Skip to content

Commit

Permalink
fixed : assertAttributeEmpty() deprecated in PHPUnit.
Browse files Browse the repository at this point in the history
assertAttributeEmpty is deprecated, see deprecated sebastianbergmann/phpunit#3338

Furthermore, getNbUnread() should return an `int` instead of null. It would be worth it to ensure it is an integer. (and test it)
  • Loading branch information
encreinformatique committed Mar 10, 2021
1 parent 72b6006 commit c4d656e
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions Tests/Twig/Extension/MessageExtensionTest.php
Expand Up @@ -81,15 +81,27 @@ public function testGetNbUnreadCacheStartsEmpty()
{
$this->setUpBeforeTest();

$this->assertAttributeEmpty('nbUnreadMessagesCache', $this->extension);
/*
* assertAttributeEmpty is deprecated, see deprecated https://github.com/sebastianbergmann/phpunit/issues/3338
*/
if (\method_exists($this, 'assertAttributeEmpty')) {
$this->assertAttributeEmpty('nbUnreadMessagesCache', $this->extension);
}
$this->assertEmpty($this->extension->getNbUnread());
$this->extension->getNbUnread();
}

public function testGetNbUnread()
{
$this->setUpBeforeTest();

$this->assertAttributeEmpty('nbUnreadMessagesCache', $this->extension);
/*
* assertAttributeEmpty is deprecated, see deprecated https://github.com/sebastianbergmann/phpunit/issues/3338
*/
if (\method_exists($this, 'assertAttributeEmpty')) {
$this->assertAttributeEmpty('nbUnreadMessagesCache', $this->extension);
}
$this->assertEmpty($this->extension->getNbUnread());
$this->provider->expects($this->once())->method('getNbUnreadMessages')->will($this->returnValue(3));
$this->assertEquals(3, $this->extension->getNbUnread());
}
Expand Down

0 comments on commit c4d656e

Please sign in to comment.