Skip to content

Commit

Permalink
updated deprecated code in unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
driehle committed Dec 29, 2024
1 parent 09bfcf3 commit 4261946
Show file tree
Hide file tree
Showing 12 changed files with 99 additions and 99 deletions.
18 changes: 9 additions & 9 deletions tests/Authentication/Adapter/ObjectRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@ public function testAuthentication(): void
->expects($this->exactly(2))
->method('findOneBy')
->with($this->equalTo(['username' => 'a username']))
->will($this->returnValue($entity));
->willReturn($entity);

$objectManager = $this->createMock(ObjectManager::class);
$objectManager->expects($this->exactly(2))
->method('getRepository')
->with($this->equalTo(IdentityObject::class))
->will($this->returnValue($objectRepository));
->willReturn($objectRepository);

$adapter = new ObjectRepositoryAdapter();
$adapter->setOptions([
Expand All @@ -138,7 +138,7 @@ public function testAuthentication(): void
$result->getIdentity(),
);

$method->will($this->returnValue(null));
$method->willReturn(null);

$result = $adapter->authenticate();

Expand All @@ -156,7 +156,7 @@ public function testAuthenticationWithPublicProperties(): void
->expects($this->exactly(2))
->method('findOneBy')
->with($this->equalTo(['username' => 'a username']))
->will($this->returnValue($entity));
->willReturn($entity);

$adapter = new ObjectRepositoryAdapter();
$adapter->setOptions([
Expand All @@ -173,7 +173,7 @@ public function testAuthenticationWithPublicProperties(): void

$this->assertTrue($result->isValid());

$method->will($this->returnValue(null));
$method->willReturn(null);

$result = $adapter->authenticate();

Expand All @@ -189,7 +189,7 @@ public function testWillRefuseToAuthenticateWithoutGettersOrPublicMethods(): voi
->expects($this->once())
->method('findOneBy')
->with($this->equalTo(['username' => 'a username']))
->will($this->returnValue(new stdClass()));
->willReturn(new stdClass());

$adapter = new ObjectRepositoryAdapter();
$adapter->setOptions([
Expand All @@ -216,7 +216,7 @@ public function testCanValidateWithSpecialCrypt(): void
->expects($this->exactly(2))
->method('findOneBy')
->with($this->equalTo(['username' => 'username']))
->will($this->returnValue($entity));
->willReturn($entity);

$adapter = new ObjectRepositoryAdapter();
$adapter->setOptions([
Expand Down Expand Up @@ -249,7 +249,7 @@ public function testWillRefuseToAuthenticateWhenInvalidInstanceIsFound(): void
->expects($this->once())
->method('findOneBy')
->with($this->equalTo(['username' => 'a username']))
->will($this->returnValue(new stdClass()));
->willReturn(new stdClass());

$adapter = new ObjectRepositoryAdapter();
$adapter->setOptions([
Expand Down Expand Up @@ -283,7 +283,7 @@ public function testWillNotCastAuthCredentialValue(): void
->expects($this->once())
->method('findOneBy')
->with($this->equalTo(['username' => 'a username']))
->will($this->returnValue($entity));
->willReturn($entity);

$this->assertFalse($adapter->authenticate()->isValid());
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Authentication/Storage/ObjectRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ public function testCanRetrieveEntityFromObjectRepositoryStorage(): void
$objectRepository->expects($this->exactly(1))
->method('find')
->with($this->equalTo('a username'))
->will($this->returnValue($entity));
->willReturn($entity);

$metadata = $this->createMock(ClassMetadata::class);
$metadata->expects($this->exactly(1))
->method('getIdentifierValues')
->with($this->equalTo($entity))
->will($this->returnValue($entity->getUsername()));
->willReturn($entity->getUsername());

$storage = new ObjectRepositoryStorage([
'objectRepository' => $objectRepository,
Expand Down
4 changes: 2 additions & 2 deletions tests/Form/Element/ObjectMultiCheckboxTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function testGetValueOptionsDoesntCauseInfiniteLoopIfProxyReturnsEmptyArr
$proxy = $this->createMock(Proxy::class);
$proxy->expects($this->exactly(2))
->method('getValueOptions')
->will($this->returnValue($options));
->willReturn($options);

$element->expects($this->never())
->method('setValueOptions');
Expand All @@ -80,7 +80,7 @@ public function testGetValueOptionsDoesntInvokeProxyIfOptionsNotEmpty(): void
$proxy = $this->createMock(Proxy::class);
$proxy->expects($this->once())
->method('getValueOptions')
->will($this->returnValue($options));
->willReturn($options);

$this->setProxyViaReflection($proxy);

Expand Down
4 changes: 2 additions & 2 deletions tests/Form/Element/ObjectRadioTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function testGetValueOptionsDoesntCauseInfiniteLoopIfProxyReturnsEmptyArr
$proxy = $this->createMock(Proxy::class);
$proxy->expects($this->exactly(2))
->method('getValueOptions')
->will($this->returnValue($options));
->willReturn($options);

$element->expects($this->never())
->method('setValueOptions');
Expand All @@ -54,7 +54,7 @@ public function testGetValueOptionsDoesntInvokeProxyIfOptionsNotEmpty(): void
$proxy = $this->createMock(Proxy::class);
$proxy->expects($this->once())
->method('getValueOptions')
->will($this->returnValue($options));
->willReturn($options);

$this->setProxyViaReflection($proxy);

Expand Down
4 changes: 2 additions & 2 deletions tests/Form/Element/ObjectSelectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function testGetValueOptionsDoesntCauseInfiniteLoopIfProxyReturnsEmptyArr
$proxy = $this->createMock(Proxy::class);
$proxy->expects($this->exactly(2))
->method('getValueOptions')
->will($this->returnValue($options));
->willReturn($options);

$element->expects($this->never())
->method('setValueOptions');
Expand All @@ -98,7 +98,7 @@ public function testGetValueOptionsDoesntInvokeProxyIfOptionsNotEmpty(): void
$proxy = $this->createMock(Proxy::class);
$proxy->expects($this->once())
->method('getValueOptions')
->will($this->returnValue($options));
->willReturn($options);

$this->setProxyViaReflection($proxy);

Expand Down
6 changes: 3 additions & 3 deletions tests/Form/Element/ProxyAwareElementTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,19 @@ static function () use ($objectOne, $objectTwo) {
$objectRepository = $this->createMock(ObjectRepository::class);
$objectRepository->expects($this->any())
->method('findAll')
->will($this->returnValue($result));
->willReturn($result);

$objectManager = $this->createMock(ObjectManager::class);
$objectManager->expects($this->any())
->method('getClassMetadata')
->with($this->equalTo($objectClass))
->will($this->returnValue($metadata));
->willReturn($metadata);

$objectManager
->expects($this->any())
->method('getRepository')
->with($this->equalTo($objectClass))
->will($this->returnValue($objectRepository));
->willReturn($objectRepository);

if (! method_exists($this->element, 'getProxy')) {
throw new RuntimeException('Element must implement getProxy().');
Expand Down
Loading

0 comments on commit 4261946

Please sign in to comment.