Skip to content

Commit

Permalink
Merge pull request doctrine#7440 from carusogabriel/dedicated-assertions
Browse files Browse the repository at this point in the history
Use dedicated assertContainsOnlyInstancesOf PHPUnit assertion
  • Loading branch information
Ocramius committed Oct 30, 2018
2 parents 91346c4 + b0825e4 commit d81284b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 26 deletions.
Expand Up @@ -151,10 +151,7 @@ public function testQueryCacheFindAllJoinTableEntities() : void

self::assertCount(count($this->attractionsInfo), $result2);
self::assertEquals($queryCount + 1, $this->getCurrentQueryCount());

foreach ($result2 as $entity) {
self::assertInstanceOf(AttractionInfo::class, $entity);
}
self::assertContainsOnlyInstancesOf(AttractionInfo::class, $result2);
}

public function testOneToManyRelationJoinTable() : void
Expand Down Expand Up @@ -231,9 +228,6 @@ public function testQueryCacheShouldBeEvictedOnTimestampUpdate() : void

self::assertCount(count($this->attractionsInfo) + 1, $result2);
self::assertEquals($queryCount + 6, $this->getCurrentQueryCount());

foreach ($result2 as $entity) {
self::assertInstanceOf(AttractionInfo::class, $entity);
}
self::assertContainsOnlyInstancesOf(AttractionInfo::class, $result2);
}
}
Expand Up @@ -1151,9 +1151,6 @@ public function testQueryCacheShouldBeEvictedOnTimestampUpdate() : void

self::assertCount(3, $result2);
self::assertEquals($queryCount + 1, $this->getCurrentQueryCount());

foreach ($result2 as $entity) {
self::assertInstanceOf(Country::class, $entity);
}
self::assertContainsOnlyInstancesOf(Country::class, $result2);
}
}
Expand Up @@ -145,10 +145,7 @@ public function testQueryCacheFindAll() : void

self::assertCount(count($this->attractions), $result2);
self::assertEquals($queryCount + 1, $this->getCurrentQueryCount());

foreach ($result2 as $entity) {
self::assertInstanceOf(Attraction::class, $entity);
}
self::assertContainsOnlyInstancesOf(Attraction::class, $result2);
}

public function testShouldNotPutOneToManyRelationOnPersist() : void
Expand Down Expand Up @@ -251,9 +248,6 @@ public function testQueryCacheShouldBeEvictedOnTimestampUpdate() : void

self::assertCount(count($this->attractions) + 1, $result2);
self::assertEquals($queryCount + 1, $this->getCurrentQueryCount());

foreach ($result2 as $entity) {
self::assertInstanceOf(Attraction::class, $entity);
}
self::assertContainsOnlyInstancesOf(Attraction::class, $result2);
}
}
8 changes: 2 additions & 6 deletions tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1685Test.php
Expand Up @@ -45,9 +45,7 @@ public function testPaginateCount() : void

public function testPaginateIterate() : void
{
foreach ($this->paginator as $ad) {
self::assertInstanceOf(DDC117ArticleDetails::class, $ad);
}
self::assertContainsOnlyInstancesOf(DDC117ArticleDetails::class, $this->paginator);
}

public function testPaginateCountNoOutputWalkers() : void
Expand All @@ -64,8 +62,6 @@ public function testPaginateIterateNoOutputWalkers() : void
$this->expectException(\RuntimeException::class);
$this->expectExceptionMessage('Paginating an entity with foreign key as identifier only works when using the Output Walkers. Call Paginator#setUseOutputWalkers(true) before iterating the paginator.');

foreach ($this->paginator as $ad) {
self::assertInstanceOf(DDC117ArticleDetails::class, $ad);
}
self::assertContainsOnlyInstancesOf(DDC117ArticleDetails::class, $this->paginator);
}
}

0 comments on commit d81284b

Please sign in to comment.