Skip to content

Commit

Permalink
Add deprecated assertions in our own suite of tests for now
Browse files Browse the repository at this point in the history
  • Loading branch information
carusogabriel committed Jul 21, 2019
1 parent a293cc7 commit d2fbd38
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
5 changes: 2 additions & 3 deletions tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3123Test.php
Expand Up @@ -22,7 +22,6 @@ protected function setUp() : void

public function testIssue() : void
{
$test = $this;
$user = new CmsUser();
$uow = $this->em->getUnitOfWork();

Expand All @@ -39,8 +38,8 @@ public function testIssue() : void
$listener
->expects($this->once())
->method(Events::postFlush)
->will($this->returnCallback(static function () use ($uow, $test) {
$test->assertAttributeEmpty('extraUpdates', $uow, 'ExtraUpdates are reset before postFlush');
->will($this->returnCallback(static function () use ($uow) {
self::assertAttributeEmpty('extraUpdates', $uow, 'ExtraUpdates are reset before postFlush');
}));

$this->em->getEventManager()->addEventListener(Events::postFlush, $listener);
Expand Down
2 changes: 1 addition & 1 deletion tests/Doctrine/Tests/ORM/Query/QueryTest.php
Expand Up @@ -401,7 +401,7 @@ public function testResultCacheProfileCanBeRemovedViaSetter() : void
$query->useResultCache(true);
$query->setResultCacheProfile();

self::assertAttributeSame(null, 'queryCacheProfile', $query);
self::assertAttributeEmpty('queryCacheProfile', $query);
}

/** @group 7527 */
Expand Down
19 changes: 19 additions & 0 deletions tests/Doctrine/Tests/OrmTestCase.php
Expand Up @@ -19,6 +19,7 @@
use Doctrine\ORM\Proxy\Factory\ProxyFactory;
use function is_array;
use function realpath;
use ReflectionClass;

/**
* Base testcase class for all ORM testcases.
Expand Down Expand Up @@ -171,4 +172,22 @@ protected function getSharedSecondLevelCacheDriverImpl()

return $this->secondLevelCacheDriverImpl;
}

public static function assertAttributeEmpty(string $haystackAttributeName, $haystackClassOrObject, string $message = ''): void
{
$class = new ReflectionClass($haystackClassOrObject);
$property = $class->getProperty($haystackAttributeName);
$property->setAccessible(true);

self::assertEmpty($property->getValue($haystackClassOrObject));
}

public static function assertAttributeSame($expected, string $actualAttributeName, $actualClassOrObject, string $message = ''): void
{
$class = new ReflectionClass($actualClassOrObject);
$property = $class->getProperty($actualAttributeName);
$property->setAccessible(true);

self::assertSame($expected, $property->getValue($actualClassOrObject));
}
}

0 comments on commit d2fbd38

Please sign in to comment.