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

@@ -9,12 +9,12 @@
namespace App\Tests\Controller\Security;
use App\Tests\Controller\ControllerBaseTest;
use App\Tests\Controller\AbstractControllerBaseTestCase;
/**
* @group integration
*/
class PasswordResetControllerTest extends ControllerBaseTest
class PasswordResetControllerTest extends AbstractControllerBaseTestCase
{
private function testResetActionWithDeactivatedFeature(string $route, string $method = 'GET'): void
{
@@ -47,16 +47,16 @@ class PasswordResetControllerTest extends ControllerBaseTest
$this->request($client, '/resetting/request');
$response = $client->getResponse();
$this->assertTrue($response->isSuccessful());
self::assertTrue($response->isSuccessful());
$content = $response->getContent();
$this->assertNotFalse($content);
$this->assertStringContainsString('<title>Kimai Time Tracking</title>', $content);
$this->assertStringContainsString('Reset your password', $content);
$this->assertStringContainsString('<form class="card-body security-password-reset" action="/en/resetting/send-email" method="post" autocomplete="off">', $content);
$this->assertStringContainsString('<input autocomplete="username" type="text"', $content);
$this->assertStringContainsString('id="username" name="username" required="required"', $content);
$this->assertStringContainsString('Reset your password', $content);
self::assertNotFalse($content);
self::assertStringContainsString('<title>Kimai Time Tracking</title>', $content);
self::assertStringContainsString('Reset your password', $content);
self::assertStringContainsString('<form class="card-body security-password-reset" action="/en/resetting/send-email" method="post" autocomplete="off">', $content);
self::assertStringContainsString('<input autocomplete="username" type="text"', $content);
self::assertStringContainsString('id="username" name="username" required="required"', $content);
self::assertStringContainsString('Reset your password', $content);
$form = $client->getCrawler()->filter('form')->form();
$client->submit($form, [
@@ -65,12 +65,12 @@ class PasswordResetControllerTest extends ControllerBaseTest
$this->assertIsRedirect($client, $this->createUrl('/resetting/check-email'));
$client->followRedirect();
$this->assertTrue($client->getResponse()->isSuccessful());
self::assertTrue($client->getResponse()->isSuccessful());
// TODO test the actual email and provided login link
$user = $this->loadUserFromDatabase('john_user');
$this->assertTrue($user->requiresPasswordReset());
self::assertTrue($user->requiresPasswordReset());
}
public function testRequestAsLoggedInUserRedirects(): void
@@ -93,11 +93,11 @@ class PasswordResetControllerTest extends ControllerBaseTest
$this->request($client, '/resetting/send-email', 'POST');
$this->assertIsRedirect($client, $this->createUrl('/resetting/check-email'));
$client->followRedirect();
$this->assertTrue($client->getResponse()->isSuccessful());
self::assertTrue($client->getResponse()->isSuccessful());
$content = $client->getResponse()->getContent();
$this->assertNotFalse($content);
$this->assertStringContainsString('An email has been sent with a link to reset your password.', $content);
$this->assertStringContainsString('Note: You can only request a new password once every 1:00 hours.', $content);
self::assertNotFalse($content);
self::assertStringContainsString('An email has been sent with a link to reset your password.', $content);
self::assertStringContainsString('Note: You can only request a new password once every 1:00 hours.', $content);
}
public function testResetWithEmptyUsername(): void
@@ -106,11 +106,11 @@ class PasswordResetControllerTest extends ControllerBaseTest
$this->request($client, '/resetting/send-email', 'POST', ['username' => '']);
$this->assertIsRedirect($client, $this->createUrl('/resetting/check-email'));
$client->followRedirect();
$this->assertTrue($client->getResponse()->isSuccessful());
self::assertTrue($client->getResponse()->isSuccessful());
$content = $client->getResponse()->getContent();
$this->assertNotFalse($content);
$this->assertStringContainsString('An email has been sent with a link to reset your password.', $content);
$this->assertStringContainsString('Note: You can only request a new password once every 1:00 hours.', $content);
self::assertNotFalse($content);
self::assertStringContainsString('An email has been sent with a link to reset your password.', $content);
self::assertStringContainsString('Note: You can only request a new password once every 1:00 hours.', $content);
}
public function testResetWithUnknownUsername(): void
@@ -119,11 +119,11 @@ class PasswordResetControllerTest extends ControllerBaseTest
$this->request($client, '/resetting/send-email', 'POST', ['username' => 'foobar']);
$this->assertIsRedirect($client, $this->createUrl('/resetting/check-email'));
$client->followRedirect();
$this->assertTrue($client->getResponse()->isSuccessful());
self::assertTrue($client->getResponse()->isSuccessful());
$content = $client->getResponse()->getContent();
$this->assertNotFalse($content);
$this->assertStringContainsString('An email has been sent with a link to reset your password.', $content);
$this->assertStringContainsString('Note: You can only request a new password once every 1:00 hours.', $content);
self::assertNotFalse($content);
self::assertStringContainsString('An email has been sent with a link to reset your password.', $content);
self::assertStringContainsString('Note: You can only request a new password once every 1:00 hours.', $content);
}
public function testResetWithKnownUsername(): void
@@ -131,10 +131,10 @@ class PasswordResetControllerTest extends ControllerBaseTest
$client = self::createClient();
$user = $this->loadUserFromDatabase('john_user');
$this->assertFalse($user->requiresPasswordReset());
self::assertFalse($user->requiresPasswordReset());
$this->request($client, '/resetting/request');
$this->assertTrue($client->getResponse()->isSuccessful());
self::assertTrue($client->getResponse()->isSuccessful());
$form = $client->getCrawler()->filter('form')->form();
$client->submit($form, [
'username' => 'john_user',
@@ -142,15 +142,15 @@ class PasswordResetControllerTest extends ControllerBaseTest
$this->assertIsRedirect($client, $this->createUrl('/resetting/check-email'));
$client->followRedirect();
$this->assertTrue($client->getResponse()->isSuccessful());
self::assertTrue($client->getResponse()->isSuccessful());
$content = $client->getResponse()->getContent();
$this->assertNotFalse($content);
$this->assertStringContainsString('An email has been sent with a link to reset your password.', $content);
$this->assertStringContainsString('Note: You can only request a new password once every 1:00 hours.', $content);
self::assertNotFalse($content);
self::assertStringContainsString('An email has been sent with a link to reset your password.', $content);
self::assertStringContainsString('Note: You can only request a new password once every 1:00 hours.', $content);
// TODO test the actual email and provided login link
$user = $this->loadUserFromDatabase('john_user');
$this->assertTrue($user->requiresPasswordReset());
self::assertTrue($user->requiresPasswordReset());
}
}