Upgrade tests to PhpUnit 10 (#5252)

This commit is contained in:
Kevin Papst
2024-12-22 01:25:30 +01:00
committed by GitHub
parent 9bd37fb695
commit c7f0508707
377 changed files with 3308 additions and 3409 deletions

View File

@@ -70,7 +70,7 @@ class ActivateUserCommandTest extends KernelTestCase
$commandTester = $this->callCommand('chris_user');
$output = $commandTester->getDisplay();
$this->assertStringContainsString('[OK] User "chris_user" has been activated.', $output);
self::assertStringContainsString('[OK] User "chris_user" has been activated.', $output);
$container = self::$kernel->getContainer();
/** @var Registry $doctrine */
@@ -87,7 +87,7 @@ class ActivateUserCommandTest extends KernelTestCase
$commandTester = $this->callCommand('susan_super');
$output = $commandTester->getDisplay();
$this->assertStringContainsString('[WARNING] User "susan_super" is already active.', $output);
self::assertStringContainsString('[WARNING] User "susan_super" is already active.', $output);
}
public function testWithMissingUsername(): void

View File

@@ -86,7 +86,7 @@ class ChangePasswordCommandTest extends KernelTestCase
$commandTester = $this->callCommand('john_user', '0987654321');
$output = $commandTester->getDisplay();
$this->assertStringContainsString('[OK] Changed password for user "john_user".', $output);
self::assertStringContainsString('[OK] Changed password for user "john_user".', $output);
/** @var Registry $doctrine */
$doctrine = self::getContainer()->get('doctrine');
@@ -105,7 +105,7 @@ class ChangePasswordCommandTest extends KernelTestCase
$commandTester = $this->callCommand('john_user', '1');
$output = $commandTester->getDisplay();
$this->assertStringContainsString('[ERROR] plainPassword: This value is too short.', $output);
self::assertStringContainsString('[ERROR] plainPassword: This value is too short.', $output);
}
public function testWithMissingUsername(): void
@@ -120,6 +120,6 @@ class ChangePasswordCommandTest extends KernelTestCase
{
$commandTester = $this->callCommand('john_user', null);
$output = $commandTester->getDisplay();
$this->assertStringContainsString('[OK] Changed password for user "john_user".', $output);
self::assertStringContainsString('[OK] Changed password for user "john_user".', $output);
}
}

View File

@@ -42,7 +42,7 @@ class CreateUserCommandTest extends KernelTestCase
$commandTester = $this->createUser('MyTestUser', 'user@example.com', 'ROLE_USER', 'foobar');
$output = $commandTester->getDisplay();
$this->assertStringContainsString('[ERROR] plainPassword: This value is too short.', $output);
self::assertStringContainsString('[ERROR] plainPassword: This value is too short.', $output);
}
public function testCreateUser(): void
@@ -50,7 +50,7 @@ class CreateUserCommandTest extends KernelTestCase
$commandTester = $this->createUser('MyTestUser', 'user@example.com', 'ROLE_USER', 'foobar12');
$output = $commandTester->getDisplay();
$this->assertStringContainsString('[OK] Success! Created user: MyTestUser', $output);
self::assertStringContainsString('[OK] Success! Created user: MyTestUser', $output);
$container = self::$kernel->getContainer();
/** @var Registry $doctrine */
@@ -80,9 +80,9 @@ class CreateUserCommandTest extends KernelTestCase
{
$commandTester = $this->createUser('xx', '', 'ROLE_USER', '');
$output = $commandTester->getDisplay();
$this->assertStringContainsString('[ERROR] email: This value should not be blank', $output);
$this->assertStringContainsString('[ERROR] plainPassword: This value should not be blank', $output);
$this->assertStringContainsString('[ERROR] plainPassword: This value is too short.', $output);
self::assertStringContainsString('[ERROR] email: This value should not be blank', $output);
self::assertStringContainsString('[ERROR] plainPassword: This value should not be blank', $output);
self::assertStringContainsString('[ERROR] plainPassword: This value is too short.', $output);
}
public function testUserAlreadyExisting(): void
@@ -91,7 +91,7 @@ class CreateUserCommandTest extends KernelTestCase
$commandTester = $this->createUser('MyTestUser', 'user2@example.com', 'ROLE_USER', 'foobar123');
$output = $commandTester->getDisplay();
$this->assertStringContainsString('[ERROR] username: The username is already used.', $output);
self::assertStringContainsString('[ERROR] username: The username is already used.', $output);
}
public function testEmailAlreadyExisting(): void
@@ -100,7 +100,7 @@ class CreateUserCommandTest extends KernelTestCase
$commandTester = $this->createUser('MyTestUser2', 'user@example.com', 'ROLE_USER', 'foobar');
$output = $commandTester->getDisplay();
$this->assertStringContainsString('[ERROR] email: This e-mail address is already in use.', $output);
self::assertStringContainsString('[ERROR] email: This e-mail address is already in use.', $output);
}
public function testUserEmail(): void
@@ -108,6 +108,6 @@ class CreateUserCommandTest extends KernelTestCase
$commandTester = $this->createUser('MyTestUser', 'ROLE_USER', 'ROLE_USER', 'foobar12');
$output = $commandTester->getDisplay();
$this->assertStringContainsString('[ERROR] email: This value is not a valid email address', $output);
self::assertStringContainsString('[ERROR] email: This value is not a valid email address', $output);
}
}

