From 27300bf4afadf7323d2b7e2887a2e36f1127afd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Cobucci?= Date: Sun, 6 Aug 2017 12:51:16 +0200 Subject: [PATCH 1/2] Make PHPUnit strict about risky tests --- phpunit.xml.dist | 16 ++++++---------- tests/travis/mariadb.travis.xml | 8 +++++++- tests/travis/mysql.travis.xml | 8 +++++++- tests/travis/pgsql.travis.xml | 8 +++++++- tests/travis/sqlite.travis.xml | 9 +++++++-- 5 files changed, 34 insertions(+), 15 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index e6fc54315..c6bd89882 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -11,15 +11,11 @@ tests/ folder: phpunit -c ... Example: phpunit -c mysqlconf.xml AllTests --> - @@ -46,7 +42,7 @@ --> - + @@ -56,4 +52,4 @@ - \ No newline at end of file + diff --git a/tests/travis/mariadb.travis.xml b/tests/travis/mariadb.travis.xml index bac3fa480..16024c4c6 100644 --- a/tests/travis/mariadb.travis.xml +++ b/tests/travis/mariadb.travis.xml @@ -1,5 +1,11 @@ - + diff --git a/tests/travis/mysql.travis.xml b/tests/travis/mysql.travis.xml index bac3fa480..16024c4c6 100644 --- a/tests/travis/mysql.travis.xml +++ b/tests/travis/mysql.travis.xml @@ -1,5 +1,11 @@ - + diff --git a/tests/travis/pgsql.travis.xml b/tests/travis/pgsql.travis.xml index d1a0a49f2..6ad430af3 100644 --- a/tests/travis/pgsql.travis.xml +++ b/tests/travis/pgsql.travis.xml @@ -1,5 +1,11 @@ - + diff --git a/tests/travis/sqlite.travis.xml b/tests/travis/sqlite.travis.xml index f9b3ef1f3..7894dfd2e 100644 --- a/tests/travis/sqlite.travis.xml +++ b/tests/travis/sqlite.travis.xml @@ -1,6 +1,11 @@ - - + ./../Doctrine/Tests/ORM From b960170fe1f4caef762cf2837be3340ae472c120 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Cobucci?= Date: Sun, 6 Aug 2017 12:51:37 +0200 Subject: [PATCH 2/2] Move test to the right place and add assertions That test was removed from "performance" group but we forgot to move it to the correct namespace. It was also not doing any assertion, which is quite bad. More info: - https://github.com/doctrine/doctrine2/issues/3333 --- .../Ticket}/DDC2602Test.php | 45 +++++++++---------- 1 file changed, 22 insertions(+), 23 deletions(-) rename tests/Doctrine/Tests/ORM/{Performance => Functional/Ticket}/DDC2602Test.php (83%) diff --git a/tests/Doctrine/Tests/ORM/Performance/DDC2602Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2602Test.php similarity index 83% rename from tests/Doctrine/Tests/ORM/Performance/DDC2602Test.php rename to tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2602Test.php index de8bedfc7..23b9f662f 100644 --- a/tests/Doctrine/Tests/ORM/Performance/DDC2602Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2602Test.php @@ -1,62 +1,61 @@ _schemaTool->createSchema( [ - $this->_em->getClassMetadata(DDC2602User::class), - $this->_em->getClassMetadata(DDC2602Biography::class), - $this->_em->getClassMetadata(DDC2602BiographyField::class), - $this->_em->getClassMetadata(DDC2602BiographyFieldChoice::class), + $this->_em->getClassMetadata(DDC2602User::class), + $this->_em->getClassMetadata(DDC2602Biography::class), + $this->_em->getClassMetadata(DDC2602BiographyField::class), + $this->_em->getClassMetadata(DDC2602BiographyFieldChoice::class), ] ); $this->loadFixture(); } - protected function tearDown() + protected function tearDown() : void { parent::tearDown(); $this->_schemaTool->dropSchema( [ - $this->_em->getClassMetadata(DDC2602User::class), - $this->_em->getClassMetadata(DDC2602Biography::class), - $this->_em->getClassMetadata(DDC2602BiographyField::class), - $this->_em->getClassMetadata(DDC2602BiographyFieldChoice::class), + $this->_em->getClassMetadata(DDC2602User::class), + $this->_em->getClassMetadata(DDC2602Biography::class), + $this->_em->getClassMetadata(DDC2602BiographyField::class), + $this->_em->getClassMetadata(DDC2602BiographyFieldChoice::class), ] ); } - public function testIssue() + public function testPostLoadListenerShouldBeAbleToRunQueries() : void { $eventManager = $this->_em->getEventManager(); $eventManager->addEventListener([Events::postLoad], new DDC2602PostLoadListener()); - // Set maximum seconds this can run - $this->setMaxRunningTime(1); + $result = $this->_em->createQuery('SELECT u, b FROM Doctrine\Tests\ORM\Functional\Ticket\DDC2602User u JOIN u.biography b') + ->getResult(); - $this - ->_em - ->createQuery('SELECT u, b FROM Doctrine\Tests\ORM\Performance\DDC2602User u JOIN u.biography b') - ->getResult(); + self::assertCount(2, $result); + self::assertCount(2, $result[0]->biography->fieldList); + self::assertCount(1, $result[1]->biography->fieldList); } - private function loadFixture() + private function loadFixture() : void { $user1 = new DDC2602User(); $user2 = new DDC2602User(); @@ -127,7 +126,7 @@ class DDC2602Test extends OrmPerformanceTestCase class DDC2602PostLoadListener { - public function postLoad(LifecycleEventArgs $event) + public function postLoad(LifecycleEventArgs $event) : void { $entity = $event->getEntity(); @@ -138,7 +137,7 @@ class DDC2602PostLoadListener $entityManager = $event->getEntityManager(); $query = $entityManager->createQuery(' SELECT f, fc - FROM Doctrine\Tests\ORM\Performance\DDC2602BiographyField f INDEX BY f.id + FROM Doctrine\Tests\ORM\Functional\Ticket\DDC2602BiographyField f INDEX BY f.id JOIN f.choiceList fc INDEX BY fc.id ');