upgraded to phpunit 8 (#1155)

This commit is contained in:
Kevin Papst
2019-10-24 17:35:05 +02:00
committed by GitHub
parent e91e4ff430
commit b0f83291ee
81 changed files with 421 additions and 463 deletions

View File

@@ -26,6 +26,6 @@ class AboutControllerTest extends ControllerBaseTest
$result = $client->getCrawler()->filter('div.box-body pre');
$this->assertEquals(1, count($result));
$this->assertContains('MIT License', $result->text());
$this->assertStringContainsString('MIT License', $result->text());
}
}

View File

@@ -48,10 +48,10 @@ class CalendarControllerTest extends ControllerBaseTest
$this->assertEquals(1, $calendar->count());
$content = $client->getResponse()->getContent();
$this->assertContains("googleCalendarId: 'de.german#holiday@group.v.calendar.google.com',", $content);
$this->assertContains("name: 'holidays'", $content);
$this->assertContains("googleCalendarId: 'en.german#holiday@group.v.calendar.google.com',", $content);
$this->assertContains("name: 'holidays_en'", $content);
$this->assertStringContainsString("googleCalendarId: 'de.german#holiday@group.v.calendar.google.com',", $content);
$this->assertStringContainsString("name: 'holidays'", $content);
$this->assertStringContainsString("googleCalendarId: 'en.german#holiday@group.v.calendar.google.com',", $content);
$this->assertStringContainsString("name: 'holidays_en'", $content);
}
protected function getDefaultSettings()

View File

@@ -147,7 +147,7 @@ abstract class ControllerBaseTest extends WebTestCase
$client->getResponse()->isSuccessful(),
'Access is not denied for URL: ' . $client->getRequest()->getUri()
);
self::assertContains(
self::assertStringContainsString(
'Symfony\Component\Security\Core\Exception\AccessDeniedException',
$client->getResponse()->getContent(),
'Could not find AccessDeniedException in response'
@@ -168,7 +168,7 @@ abstract class ControllerBaseTest extends WebTestCase
protected function assertMainContentClass(Client $client, string $classname)
{
self::assertContains('<section class="content ' . $classname . '">', $client->getResponse()->getContent());
self::assertStringContainsString('<section class="content ' . $classname . '">', $client->getResponse()->getContent());
}
/**
@@ -176,7 +176,7 @@ abstract class ControllerBaseTest extends WebTestCase
*/
protected function assertHasDataTable(Client $client)
{
self::assertContains('<table class="table table-striped table-hover dataTable" role="grid" data-reload-event="', $client->getResponse()->getContent());
self::assertStringContainsString('<table class="table table-striped table-hover dataTable" role="grid" data-reload-event="', $client->getResponse()->getContent());
}
/**
@@ -185,9 +185,9 @@ abstract class ControllerBaseTest extends WebTestCase
protected static function assertHasProgressbar(Client $client)
{
$content = $client->getResponse()->getContent();
self::assertContains('<div class="progress-bar progress-bar-', $content);
self::assertContains('" role="progressbar" aria-valuenow="', $content);
self::assertContains('" aria-valuemin="0" aria-valuemax="100" style="width: ', $content);
self::assertStringContainsString('<div class="progress-bar progress-bar-', $content);
self::assertStringContainsString('" role="progressbar" aria-valuenow="', $content);
self::assertStringContainsString('" aria-valuemin="0" aria-valuemax="100" style="width: ', $content);
}
/**
@@ -259,7 +259,7 @@ abstract class ControllerBaseTest extends WebTestCase
/** @var \DOMElement $listMsg */
$listMsg = $field->parents()->getNode(1);
$classes = $listMsg->getAttribute('class');
self::assertContains('has-error', $classes, 'Form field has no validation message: ' . $name);
self::assertStringContainsString('has-error', $classes, 'Form field has no validation message: ' . $name);
}
}
}
@@ -279,7 +279,7 @@ abstract class ControllerBaseTest extends WebTestCase
protected function assertCalloutWidgetWithMessage(Client $client, string $message)
{
$node = $client->getCrawler()->filter('div.callout.callout-warning.lead');
self::assertContains($message, $node->text());
self::assertStringContainsString($message, $node->text());
}
protected function assertHasFlashDeleteSuccess(Client $client)
@@ -301,7 +301,7 @@ abstract class ControllerBaseTest extends WebTestCase
$node = $client->getCrawler()->filter('div.alert.alert-success.alert-dismissible');
self::assertNotEmpty($node->text());
if (null !== $message) {
self::assertContains($message, $node->text());
self::assertStringContainsString($message, $node->text());
}
}
@@ -314,7 +314,7 @@ abstract class ControllerBaseTest extends WebTestCase
$node = $client->getCrawler()->filter('div.alert.alert-error.alert-dismissible');
self::assertNotEmpty($node->text());
if (null !== $message) {
self::assertContains($message, $node->text());
self::assertStringContainsString($message, $node->text());
}
}

