From 9b96ed96accc27d6d6a8c7281b9f42c1b0931b47 Mon Sep 17 00:00:00 2001 From: Alexander Obuhovich Date: Thu, 2 Feb 2017 14:20:11 +0200 Subject: [PATCH 1/2] =?UTF-8?q?Use=20=E2=80=9CsetUpBeforeClass=E2=80=9D=20?= =?UTF-8?q?instead=20of=20=E2=80=9CsetUp=E2=80=9D=20for=20managing=20stati?= =?UTF-8?q?c=20test=20properties?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AbstractDatabaseAwareTestCase.php | 4 ++-- .../Checker/AbstractCheckerTestCase.php | 24 +++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/CodeInsight/AbstractDatabaseAwareTestCase.php b/tests/CodeInsight/AbstractDatabaseAwareTestCase.php index 3fad37a..b77ba65 100644 --- a/tests/CodeInsight/AbstractDatabaseAwareTestCase.php +++ b/tests/CodeInsight/AbstractDatabaseAwareTestCase.php @@ -30,7 +30,7 @@ protected function setUp() { parent::setUp(); - $this->database = $this->createDatabase(); + $this->database = self::createDatabase(); } /** @@ -127,7 +127,7 @@ protected function assertTableCount($table_name, $expected_record_count, Extende * * @return ExtendedPdoInterface */ - protected function createDatabase() + protected static function createDatabase() { $db = new ExtendedPdo('sqlite::memory:'); diff --git a/tests/CodeInsight/BackwardsCompatibility/Checker/AbstractCheckerTestCase.php b/tests/CodeInsight/BackwardsCompatibility/Checker/AbstractCheckerTestCase.php index 43ae29e..1004388 100644 --- a/tests/CodeInsight/BackwardsCompatibility/Checker/AbstractCheckerTestCase.php +++ b/tests/CodeInsight/BackwardsCompatibility/Checker/AbstractCheckerTestCase.php @@ -48,6 +48,17 @@ abstract class AbstractCheckerTestCase extends AbstractDatabaseAwareTestCase */ protected static $newKnowledgeBase; + public static function setUpBeforeClass() + { + parent::setUpBeforeClass(); + + static::$oldKnowledgeBase = new KnowledgeBase(__DIR__ . '/fixtures/OldProject', static::createDatabase()); + static::$oldKnowledgeBase->silentRefresh(); + + static::$newKnowledgeBase = new KnowledgeBase(__DIR__ . '/fixtures/NewProject', static::createDatabase()); + static::$newKnowledgeBase->silentRefresh(); + } + protected function setUp() { parent::setUp(); @@ -57,24 +68,13 @@ protected function setUp() $cache->save(Argument::cetera())->willReturn(true); $this->cache = $cache->reveal(); - - if ( !isset(static::$oldKnowledgeBase) ) { - static::$oldKnowledgeBase = new KnowledgeBase(__DIR__ . '/fixtures/OldProject', $this->createDatabase()); - static::$oldKnowledgeBase->silentRefresh(); - } - - if ( !isset(static::$newKnowledgeBase) ) { - static::$newKnowledgeBase = new KnowledgeBase(__DIR__ . '/fixtures/NewProject', $this->createDatabase()); - static::$newKnowledgeBase->silentRefresh(); - } - $this->checker = $this->createChecker(); } public function testEmptyCheck() { $this->assertEmpty( - $this->checker->check(self::$oldKnowledgeBase->getDatabase(), self::$oldKnowledgeBase->getDatabase()) + $this->checker->check(static::$oldKnowledgeBase->getDatabase(), static::$oldKnowledgeBase->getDatabase()) ); } From f5d0b5e94ef04b749e85457d974035b9bc614c5e Mon Sep 17 00:00:00 2001 From: Alexander Obuhovich Date: Thu, 2 Feb 2017 14:25:50 +0200 Subject: [PATCH 2/2] Adapting for __DIR__ constant handling in HHVM --- .../BackwardsCompatibility/Checker/ClassCheckerTest.php | 2 +- .../BackwardsCompatibility/Checker/ConstantCheckerTest.php | 2 +- .../BackwardsCompatibility/Checker/FunctionCheckerTest.php | 2 +- .../Checker/InPortalClassCheckerTest.php | 2 +- .../Checker/fixtures/NewProject/class_locator.php | 6 ++++-- .../Checker/fixtures/OldProject/class_locator.php | 6 ++++-- 6 files changed, 12 insertions(+), 8 deletions(-) diff --git a/tests/CodeInsight/BackwardsCompatibility/Checker/ClassCheckerTest.php b/tests/CodeInsight/BackwardsCompatibility/Checker/ClassCheckerTest.php index eaefbf7..8af0ec2 100644 --- a/tests/CodeInsight/BackwardsCompatibility/Checker/ClassCheckerTest.php +++ b/tests/CodeInsight/BackwardsCompatibility/Checker/ClassCheckerTest.php @@ -244,7 +244,7 @@ public function testCheck() 'new' => 'protected', ), ), - $this->checker->check(self::$oldKnowledgeBase->getDatabase(), self::$newKnowledgeBase->getDatabase()) + $this->checker->check(static::$oldKnowledgeBase->getDatabase(), static::$newKnowledgeBase->getDatabase()) ); } diff --git a/tests/CodeInsight/BackwardsCompatibility/Checker/ConstantCheckerTest.php b/tests/CodeInsight/BackwardsCompatibility/Checker/ConstantCheckerTest.php index 1d44bb3..1ac87c0 100644 --- a/tests/CodeInsight/BackwardsCompatibility/Checker/ConstantCheckerTest.php +++ b/tests/CodeInsight/BackwardsCompatibility/Checker/ConstantCheckerTest.php @@ -31,7 +31,7 @@ public function testCheck() 'element' => 'SOME_CONST', ), ), - $this->checker->check(self::$oldKnowledgeBase->getDatabase(), self::$newKnowledgeBase->getDatabase()) + $this->checker->check(static::$oldKnowledgeBase->getDatabase(), static::$newKnowledgeBase->getDatabase()) ); } diff --git a/tests/CodeInsight/BackwardsCompatibility/Checker/FunctionCheckerTest.php b/tests/CodeInsight/BackwardsCompatibility/Checker/FunctionCheckerTest.php index 491b639..6669d08 100644 --- a/tests/CodeInsight/BackwardsCompatibility/Checker/FunctionCheckerTest.php +++ b/tests/CodeInsight/BackwardsCompatibility/Checker/FunctionCheckerTest.php @@ -49,7 +49,7 @@ public function testCheck() 'new' => '$p1, $p2', ), ), - $this->checker->check(self::$oldKnowledgeBase->getDatabase(), self::$newKnowledgeBase->getDatabase()) + $this->checker->check(static::$oldKnowledgeBase->getDatabase(), static::$newKnowledgeBase->getDatabase()) ); } diff --git a/tests/CodeInsight/BackwardsCompatibility/Checker/InPortalClassCheckerTest.php b/tests/CodeInsight/BackwardsCompatibility/Checker/InPortalClassCheckerTest.php index 44c123d..3d131c1 100644 --- a/tests/CodeInsight/BackwardsCompatibility/Checker/InPortalClassCheckerTest.php +++ b/tests/CodeInsight/BackwardsCompatibility/Checker/InPortalClassCheckerTest.php @@ -159,7 +159,7 @@ public function testCheck() 'element' => 'ClassE::SOME_CONST', ), ), - $this->checker->check(self::$oldKnowledgeBase->getDatabase(), self::$newKnowledgeBase->getDatabase()) + $this->checker->check(static::$oldKnowledgeBase->getDatabase(), static::$newKnowledgeBase->getDatabase()) ); } diff --git a/tests/CodeInsight/BackwardsCompatibility/Checker/fixtures/NewProject/class_locator.php b/tests/CodeInsight/BackwardsCompatibility/Checker/fixtures/NewProject/class_locator.php index 5835b5e..5f44904 100644 --- a/tests/CodeInsight/BackwardsCompatibility/Checker/fixtures/NewProject/class_locator.php +++ b/tests/CodeInsight/BackwardsCompatibility/Checker/fixtures/NewProject/class_locator.php @@ -1,4 +1,6 @@