View File

@@ -69,7 +69,7 @@ class DeactivateUserCommandTest extends KernelTestCase
$commandTester = $this->callCommand('john_user');
$output = $commandTester->getDisplay();
$this->assertStringContainsString('[OK] User "john_user" has been deactivated.', $output);
self::assertStringContainsString('[OK] User "john_user" has been deactivated.', $output);
$container = self::$kernel->getContainer();
/** @var Registry $doctrine */
@@ -86,7 +86,7 @@ class DeactivateUserCommandTest extends KernelTestCase
$commandTester = $this->callCommand('chris_user');
$output = $commandTester->getDisplay();
$this->assertStringContainsString('[WARNING] User "chris_user" is already deactivated.', $output);
self::assertStringContainsString('[WARNING] User "chris_user" is already deactivated.', $output);
}
public function testWithMissingUsername(): void

View File

@@ -79,7 +79,7 @@ class DemoteUserCommandTest extends KernelTestCase
$commandTester = $this->callCommand('tony_teamlead', 'ROLE_TEAMLEAD');
$output = $commandTester->getDisplay();
$this->assertStringContainsString('[OK] Role "ROLE_TEAMLEAD" has been removed from user "tony_teamlead".', $output);
self::assertStringContainsString('[OK] Role "ROLE_TEAMLEAD" has been removed from user "tony_teamlead".', $output);
$container = self::$kernel->getContainer();
/** @var Registry $doctrine */
@@ -96,7 +96,7 @@ class DemoteUserCommandTest extends KernelTestCase
$commandTester = $this->callCommand('susan_super', null, true);
$output = $commandTester->getDisplay();
$this->assertStringContainsString('[OK] Super administrator role has been removed from the user "susan_super".', $output);
self::assertStringContainsString('[OK] Super administrator role has been removed from the user "susan_super".', $output);
$container = self::$kernel->getContainer();
/** @var Registry $doctrine */
@@ -113,7 +113,7 @@ class DemoteUserCommandTest extends KernelTestCase
$commandTester = $this->callCommand('tony_teamlead', null, true);
$output = $commandTester->getDisplay();
$this->assertStringContainsString('[WARNING] User "tony_teamlead" doesn\'t have the super administrator role.', $output);
self::assertStringContainsString('[WARNING] User "tony_teamlead" doesn\'t have the super administrator role.', $output);
}
public function testDemoteAdminFailsOnTeamlead(): void
@@ -121,7 +121,7 @@ class DemoteUserCommandTest extends KernelTestCase
$commandTester = $this->callCommand('tony_teamlead', 'ROLE_ADMIN', false);
$output = $commandTester->getDisplay();
$this->assertStringContainsString('[WARNING] User "tony_teamlead" didn\'t have "ROLE_ADMIN" role.', $output);
self::assertStringContainsString('[WARNING] User "tony_teamlead" didn\'t have "ROLE_ADMIN" role.', $output);
}
public function testDemoteRoleAndSuperFails(): void