View File

@@ -66,9 +66,9 @@ class DashboardControllerTest extends ControllerBaseTest
$content = $client->getResponse()->getContent();
$this->assertContains('<li class="dropdown user-menu">', $content);
$this->assertContains('<a href="/en/profile/' . $user->getUsername() . '">', $content);
$this->assertContains('<a href="/en/profile/' . $user->getUsername() . '/prefs">', $content);
$this->assertContains('<a href="/en/logout">', $content);
$this->assertStringContainsString('<li class="dropdown user-menu">', $content);
$this->assertStringContainsString('<a href="/en/profile/' . $user->getUsername() . '">', $content);
$this->assertStringContainsString('<a href="/en/profile/' . $user->getUsername() . '/prefs">', $content);
$this->assertStringContainsString('<a href="/en/logout">', $content);
}
}

View File

@@ -75,7 +75,7 @@ class ExportControllerTest extends ControllerBaseTest
$response = $client->getResponse();
$this->assertFalse($response->isSuccessful());
$this->assertEquals(404, $response->getStatusCode());
$this->assertContains('Missing export renderer', $response->getContent());
$this->assertStringContainsString('Missing export renderer', $response->getContent());
}
public function testExportActionWithInvalidRenderer()
@@ -97,7 +97,7 @@ class ExportControllerTest extends ControllerBaseTest
$response = $client->getResponse();
$this->assertFalse($response->isSuccessful());
$this->assertEquals(404, $response->getStatusCode());
$this->assertContains('Unknown export renderer', $response->getContent());
$this->assertStringContainsString('Unknown export renderer', $response->getContent());
}
public function testExportAction()
@@ -135,9 +135,9 @@ class ExportControllerTest extends ControllerBaseTest
$this->assertEquals(1, $node->count());
// poor mans assertions ;-)
$this->assertContains('export_print', $node->getIterator()[0]->getAttribute('class'));
$this->assertContains('<h2>List of expenses</h2>', $response->getContent());
$this->assertContains('<h3>Summary</h3>', $response->getContent());
$this->assertStringContainsString('export_print', $node->getIterator()[0]->getAttribute('class'));
$this->assertStringContainsString('<h2>List of expenses</h2>', $response->getContent());
$this->assertStringContainsString('<h3>Summary</h3>', $response->getContent());
$node = $client->getCrawler()->filter('section.export div#export-records table.dataTable tbody tr');
// 20 rows + the summary footer

View File

@@ -64,8 +64,8 @@ class ProfileControllerTest extends ControllerBaseTest
foreach ($dates as $start) {
$year = $start->format('Y');
$this->assertContains('<h3 class="box-title">' . $year . '</h3>', $content);
$this->assertContains('var userProfileChart' . $year . ' = new Chart(', $content);
$this->assertStringContainsString('<h3 class="box-title">' . $year . '</h3>', $content);
$this->assertStringContainsString('var userProfileChart' . $year . ' = new Chart(', $content);
}
$this->assertHasProfileBox($client, 'John Doe');
@@ -87,8 +87,8 @@ class ProfileControllerTest extends ControllerBaseTest
{
$content = $client->getResponse()->getContent();
$this->assertContains('<h3 class="box-title">About me</h3>', $content);
$this->assertContains('<span class="pull-right badge bg-blue">' . $username . '</span>', $content);
$this->assertStringContainsString('<h3 class="box-title">About me</h3>', $content);
$this->assertStringContainsString('<span class="pull-right badge bg-blue">' . $username . '</span>', $content);
}
public function getTabTestData()

View File

