Skip to content

Commit f2fdccd

Browse files
committed
Use phpunit 13 where possible
1 parent bd87a1e commit f2fdccd

12 files changed

Lines changed: 24 additions & 5511 deletions

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,5 @@ phpunit.xml
66
/.phpunit.cache/
77
/build/
88
/vendor/
9-
!/vendor-bin/tools/composer.lock
109
/vendor-bin/tools/vendor/
1110
/vendor-bin/tools/bin/

tests/Command/ActivateUserCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ private function createCommandTester(UserManipulator $manipulator, ?Application
6868

6969
$command = new ActivateUserCommand($manipulator);
7070

71-
$application->add($command);
71+
$application->addCommand($command);
7272

7373
return new CommandTester($application->find('nucleos:user:activate'));
7474
}

tests/Command/ChangePasswordCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ private function createCommandTester(UserManipulator $manipulator, ?Application
7272

7373
$command = new ChangePasswordCommand($manipulator);
7474

75-
$application->add($command);
75+
$application->addCommand($command);
7676

7777
return new CommandTester($application->find('nucleos:user:change-password'));
7878
}

tests/Command/CreateUserCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ private function createCommandTester(UserManipulator $manipulator, ?Application
7777

7878
$command = new CreateUserCommand($manipulator);
7979

80-
$application->add($command);
80+
$application->addCommand($command);
8181

8282
return new CommandTester($application->find('nucleos:user:create'));
8383
}

tests/Command/DeactivateUserCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ private function createCommandTester(UserManipulator $manipulator, ?Application
6868

6969
$command = new DeactivateUserCommand($manipulator);
7070

71-
$application->add($command);
71+
$application->addCommand($command);
7272

7373
return new CommandTester($application->find('nucleos:user:deactivate'));
7474
}

tests/Command/DemoteUserCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ private function createCommandTester(UserManipulator $manipulator, ?Application
7272

7373
$command = new DemoteUserCommand($manipulator);
7474

75-
$application->add($command);
75+
$application->addCommand($command);
7676

7777
return new CommandTester($application->find('nucleos:user:demote'));
7878
}

tests/Command/PromoteUserCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ private function createCommandTester(UserManipulator $manipulator, ?Application
7272

7373
$command = new PromoteUserCommand($manipulator);
7474

75-
$application->add($command);
75+
$application->addCommand($command);
7676

7777
return new CommandTester($application->find('nucleos:user:promote'));
7878
}

tests/Doctrine/BaseUserManagerTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,16 @@ protected function setUp(): void
4545
$this->repository = $this->getMockBuilder(ObjectRepository::class)->getMock();
4646

4747
$this->om
48-
->method('getRepository')
48+
->expects(self::any())->method('getRepository')
4949
->with(self::equalTo(self::USER_CLASS))
5050
->willReturn($this->repository)
5151
;
5252
$this->om
53-
->method('getClassMetadata')
53+
->expects(self::any())->method('getClassMetadata')
5454
->with(self::equalTo(self::USER_CLASS))
5555
->willReturn($class)
5656
;
57+
5758
$class
5859
->method('getName')
5960
->willReturn(self::USER_CLASS)

tests/Mailer/SimpleMailerTest.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,18 @@ public function testSendResettingEmail(): void
4848
{
4949
$mailer = $this->getMailer();
5050

51-
$this->translator->method('trans')->with(self::anything(), self::anything(), self::anything())
51+
$this->translator->expects(self::once())->method('trans')
52+
->with(self::anything(), self::anything(), self::anything())
5253
->willReturnArgument(0)
5354
;
5455

55-
$this->generator->method('generate')->with(self::anything(), self::anything(), self::anything())
56+
$this->generator->expects(self::once())->method('generate')
57+
->with(self::anything(), self::anything(), self::anything())
5658
->willReturn('http://something.local')
5759
;
5860

59-
$this->swiftMailer->expects(self::once())->method('send')->with(self::isInstanceOf(TemplatedEmail::class));
61+
$this->swiftMailer->expects(self::once())->method('send')
62+
->with(self::isInstanceOf(TemplatedEmail::class));
6063

6164
$mailer->sendResettingEmailMessage($this->getUser());
6265
}

tests/Util/SimpleUserManipulatorTest.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,10 @@ public function testCreateWithHasher(): void
8484
$requestStackMock = $this->getRequestStackMock(true);
8585

8686
$hasher = $this->createMock(UserPasswordHasherInterface::class);
87-
$hasher->method('hashPassword')->with($user, $password)->willReturn('hashed_password');
87+
$hasher->expects(self::once())->method('hashPassword')
88+
->with($user, $password)
89+
->willReturn('hashed_password')
90+
;
8891

8992
$manipulator = new SimpleUserManipulator($userManagerMock, $eventDispatcherMock, $requestStackMock, $hasher);
9093
$manipulator->create($username, $password, $email, true, false);
@@ -383,7 +386,10 @@ public function testChangePasswordWithValidUsernameAndHasher(): void
383386
$requestStackMock = $this->getRequestStackMock(true);
384387

385388
$hasher = $this->createMock(UserPasswordHasherInterface::class);
386-
$hasher->method('hashPassword')->with($user, $password)->willReturn('hashed_password');
389+
$hasher->expects(self::once())->method('hashPassword')
390+
->with($user, $password)
391+
->willReturn('hashed_password')
392+
;
387393

388394
$manipulator = new SimpleUserManipulator($userManagerMock, $eventDispatcherMock, $requestStackMock, $hasher);
389395
$manipulator->changePassword($username, $password);

0 commit comments

Comments
 (0)