From 909353ea39a6e967d1f39244670dd209e03413ac Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Mon, 23 Jan 2017 15:05:41 +0900 Subject: [PATCH] Simplify bootstrap for tests --- .../Cell/AdvancedValueBinderTest.php | 11 ----------- .../PhpSpreadsheetTests/Cell/DataTypeTest.php | 8 -------- .../Cell/DefaultValueBinderTest.php | 8 -------- .../PhpSpreadsheetTests/Cell/HyperlinkTest.php | 8 -------- tests/bootstrap.php | 18 +----------------- 5 files changed, 1 insertion(+), 52 deletions(-) diff --git a/tests/PhpSpreadsheetTests/Cell/AdvancedValueBinderTest.php b/tests/PhpSpreadsheetTests/Cell/AdvancedValueBinderTest.php index cba8af88..7c72e779 100644 --- a/tests/PhpSpreadsheetTests/Cell/AdvancedValueBinderTest.php +++ b/tests/PhpSpreadsheetTests/Cell/AdvancedValueBinderTest.php @@ -12,19 +12,8 @@ use PhpOffice\PhpSpreadsheet\Worksheet; class AdvancedValueBinderTest extends \PHPUnit_Framework_TestCase { - public function setUp() - { - if (!defined('PHPSPREADSHEET_ROOT')) { - define('PHPSPREADSHEET_ROOT', APPLICATION_PATH . '/'); - } - require_once PHPSPREADSHEET_ROOT . '/Bootstrap.php'; - } - public function provider() { - if (!class_exists(NumberFormat::class)) { - $this->setUp(); - } $currencyUSD = NumberFormat::FORMAT_CURRENCY_USD_SIMPLE; $currencyEURO = str_replace('$', '€', NumberFormat::FORMAT_CURRENCY_USD_SIMPLE); diff --git a/tests/PhpSpreadsheetTests/Cell/DataTypeTest.php b/tests/PhpSpreadsheetTests/Cell/DataTypeTest.php index 48f432dd..f98f4fb5 100644 --- a/tests/PhpSpreadsheetTests/Cell/DataTypeTest.php +++ b/tests/PhpSpreadsheetTests/Cell/DataTypeTest.php @@ -6,14 +6,6 @@ use PhpOffice\PhpSpreadsheet\Cell\DataType; class DataTypeTest extends \PHPUnit_Framework_TestCase { - public function setUp() - { - if (!defined('PHPSPREADSHEET_ROOT')) { - define('PHPSPREADSHEET_ROOT', APPLICATION_PATH . '/'); - } - require_once PHPSPREADSHEET_ROOT . '/Bootstrap.php'; - } - public function testGetErrorCodes() { $result = DataType::getErrorCodes(); diff --git a/tests/PhpSpreadsheetTests/Cell/DefaultValueBinderTest.php b/tests/PhpSpreadsheetTests/Cell/DefaultValueBinderTest.php index 95cf6861..ca892d66 100644 --- a/tests/PhpSpreadsheetTests/Cell/DefaultValueBinderTest.php +++ b/tests/PhpSpreadsheetTests/Cell/DefaultValueBinderTest.php @@ -11,14 +11,6 @@ class DefaultValueBinderTest extends \PHPUnit_Framework_TestCase { protected $cellStub; - public function setUp() - { - if (!defined('PHPSPREADSHEET_ROOT')) { - define('PHPSPREADSHEET_ROOT', APPLICATION_PATH . '/'); - } - require_once PHPSPREADSHEET_ROOT . '/Bootstrap.php'; - } - protected function createCellStub() { // Create a stub for the Cell class. diff --git a/tests/PhpSpreadsheetTests/Cell/HyperlinkTest.php b/tests/PhpSpreadsheetTests/Cell/HyperlinkTest.php index 9f88e588..b4c68f62 100644 --- a/tests/PhpSpreadsheetTests/Cell/HyperlinkTest.php +++ b/tests/PhpSpreadsheetTests/Cell/HyperlinkTest.php @@ -6,14 +6,6 @@ use PhpOffice\PhpSpreadsheet\Cell\Hyperlink; class HyperlinkTest extends \PHPUnit_Framework_TestCase { - public function setUp() - { - if (!defined('PHPSPREADSHEET_ROOT')) { - define('PHPSPREADSHEET_ROOT', APPLICATION_PATH . '/'); - } - require_once PHPSPREADSHEET_ROOT . '/Bootstrap.php'; - } - public function testGetUrl() { $urlValue = 'http://www.phpexcel.net'; diff --git a/tests/bootstrap.php b/tests/bootstrap.php index bd444395..f89fe408 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -10,20 +10,4 @@ setlocale(LC_ALL, 'en_US.utf8'); // PHP 5.3 Compat date_default_timezone_set('Europe/London'); -// Define path to application directory -defined('APPLICATION_PATH') - || define('APPLICATION_PATH', realpath(__DIR__ . '/../src')); - -// Ensure library/ is on include_path -set_include_path(implode(PATH_SEPARATOR, [ - realpath(APPLICATION_PATH . '/../src'), - './', - __DIR__, - get_include_path(), -])); - -if (!defined('PHPSPREADSHEET_ROOT')) { - define('PHPSPREADSHEET_ROOT', APPLICATION_PATH . '/'); -} - -require_once PHPSPREADSHEET_ROOT . 'Bootstrap.php'; +require_once __DIR__ . '/../src/Bootstrap.php';