@@ -36,15 +36,15 @@ class SecurityControllerTest extends ControllerBaseTest
$this->assertTrue($client->getResponse()->isSuccessful());
$content = $response->getContent();
$this->assertContains('<title>Kimai – Time Tracking</title>', $content);
$this->assertContains('<form action="/en/login_check" method="post">', $content);
$this->assertContains('<input type="text" name="_username"', $content);
$this->assertContains('<input name="_password" type="password"', $content);
$this->assertContains('<input id="remember_me" name="_remember_me" type="checkbox"', $content);
$this->assertContains('">Login</button>', $content);
$this->assertContains('<input type="hidden" name="_csrf_token" value="', $content);
$this->assertContains('<a href="/en/register/"', $content);
$this->assertContains('Register a new account', $content);
$this->assertStringContainsString('<title>Kimai – Time Tracking</title>', $content);
$this->assertStringContainsString('<form action="/en/login_check" method="post">', $content);
$this->assertStringContainsString('<input type="text" name="_username"', $content);
$this->assertStringContainsString('<input name="_password" type="password"', $content);
$this->assertStringContainsString('<input id="remember_me" name="_remember_me" type="checkbox"', $content);
$this->assertStringContainsString('">Login</button>', $content);
$this->assertStringContainsString('<input type="hidden" name="_csrf_token" value="', $content);
$this->assertStringContainsString('<a href="/en/register/"', $content);
$this->assertStringContainsString('Register a new account', $content);
}
public function testRegisterAccountPageIsRendered()
@@ -56,19 +56,19 @@ class SecurityControllerTest extends ControllerBaseTest
$this->assertTrue($response->isSuccessful());
$content = $response->getContent();
$this->assertContains('<title>Kimai – Time Tracking</title>', $content);
$this->assertContains('Register a new account', $content);
$this->assertContains('<form name="fos_user_registration_form" method="post" action="/en/register/" class="fos_user_registration_register">', $content);
$this->assertContains('<input type="email"', $content);
$this->assertContains('id="fos_user_registration_form_email" name="fos_user_registration_form[email]" required="required"', $content);
$this->assertContains('<input type="text"', $content);
$this->assertContains('id="fos_user_registration_form_username" name="fos_user_registration_form[username]" required="required" maxlength="60" pattern=".{3,}"', $content);
$this->assertContains('<input type="password"', $content);
$this->assertContains('id="fos_user_registration_form_plainPassword_first" name="fos_user_registration_form[plainPassword][first]" required="required"', $content);
$this->assertContains('id="fos_user_registration_form_plainPassword_second" name="fos_user_registration_form[plainPassword][second]" required="required"', $content);
$this->assertContains('<input type="hidden"', $content);
$this->assertContains('id="fos_user_registration_form__token" name="fos_user_registration_form[_token]"', $content);
$this->assertContains('>Register</button>', $content);
$this->assertStringContainsString('<title>Kimai – Time Tracking</title>', $content);
$this->assertStringContainsString('Register a new account', $content);
$this->assertStringContainsString('<form name="fos_user_registration_form" method="post" action="/en/register/" class="fos_user_registration_register">', $content);
$this->assertStringContainsString('<input type="email"', $content);
$this->assertStringContainsString('id="fos_user_registration_form_email" name="fos_user_registration_form[email]" required="required"', $content);
$this->assertStringContainsString('<input type="text"', $content);
$this->assertStringContainsString('id="fos_user_registration_form_username" name="fos_user_registration_form[username]" required="required" maxlength="60" pattern=".{3,}"', $content);
$this->assertStringContainsString('<input type="password"', $content);
$this->assertStringContainsString('id="fos_user_registration_form_plainPassword_first" name="fos_user_registration_form[plainPassword][first]" required="required"', $content);
$this->assertStringContainsString('id="fos_user_registration_form_plainPassword_second" name="fos_user_registration_form[plainPassword][second]" required="required"', $content);
$this->assertStringContainsString('<input type="hidden"', $content);
$this->assertStringContainsString('id="fos_user_registration_form__token" name="fos_user_registration_form[_token]"', $content);
$this->assertStringContainsString('>Register</button>', $content);
}
public function testRegisterAccount()
@@ -96,8 +96,8 @@ class SecurityControllerTest extends ControllerBaseTest
$this->assertTrue($client->getResponse()->isSuccessful());
$content = $client->getResponse()->getContent();
$this->assertContains('<title>Kimai – Time Tracking</title>', $content);
$this->assertContains('<p>Congrats example, your account is now activated.</p>', $content);
$this->assertContains('<a href="/en/homepage">', $content);
$this->assertStringContainsString('<title>Kimai – Time Tracking</title>', $content);
$this->assertStringContainsString('<p>Congrats example, your account is now activated.</p>', $content);
$this->assertStringContainsString('<a href="/en/homepage">', $content);
}
}

View File

@@ -17,7 +17,7 @@ use App\Tests\DataFixtures\TagFixtures;
*/
class TagControllerTest extends ControllerBaseTest
{
public function setUp()
protected function setUp(): void
{
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);
$em = $client->getContainer()->get('doctrine.orm.entity_manager');

View File

@@ -297,7 +297,7 @@ class TimesheetControllerTest extends ControllerBaseTest
$response = $client->getResponse();
$this->assertTrue($response->isSuccessful());
$this->assertContains(
$this->assertStringContainsString(
'href="https://www.kimai.org/documentation/timesheet.html"',
$response->getContent(),
'Could not find link to documentation'

View File

@@ -211,7 +211,7 @@ class TimesheetTeamControllerTest extends ControllerBaseTest
$response = $client->getResponse();
$this->assertTrue($response->isSuccessful());
$this->assertContains(
$this->assertStringContainsString(
'href="https://www.kimai.org/documentation/timesheet.html"',
$response->getContent(),
'Could not find link to documentation'