View File

@@ -122,7 +122,7 @@ class ExportCreateCommandTest extends KernelTestCase
$commandTester = $this->createExport($options);
$output = $commandTester->getDisplay();
$this->assertStringContainsString('[ERROR] ' . $errorMessage, $output);
self::assertStringContainsString('[ERROR] ' . $errorMessage, $output);
}
protected function assertCommandResult(array $options = [], string $message = ''): void
@@ -130,7 +130,7 @@ class ExportCreateCommandTest extends KernelTestCase
$commandTester = $this->createExport($options);
$output = $commandTester->getDisplay();
$this->assertStringContainsString('[OK] ' . $message, $output);
self::assertStringContainsString('[OK] ' . $message, $output);
}
public function testCreateWithUnknownExportFilter(): void
@@ -179,7 +179,7 @@ class ExportCreateCommandTest extends KernelTestCase
$commandTester = $this->createExport($options);
$output = $commandTester->getDisplay();
$this->assertStringContainsString('[OK] No entries found, skipping', $output);
self::assertStringContainsString('[OK] No entries found, skipping', $output);
}
/**
@@ -217,7 +217,7 @@ class ExportCreateCommandTest extends KernelTestCase
$commandTester = $this->createExport(['--template' => 'csv', '--customer' => [$data[0]->getId()], '--start' => $start->format('Y-m-d'), '--end' => $end->format('Y-m-d'), '--username' => UserFixtures::USERNAME_SUPER_ADMIN]);
$output = $commandTester->getDisplay();
$this->assertStringContainsString('Saved export to: ', $output);
self::assertStringContainsString('Saved export to: ', $output);
}
public function testCreateExportByProject(): void
@@ -230,7 +230,7 @@ class ExportCreateCommandTest extends KernelTestCase
$commandTester = $this->createExport(['--template' => 'csv', '--project' => [$data[1][0]->getId()], '--start' => $start->format('Y-m-d'), '--end' => $end->format('Y-m-d')]);
$output = $commandTester->getDisplay();
$this->assertStringContainsString('Saved export to: ', $output);
self::assertStringContainsString('Saved export to: ', $output);
}
public function testCreateExportWithEmail(): void
@@ -252,7 +252,7 @@ class ExportCreateCommandTest extends KernelTestCase
]));
$output = $commandTester->getDisplay();
$this->assertStringContainsString('Send email with report to: foo@example.com', $output);
$this->assertStringContainsString('Send email with report to: foo2@example.com', $output);
self::assertStringContainsString('Send email with report to: foo@example.com', $output);
self::assertStringContainsString('Send email with report to: foo2@example.com', $output);
}
}

View File

@@ -108,7 +108,7 @@ class InvoiceCreateCommandTest extends KernelTestCase
$commandTester = $this->createInvoice($options);
$output = $commandTester->getDisplay();
$this->assertStringContainsString('[ERROR] ' . $errorMessage, $output);
self::assertStringContainsString('[ERROR] ' . $errorMessage, $output);
}
public function testCreateWithUnknownExportFilter(): void
@@ -174,13 +174,13 @@ class InvoiceCreateCommandTest extends KernelTestCase
$commandTester = $this->createInvoice(['--user' => UserFixtures::USERNAME_SUPER_ADMIN, '--customer' => 1, '--template' => 'Invoice', '--start' => '2020-01-01', '--end' => '2020-03-01']);
$output = $commandTester->getDisplay();
$this->assertStringContainsString('Created 1 invoice(s)', $output);
$this->assertStringContainsString('| ID', $output);
$this->assertStringContainsString('| Customer', $output);
$this->assertStringContainsString('| Total', $output);
$this->assertStringContainsString('| Filename', $output);
$this->assertStringContainsString('0 EUR', $output);
$this->assertStringContainsString('/tests/_data/invoices/' . ((new \DateTime())->format('Y')) . '-001-Test.html |', $output);
self::assertStringContainsString('Created 1 invoice(s)', $output);
self::assertStringContainsString('| ID', $output);
self::assertStringContainsString('| Customer', $output);
self::assertStringContainsString('| Total', $output);
self::assertStringContainsString('| Filename', $output);
self::assertStringContainsString('0 EUR', $output);
self::assertStringContainsString('/tests/_data/invoices/' . ((new \DateTime())->format('Y')) . '-001-Test.html |', $output);
}
/**
@@ -224,7 +224,7 @@ class InvoiceCreateCommandTest extends KernelTestCase
$commandTester = $this->createInvoice(['--user' => UserFixtures::USERNAME_SUPER_ADMIN, '--by-customer' => null, '--start' => $start->format('Y-m-d'), '--end' => $end->format('Y-m-d')]);
$output = $commandTester->getDisplay();
$this->assertStringContainsString('Created 1 invoice(s) ', $output);
self::assertStringContainsString('Created 1 invoice(s) ', $output);
}
public function testCreateInvoiceByCustomerId(): void
@@ -238,7 +238,7 @@ class InvoiceCreateCommandTest extends KernelTestCase
$commandTester = $this->createInvoice(['--user' => UserFixtures::USERNAME_SUPER_ADMIN, '--customer' => $customer . ',1', '--start' => $start->format('Y-m-d'), '--end' => $end->format('Y-m-d')]);
$output = $commandTester->getDisplay();
$this->assertStringContainsString('Created 1 invoice(s) ', $output);
self::assertStringContainsString('Created 1 invoice(s) ', $output);
}
public function testCreateInvoiceByProject(): void
@@ -251,7 +251,7 @@ class InvoiceCreateCommandTest extends KernelTestCase
$commandTester = $this->createInvoice(['--user' => UserFixtures::USERNAME_SUPER_ADMIN, '--exported' => 'all', '--by-project' => null, '--start' => $start->format('Y-m-d'), '--end' => $end->format('Y-m-d')]);
$output = $commandTester->getDisplay();
$this->assertStringContainsString('Created 1 invoice(s) ', $output);
self::assertStringContainsString('Created 1 invoice(s) ', $output);
}
public function testCreateInvoiceByProjectId(): void
@@ -264,7 +264,7 @@ class InvoiceCreateCommandTest extends KernelTestCase
$commandTester = $this->createInvoice(['--user' => UserFixtures::USERNAME_SUPER_ADMIN, '--exported' => 'all', '--project' => '1', '--template' => 'Invoice', '--start' => $start->format('Y-m-d'), '--end' => $end->format('Y-m-d')]);
$output = $commandTester->getDisplay();
$this->assertStringContainsString('Created 1 invoice(s) ', $output);
self::assertStringContainsString('Created 1 invoice(s) ', $output);
}
public function testCreateInvoiceByProjectWithPreview(): void
@@ -277,6 +277,6 @@ class InvoiceCreateCommandTest extends KernelTestCase
$commandTester = $this->createInvoice(['--user' => UserFixtures::USERNAME_SUPER_ADMIN, '--exported' => 'all', '--preview' => sys_get_temp_dir(), '--by-project' => null, '--start' => $start->format('Y-m-d'), '--end' => $end->format('Y-m-d')]);
$output = $commandTester->getDisplay();
$this->assertStringContainsString('Created 1 invoice(s) ', $output);
self::assertStringContainsString('Created 1 invoice(s) ', $output);
}
}

View File

@@ -25,8 +25,8 @@ class ListUserCommandTest extends KernelTestCase
{
$commandTester = $this->getCommandTester();
$output = $commandTester->getDisplay();
$this->assertStringContainsString('Username Email Roles Active Authenticator', $output);
$this->assertStringContainsString('---------- ------- ------- -------- -------------', $output);
self::assertStringContainsString('Username Email Roles Active Authenticator', $output);
self::assertStringContainsString('---------- ------- ------- -------- -------------', $output);
}
protected function getCommandTester(): CommandTester

View File

@@ -33,9 +33,9 @@ class PluginCommandTest extends KernelTestCase
$commandTester = $this->getCommandTester([$plugin1], []);
$output = $commandTester->getDisplay();
$this->assertStringContainsString(__DIR__, $output);
$this->assertStringContainsString('Plugin/Fixtures/TestPlugin', $output);
$this->assertStringContainsString('TestPlugin from composer.json', $output);
self::assertStringContainsString(__DIR__, $output);
self::assertStringContainsString('Plugin/Fixtures/TestPlugin', $output);
self::assertStringContainsString('TestPlugin from composer.json', $output);
}
private function getCommandTester(array $plugins, array $options = []): CommandTester

View File

@@ -36,7 +36,7 @@ class PromoteUserCommandTest extends KernelTestCase
$container = self::$kernel->getContainer();
$userService = $container->get(UserService::class);
$this->assertInstanceOf(UserService::class, $userService);
self::assertInstanceOf(UserService::class, $userService);
$this->application->add(new PromoteUserCommand($userService));
}
@@ -79,7 +79,7 @@ class PromoteUserCommandTest extends KernelTestCase
$commandTester = $this->callCommand('john_user', 'ROLE_TEAMLEAD');
$output = $commandTester->getDisplay();
$this->assertStringContainsString('[OK] Role "ROLE_TEAMLEAD" has been added to user "john_user".', $output);
self::assertStringContainsString('[OK] Role "ROLE_TEAMLEAD" has been added to user "john_user".', $output);
$container = self::$kernel->getContainer();
/** @var Registry $doctrine */
@@ -96,7 +96,7 @@ class PromoteUserCommandTest extends KernelTestCase
$commandTester = $this->callCommand('john_user', null, true);
$output = $commandTester->getDisplay();
$this->assertStringContainsString('[OK] User "john_user" has been promoted as a super administrator.', $output);
self::assertStringContainsString('[OK] User "john_user" has been promoted as a super administrator.', $output);
$container = self::$kernel->getContainer();
/** @var Registry $doctrine */
@@ -113,7 +113,7 @@ class PromoteUserCommandTest extends KernelTestCase
$commandTester = $this->callCommand('susan_super', null, true);
$output = $commandTester->getDisplay();
$this->assertStringContainsString('[WARNING] User "susan_super" does already have the super administrator role.', $output);
self::assertStringContainsString('[WARNING] User "susan_super" does already have the super administrator role.', $output);
}
public function testPromoteTeamleadFailsOnTeamlead(): void
@@ -121,7 +121,7 @@ class PromoteUserCommandTest extends KernelTestCase
$commandTester = $this->callCommand('tony_teamlead', 'ROLE_TEAMLEAD', false);
$output = $commandTester->getDisplay();
$this->assertStringContainsString('[WARNING] User "tony_teamlead" did already have "ROLE_TEAMLEAD" role.', $output);
self::assertStringContainsString('[WARNING] User "tony_teamlead" did already have "ROLE_TEAMLEAD" role.', $output);
}
public function testPromoteRoleAndSuperFails(): void

View File

@@ -39,10 +39,10 @@ class VersionCommandTest extends KernelTestCase
{
$commandTester = $this->getCommandTester($options);
$output = $commandTester->getDisplay();
$this->assertEquals($result . PHP_EOL, $output);
self::assertEquals($result . PHP_EOL, $output);
}
public function getTestData(): array // @phpstan-ignore missingType.iterableValue
public static function getTestData(): array // @phpstan-ignore missingType.iterableValue
{
return [
[[], 'Kimai ' . Constants::VERSION . ' by Kevin Papst.'],