Release 2.20.0 (#4987)
This commit is contained in:
@@ -39,7 +39,7 @@ abstract class APIControllerBaseTest extends ControllerBaseTest
|
||||
User::ROLE_ADMIN => self::createClient([], $this->getAuthHeader(UserFixtures::USERNAME_ADMIN, UserFixtures::DEFAULT_API_TOKEN . '_admin')),
|
||||
User::ROLE_TEAMLEAD => self::createClient([], $this->getAuthHeader(UserFixtures::USERNAME_TEAMLEAD, UserFixtures::DEFAULT_API_TOKEN . '_teamlead')),
|
||||
User::ROLE_USER => self::createClient([], $this->getAuthHeader(UserFixtures::USERNAME_USER, UserFixtures::DEFAULT_API_TOKEN . '_user')),
|
||||
default => throw new \Exception(sprintf('Unknown role "%s"', $role)),
|
||||
default => throw new \Exception(\sprintf('Unknown role "%s"', $role)),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -74,13 +74,13 @@ abstract class APIControllerBaseTest extends ControllerBaseTest
|
||||
self::assertEquals(
|
||||
$data,
|
||||
json_decode($response->getContent(), true),
|
||||
sprintf('The secure URL %s is not protected.', $url)
|
||||
\sprintf('The secure URL %s is not protected.', $url)
|
||||
);
|
||||
|
||||
self::assertEquals(
|
||||
Response::HTTP_UNAUTHORIZED,
|
||||
$response->getStatusCode(),
|
||||
sprintf('The secure URL %s has the wrong status code %s.', $url, $response->getStatusCode())
|
||||
\sprintf('The secure URL %s has the wrong status code %s.', $url, $response->getStatusCode())
|
||||
);
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ abstract class APIControllerBaseTest extends ControllerBaseTest
|
||||
|
||||
self::assertFalse(
|
||||
$client->getResponse()->isSuccessful(),
|
||||
sprintf('The secure URL %s is not protected for role %s', $url, $role)
|
||||
\sprintf('The secure URL %s is not protected for role %s', $url, $role)
|
||||
);
|
||||
|
||||
$this->assertApiException($client->getResponse(), [
|
||||
@@ -248,7 +248,7 @@ abstract class APIControllerBaseTest extends ControllerBaseTest
|
||||
while (stripos($fieldName, '.') !== false) {
|
||||
$parts = explode('.', $fieldName);
|
||||
$tmp = array_shift($parts);
|
||||
self::assertArrayHasKey($tmp, $data, sprintf('Could not find field "%s" in result', $tmp));
|
||||
self::assertArrayHasKey($tmp, $data, \sprintf('Could not find field "%s" in result', $tmp));
|
||||
$data = $data[$tmp];
|
||||
if (\count($data) === 1 && \array_key_exists('children', $data)) {
|
||||
$data = $data['children'];
|
||||
@@ -256,8 +256,8 @@ abstract class APIControllerBaseTest extends ControllerBaseTest
|
||||
$fieldName = implode('.', $parts);
|
||||
}
|
||||
|
||||
self::assertArrayHasKey($fieldName, $data, sprintf('Could not find validation error for field "%s" in list: %s', $fieldName, implode(', ', $failedFields)));
|
||||
self::assertArrayHasKey('errors', $data[$fieldName], sprintf('Field %s has no validation problem', $fieldName));
|
||||
self::assertArrayHasKey($fieldName, $data, \sprintf('Could not find validation error for field "%s" in list: %s', $fieldName, implode(', ', $failedFields)));
|
||||
self::assertArrayHasKey('errors', $data[$fieldName], \sprintf('Field %s has no validation problem', $fieldName));
|
||||
foreach ($messages as $i => $message) {
|
||||
self::assertEquals($message, $data[$fieldName]['errors'][$i]);
|
||||
}
|
||||
@@ -648,7 +648,7 @@ abstract class APIControllerBaseTest extends ControllerBaseTest
|
||||
];
|
||||
|
||||
default:
|
||||
throw new \Exception(sprintf('Unknown API response type: %s', $type));
|
||||
throw new \Exception(\sprintf('Unknown API response type: %s', $type));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -668,12 +668,12 @@ abstract class APIControllerBaseTest extends ControllerBaseTest
|
||||
sort($actual);
|
||||
sort($expectedKeys);
|
||||
|
||||
self::assertEquals($expectedKeys, $actual, sprintf('Structure for API response type "%s" does not match', $type));
|
||||
self::assertEquals($expectedKeys, $actual, \sprintf('Structure for API response type "%s" does not match', $type));
|
||||
|
||||
self::assertEquals(
|
||||
\count($actual),
|
||||
\count($expectedKeys),
|
||||
sprintf('Mismatch between expected and result keys for API response type "%s". Expected %s keys but found %s.', $type, \count($expected), \count($actual))
|
||||
\sprintf('Mismatch between expected and result keys for API response type "%s". Expected %s keys but found %s.', $type, \count($expected), \count($actual))
|
||||
);
|
||||
|
||||
foreach ($expected as $key => $value) {
|
||||
@@ -706,13 +706,13 @@ abstract class APIControllerBaseTest extends ControllerBaseTest
|
||||
$value['type'] = substr($value['type'], 1);
|
||||
}
|
||||
|
||||
self::assertIsArray($result[$key], sprintf('Key "%s" in type "%s" is not an array', $key, $type));
|
||||
self::assertIsArray($result[$key], \sprintf('Key "%s" in type "%s" is not an array', $key, $type));
|
||||
|
||||
self::assertApiResponseTypeStructure($value['type'], $result[$key]);
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new \Exception(sprintf('Invalid result type "%s" for subresource given', $value['result']));
|
||||
throw new \Exception(\sprintf('Invalid result type "%s" for subresource given', $value['result']));
|
||||
}
|
||||
|
||||
continue;
|
||||
@@ -727,18 +727,18 @@ abstract class APIControllerBaseTest extends ControllerBaseTest
|
||||
|
||||
if (strtolower($value) === 'datetime') {
|
||||
$date = \DateTime::createFromFormat('Y-m-d\TH:i:sO', $result[$key]);
|
||||
self::assertInstanceOf(\DateTime::class, $date, sprintf('Field "%s" was expected to be a Date with the format "Y-m-dTH:i:sO", but found: %s', $key, $result[$key]));
|
||||
self::assertInstanceOf(\DateTime::class, $date, \sprintf('Field "%s" was expected to be a Date with the format "Y-m-dTH:i:sO", but found: %s', $key, $result[$key]));
|
||||
$value = 'string';
|
||||
} elseif (strtolower($value) === 'date') {
|
||||
$date = \DateTime::createFromFormat('Y-m-d', $result[$key]);
|
||||
self::assertInstanceOf(\DateTime::class, $date, sprintf('Field "%s" was expected to be a Date with the format "Y-m-d", but found: %s', $key, $result[$key]));
|
||||
self::assertInstanceOf(\DateTime::class, $date, \sprintf('Field "%s" was expected to be a Date with the format "Y-m-d", but found: %s', $key, $result[$key]));
|
||||
$value = 'string';
|
||||
}
|
||||
|
||||
static::assertThat(
|
||||
$result[$key],
|
||||
new IsType($value),
|
||||
sprintf('Found type mismatch in structure for API response type %s. Expected type "%s" for key "%s".', $type, $value, $key)
|
||||
\sprintf('Found type mismatch in structure for API response type %s. Expected type "%s" for key "%s".', $type, $value, $key)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ class ActionsControllerTest extends APIControllerBaseTest
|
||||
];
|
||||
|
||||
foreach ($views as $view => $entries) {
|
||||
$this->assertAccessIsGranted($client, sprintf('/api/actions/timesheet/%s/%s/en', $items[0]->getId(), $view));
|
||||
$this->assertAccessIsGranted($client, \sprintf('/api/actions/timesheet/%s/%s/en', $items[0]->getId(), $view));
|
||||
$result = json_decode($client->getResponse()->getContent(), true);
|
||||
|
||||
$this->assertIsArray($result);
|
||||
@@ -65,7 +65,7 @@ class ActionsControllerTest extends APIControllerBaseTest
|
||||
|
||||
$i = 0;
|
||||
foreach ($entries as $id) {
|
||||
self::assertEquals($id, $result[$i]['id'], sprintf('Failed action "%s" with name "%s" in view "%s"', $i, $id, $view));
|
||||
self::assertEquals($id, $result[$i]['id'], \sprintf('Failed action "%s" with name "%s" in view "%s"', $i, $id, $view));
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
@@ -105,7 +105,7 @@ class ActionsControllerTest extends APIControllerBaseTest
|
||||
];
|
||||
|
||||
foreach ($views as $view => $entries) {
|
||||
$this->assertAccessIsGranted($client, sprintf('/api/actions/activity/%s/%s/en', $activities[0]->getId(), $view));
|
||||
$this->assertAccessIsGranted($client, \sprintf('/api/actions/activity/%s/%s/en', $activities[0]->getId(), $view));
|
||||
$result = json_decode($client->getResponse()->getContent(), true);
|
||||
|
||||
$this->assertIsArray($result);
|
||||
@@ -115,7 +115,7 @@ class ActionsControllerTest extends APIControllerBaseTest
|
||||
|
||||
$i = 0;
|
||||
foreach ($entries as $id) {
|
||||
self::assertEquals($id, $result[$i]['id'], sprintf('Failed action "%s" with name "%s" in view "%s"', $i, $id, $view));
|
||||
self::assertEquals($id, $result[$i]['id'], \sprintf('Failed action "%s" with name "%s" in view "%s"', $i, $id, $view));
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
@@ -154,7 +154,7 @@ class ActionsControllerTest extends APIControllerBaseTest
|
||||
];
|
||||
|
||||
foreach ($views as $view => $entries) {
|
||||
$this->assertAccessIsGranted($client, sprintf('/api/actions/project/%s/%s/en', $projects[0]->getId(), $view));
|
||||
$this->assertAccessIsGranted($client, \sprintf('/api/actions/project/%s/%s/en', $projects[0]->getId(), $view));
|
||||
$result = json_decode($client->getResponse()->getContent(), true);
|
||||
|
||||
$this->assertIsArray($result);
|
||||
@@ -164,7 +164,7 @@ class ActionsControllerTest extends APIControllerBaseTest
|
||||
|
||||
$i = 0;
|
||||
foreach ($entries as $id) {
|
||||
self::assertEquals($id, $result[$i]['id'], sprintf('Failed action "%s" with name "%s" in view "%s"', $i, $id, $view));
|
||||
self::assertEquals($id, $result[$i]['id'], \sprintf('Failed action "%s" with name "%s" in view "%s"', $i, $id, $view));
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
@@ -199,7 +199,7 @@ class ActionsControllerTest extends APIControllerBaseTest
|
||||
];
|
||||
|
||||
foreach ($views as $view => $entries) {
|
||||
$this->assertAccessIsGranted($client, sprintf('/api/actions/customer/%s/%s/en', $customers[0]->getId(), $view));
|
||||
$this->assertAccessIsGranted($client, \sprintf('/api/actions/customer/%s/%s/en', $customers[0]->getId(), $view));
|
||||
$result = json_decode($client->getResponse()->getContent(), true);
|
||||
|
||||
$this->assertIsArray($result);
|
||||
@@ -209,7 +209,7 @@ class ActionsControllerTest extends APIControllerBaseTest
|
||||
|
||||
$i = 0;
|
||||
foreach ($entries as $id) {
|
||||
self::assertEquals($id, $result[$i]['id'], sprintf('Failed action "%s" with name "%s" in view "%s"', $i, $id, $view));
|
||||
self::assertEquals($id, $result[$i]['id'], \sprintf('Failed action "%s" with name "%s" in view "%s"', $i, $id, $view));
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,10 +46,10 @@ class ActivityControllerTest extends APIControllerBaseTest
|
||||
protected function getRateUrl($id = '1', $rateId = null): string
|
||||
{
|
||||
if (null !== $rateId) {
|
||||
return sprintf('/api/activities/%s/rates/%s', $id, $rateId);
|
||||
return \sprintf('/api/activities/%s/rates/%s', $id, $rateId);
|
||||
}
|
||||
|
||||
return sprintf('/api/activities/%s/rates', $id);
|
||||
return \sprintf('/api/activities/%s/rates', $id);
|
||||
}
|
||||
|
||||
protected function importTestRates($id): array
|
||||
|
||||
@@ -26,7 +26,7 @@ class ApiDocControllerTest extends ControllerBaseTest
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);
|
||||
$this->assertAccessIsGranted($client, '/api/doc');
|
||||
$this->assertStringContainsString('<title>Kimai - API Docs</title>', $client->getResponse()->getContent());
|
||||
$this->assertStringContainsString('<title>Kimai', $client->getResponse()->getContent());
|
||||
$result = $client->getCrawler()->filter('script#swagger-data');
|
||||
$swaggerJson = json_decode($result->text(), true);
|
||||
$tags = [];
|
||||
@@ -44,7 +44,7 @@ class ApiDocControllerTest extends ControllerBaseTest
|
||||
sort($actual);
|
||||
sort($expectedKeys);
|
||||
|
||||
self::assertEquals($expectedKeys, $actual, sprintf('Expected %s sections in API docs, but found %s.', \count($actual), \count($expectedKeys)));
|
||||
self::assertEquals($expectedKeys, $actual, \sprintf('Expected %s sections in API docs, but found %s.', \count($actual), \count($expectedKeys)));
|
||||
}
|
||||
|
||||
public function testGetJsonDocs(): void
|
||||
@@ -105,7 +105,7 @@ class ApiDocControllerTest extends ControllerBaseTest
|
||||
$this->assertArrayHasKey('openapi', $json);
|
||||
$this->assertEquals('3.0.0', $json['openapi']);
|
||||
$this->assertArrayHasKey('info', $json);
|
||||
$this->assertEquals('Kimai - API Docs', $json['info']['title']);
|
||||
$this->assertStringStartsWith('Kimai', $json['info']['title']);
|
||||
$this->assertEquals('1.0', $json['info']['version']);
|
||||
|
||||
$this->assertArrayHasKey('paths', $json);
|
||||
|
||||
@@ -70,13 +70,13 @@ class AuthenticationTest extends APIControllerBaseTest
|
||||
$this->assertEquals(
|
||||
$data,
|
||||
json_decode($response->getContent(), true),
|
||||
sprintf('The secure URL %s is not protected.', $url)
|
||||
\sprintf('The secure URL %s is not protected.', $url)
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
Response::HTTP_FORBIDDEN,
|
||||
$response->getStatusCode(),
|
||||
sprintf('The secure URL %s has the wrong status code %s.', $url, $response->getStatusCode())
|
||||
\sprintf('The secure URL %s has the wrong status code %s.', $url, $response->getStatusCode())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -46,10 +46,10 @@ class CustomerControllerTest extends APIControllerBaseTest
|
||||
protected function getRateUrl($id = '1', $rateId = null): string
|
||||
{
|
||||
if (null !== $rateId) {
|
||||
return sprintf('/api/customers/%s/rates/%s', $id, $rateId);
|
||||
return \sprintf('/api/customers/%s/rates/%s', $id, $rateId);
|
||||
}
|
||||
|
||||
return sprintf('/api/customers/%s/rates', $id);
|
||||
return \sprintf('/api/customers/%s/rates', $id);
|
||||
}
|
||||
|
||||
protected function importTestRates($id): array
|
||||
|
||||
@@ -47,10 +47,10 @@ class ProjectControllerTest extends APIControllerBaseTest
|
||||
protected function getRateUrl($id = '1', $rateId = null): string
|
||||
{
|
||||
if (null !== $rateId) {
|
||||
return sprintf('/api/projects/%s/rates/%s', $id, $rateId);
|
||||
return \sprintf('/api/projects/%s/rates/%s', $id, $rateId);
|
||||
}
|
||||
|
||||
return sprintf('/api/projects/%s/rates', $id);
|
||||
return \sprintf('/api/projects/%s/rates', $id);
|
||||
}
|
||||
|
||||
protected function importTestRates($id): array
|
||||
|
||||
@@ -419,7 +419,7 @@ class TimesheetControllerTest extends APIControllerBaseTest
|
||||
];
|
||||
|
||||
foreach ($expected as $key => $value) {
|
||||
self::assertEquals($value, $result[$key], sprintf('Field %s has invalid value', $key));
|
||||
self::assertEquals($value, $result[$key], \sprintf('Field %s has invalid value', $key));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -162,12 +162,12 @@ class ExportCreateCommandTest extends KernelTestCase
|
||||
|
||||
public function testCreateWithInvalidEmail(): void
|
||||
{
|
||||
$this->assertCommandErrors(['--template' => 'csv', '--email' => ['tzuikmnbgtz']], 'Invalid "email" given: tzuikmnbgtz');
|
||||
$this->assertCommandErrors(['--template' => 'csv', '--email' => ['tzuikmnbgtz']], 'Invalid "email" given');
|
||||
}
|
||||
|
||||
public function testCreateWithInvalidEmails(): void
|
||||
{
|
||||
$this->assertCommandErrors(['--template' => 'csv', '--email' => ['foo@example.com', 'foo@1']], 'Invalid "email" given: foo@1');
|
||||
$this->assertCommandErrors(['--template' => 'csv', '--email' => ['foo@example.com', 'foo@1']], 'Invalid "email" given');
|
||||
}
|
||||
|
||||
public function testCreateWithMissingEntries(): void
|
||||
|
||||
@@ -54,7 +54,7 @@ class UpdateCommandTest extends KernelTestCase
|
||||
self::assertStringContainsString('[OK] Already at the latest version ("DoctrineMigrations\\', $result);
|
||||
|
||||
self::assertStringContainsString(
|
||||
sprintf('[OK] Congratulations! Successfully updated Kimai to version %s', Constants::VERSION),
|
||||
\sprintf('[OK] Congratulations! Successfully updated Kimai to version %s', Constants::VERSION),
|
||||
$result
|
||||
);
|
||||
|
||||
|
||||
@@ -25,6 +25,6 @@ class ConsoleApplicationTest extends TestCase
|
||||
$sut = new ConsoleApplication($kernel);
|
||||
self::assertEquals(Constants::SOFTWARE, $sut->getName());
|
||||
self::assertEquals(Constants::VERSION, $sut->getVersion());
|
||||
self::assertEquals(sprintf('%s <info>%s</info> (env: <comment></>, debug: <comment>false</>)', Constants::SOFTWARE, Constants::VERSION), $sut->getLongVersion());
|
||||
self::assertEquals(\sprintf('%s <info>%s</info> (env: <comment></>, debug: <comment>false</>)', Constants::SOFTWARE, Constants::VERSION), $sut->getLongVersion());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,13 +182,13 @@ abstract class ControllerBaseTest extends WebTestCase
|
||||
|
||||
self::assertTrue(
|
||||
$response->isRedirect(),
|
||||
sprintf('The secure URL %s is not protected.', $url)
|
||||
\sprintf('The secure URL %s is not protected.', $url)
|
||||
);
|
||||
|
||||
self::assertStringEndsWith(
|
||||
'/login',
|
||||
$response->getTargetUrl(),
|
||||
sprintf('The secure URL %s does not redirect to the login form.', $url)
|
||||
\sprintf('The secure URL %s does not redirect to the login form.', $url)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ abstract class ControllerBaseTest extends WebTestCase
|
||||
$client->request($method, $this->createUrl($url));
|
||||
self::assertFalse(
|
||||
$client->getResponse()->isSuccessful(),
|
||||
sprintf('The secure URL %s is not protected for role %s', $url, $role)
|
||||
\sprintf('The secure URL %s is not protected for role %s', $url, $role)
|
||||
);
|
||||
$this->assertAccessDenied($client);
|
||||
}
|
||||
@@ -325,7 +325,7 @@ abstract class ControllerBaseTest extends WebTestCase
|
||||
self::assertEquals(
|
||||
\count($fieldNames),
|
||||
\count($validationErrors),
|
||||
sprintf('Expected %s validation errors, found %s', \count($fieldNames), \count($validationErrors))
|
||||
\sprintf('Expected %s validation errors, found %s', \count($fieldNames), \count($validationErrors))
|
||||
);
|
||||
|
||||
foreach ($fieldNames as $name) {
|
||||
@@ -432,7 +432,7 @@ abstract class ControllerBaseTest extends WebTestCase
|
||||
self::assertNotNull($location);
|
||||
|
||||
// check for meta refresh
|
||||
$expectedMeta = sprintf('<meta http-equiv="refresh" content="0;url=\'%1$s\'" />', $location);
|
||||
$expectedMeta = \sprintf('<meta http-equiv="refresh" content="0;url=\'%1$s\'" />', $location);
|
||||
self::assertStringContainsString($expectedMeta, $client->getResponse()->getContent());
|
||||
|
||||
if ($url !== null) {
|
||||
|
||||
@@ -243,7 +243,7 @@ class ProfileControllerTest extends ControllerBaseTest
|
||||
}
|
||||
|
||||
/**
|
||||
* @legacy
|
||||
* @group legacy
|
||||
*/
|
||||
public function testApiTokenAction(): void
|
||||
{
|
||||
|
||||
@@ -53,8 +53,8 @@ abstract class AbstractUserPeriodControllerTest extends ControllerBaseTest
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_SUPER_ADMIN);
|
||||
$this->importReportingFixture(User::ROLE_SUPER_ADMIN);
|
||||
$this->assertAccessIsGranted($client, sprintf('%s?user=%s&date=12999119191&sumType=%s', $this->getReportUrl(), $user, $dataType));
|
||||
self::assertStringContainsString(sprintf('<div class="card-body %s', $this->getBoxId()), $client->getResponse()->getContent());
|
||||
$this->assertAccessIsGranted($client, \sprintf('%s?user=%s&date=12999119191&sumType=%s', $this->getReportUrl(), $user, $dataType));
|
||||
self::assertStringContainsString(\sprintf('<div class="card-body %s', $this->getBoxId()), $client->getResponse()->getContent());
|
||||
$option = $client->getCrawler()->filterXPath("//select[@id='user']/option[@selected]");
|
||||
self::assertEquals($user, $option->attr('value'));
|
||||
$cell = $client->getCrawler()->filterXPath("//th[contains(@class, 'reportDataTypeTitle')]");
|
||||
@@ -65,8 +65,8 @@ abstract class AbstractUserPeriodControllerTest extends ControllerBaseTest
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);
|
||||
$this->importReportingFixture(User::ROLE_USER);
|
||||
$this->assertAccessIsGranted($client, sprintf('%s?date=12999119191', $this->getReportUrl()));
|
||||
self::assertStringContainsString(sprintf('<div class="card-body %s', $this->getBoxId()), $client->getResponse()->getContent());
|
||||
$this->assertAccessIsGranted($client, \sprintf('%s?date=12999119191', $this->getReportUrl()));
|
||||
self::assertStringContainsString(\sprintf('<div class="card-body %s', $this->getBoxId()), $client->getResponse()->getContent());
|
||||
$select = $client->getCrawler()->filterXPath("//select[@id='user']");
|
||||
self::assertEquals(0, $select->count());
|
||||
$cell = $client->getCrawler()->filterXPath("//th[contains(@class, 'reportDataTypeTitle')]");
|
||||
|
||||
@@ -56,8 +56,8 @@ abstract class AbstractUsersPeriodControllerTest extends ControllerBaseTest
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_SUPER_ADMIN);
|
||||
$this->importReportingFixture(User::ROLE_SUPER_ADMIN);
|
||||
$this->assertAccessIsGranted($client, sprintf('%s?date=12999119191&sumType=%s', $this->getReportUrl(), $dataType));
|
||||
self::assertStringContainsString(sprintf('<div class="card-body %s', $this->getBoxId()), $client->getResponse()->getContent());
|
||||
$this->assertAccessIsGranted($client, \sprintf('%s?date=12999119191&sumType=%s', $this->getReportUrl(), $dataType));
|
||||
self::assertStringContainsString(\sprintf('<div class="card-body %s', $this->getBoxId()), $client->getResponse()->getContent());
|
||||
$cell = $client->getCrawler()->filterXPath("//th[contains(@class, 'reportDataTypeTitle')]");
|
||||
self::assertEquals($title, $cell->text());
|
||||
}
|
||||
@@ -69,8 +69,8 @@ abstract class AbstractUsersPeriodControllerTest extends ControllerBaseTest
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_TEAMLEAD);
|
||||
$this->importReportingFixture(User::ROLE_TEAMLEAD);
|
||||
$this->assertAccessIsGranted($client, sprintf('%s?date=12999119191&sumType=%s', $this->getReportUrl(), $dataType));
|
||||
self::assertStringContainsString(sprintf('<div class="card-body %s', $this->getBoxId()), $client->getResponse()->getContent());
|
||||
$this->assertAccessIsGranted($client, \sprintf('%s?date=12999119191&sumType=%s', $this->getReportUrl(), $dataType));
|
||||
self::assertStringContainsString(\sprintf('<div class="card-body %s', $this->getBoxId()), $client->getResponse()->getContent());
|
||||
$select = $client->getCrawler()->filterXPath("//select[@id='user']");
|
||||
self::assertEquals(0, $select->count());
|
||||
$cell = $client->getCrawler()->filterXPath("//th[contains(@class, 'reportDataTypeTitle')]");
|
||||
@@ -84,7 +84,7 @@ abstract class AbstractUsersPeriodControllerTest extends ControllerBaseTest
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_SUPER_ADMIN);
|
||||
$this->importReportingFixture(User::ROLE_SUPER_ADMIN);
|
||||
$this->request($client, sprintf('%s?date=12999119191&sumType=%s', $this->getReportExportUrl(), $dataType));
|
||||
$this->request($client, \sprintf('%s?date=12999119191&sumType=%s', $this->getReportExportUrl(), $dataType));
|
||||
$response = $client->getResponse();
|
||||
$this->assertTrue($response->isSuccessful());
|
||||
self::assertInstanceOf(BinaryFileResponse::class, $response);
|
||||
|
||||
@@ -52,8 +52,8 @@ trait EntityValidationTestTrait
|
||||
$this->assertTrue($foundField, 'Failed finding violation for field: ' . $propertyPath);
|
||||
}
|
||||
|
||||
$this->assertEmpty($violatedFields, sprintf('Unexpected violations found: %s', implode(', ', $violatedFields)));
|
||||
$this->assertEquals($expected, $countViolations, sprintf('Expected %s violations, found %s in %s.', $expected, $actual, implode(', ', array_keys($violatedFields))));
|
||||
$this->assertEmpty($violatedFields, \sprintf('Unexpected violations found: %s', implode(', ', $violatedFields)));
|
||||
$this->assertEquals($expected, $countViolations, \sprintf('Expected %s violations, found %s in %s.', $expected, $actual, implode(', ', array_keys($violatedFields))));
|
||||
}
|
||||
|
||||
public function assertHasNoViolations($entity, $groups = null): void
|
||||
@@ -65,6 +65,6 @@ trait EntityValidationTestTrait
|
||||
$violations = $validator->validate($entity, null, $groups);
|
||||
$actual = $violations->count();
|
||||
|
||||
$this->assertEquals(0, $actual, sprintf('Expected 0 violations, found %s.', $actual));
|
||||
$this->assertEquals(0, $actual, \sprintf('Expected 0 violations, found %s.', $actual));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,7 +238,7 @@ class ConfigurableNumberGeneratorTest extends TestCase
|
||||
public function testInvalidGetInvoiceNumber(string $format, \DateTime $invoiceDate, string $brokenPart): void
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage(sprintf('Unknown %s found', $brokenPart));
|
||||
$this->expectExceptionMessage(\sprintf('Unknown %s found', $brokenPart));
|
||||
|
||||
$sut = $this->getSut($format);
|
||||
$model = (new InvoiceModelFactoryFactory($this))->create()->createModel(new DebugFormatter(), new Customer('foo'), new InvoiceTemplate(), new InvoiceQuery());
|
||||
|
||||
@@ -228,7 +228,7 @@ class LdapManagerTest extends TestCase
|
||||
|
||||
return $expected[1];
|
||||
}
|
||||
$this->fail(sprintf('Unexpected search with baseDn %s', $baseDn));
|
||||
$this->fail(\sprintf('Unexpected search with baseDn %s', $baseDn));
|
||||
});
|
||||
|
||||
$sut = $this->getLdapManager($driver);
|
||||
@@ -269,7 +269,7 @@ class LdapManagerTest extends TestCase
|
||||
return $expected[1];
|
||||
}
|
||||
|
||||
$this->fail(sprintf('Unexpected search with baseDn %s', $baseDn));
|
||||
$this->fail(\sprintf('Unexpected search with baseDn %s', $baseDn));
|
||||
});
|
||||
|
||||
$sut = $this->getLdapManager($driver);
|
||||
@@ -305,7 +305,7 @@ class LdapManagerTest extends TestCase
|
||||
return $expected[1];
|
||||
}
|
||||
|
||||
$this->fail(sprintf('Unexpected search with baseDn %s', $baseDn));
|
||||
$this->fail(\sprintf('Unexpected search with baseDn %s', $baseDn));
|
||||
});
|
||||
|
||||
$sut = $this->getLdapManager($driver, [
|
||||
@@ -445,7 +445,7 @@ class LdapManagerTest extends TestCase
|
||||
|
||||
return $expectedGroups;
|
||||
}
|
||||
$this->fail(sprintf('Unexpected search with baseDn %s', $baseDn));
|
||||
$this->fail(\sprintf('Unexpected search with baseDn %s', $baseDn));
|
||||
});
|
||||
|
||||
$sut = $this->getLdapManager($driver, $groupConfig);
|
||||
|
||||
@@ -23,9 +23,9 @@ class MonthTest extends TestCase
|
||||
foreach($months as $key => $days) {
|
||||
$index = ++$key;
|
||||
$monthKey = ($index < 10) ? '0' . $index : $index;
|
||||
$date = new \DateTimeImmutable(sprintf('2020-%s-25 13:00:00', $monthKey));
|
||||
$date = new \DateTimeImmutable(\sprintf('2020-%s-25 13:00:00', $monthKey));
|
||||
$month = new Month($date);
|
||||
self::assertEquals(sprintf('2020-%s-25', $monthKey), $month->getMonth()->format('Y-m-d'));
|
||||
self::assertEquals(\sprintf('2020-%s-25', $monthKey), $month->getMonth()->format('Y-m-d'));
|
||||
self::assertCount($days, $month->getDays());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,8 +27,8 @@ class YearTest extends TestCase
|
||||
foreach($months as $key => $days) {
|
||||
$index = ++$key;
|
||||
$monthKey = ($index < 10) ? '0' . $index : $index;
|
||||
$month = $sut->getMonth(new \DateTimeImmutable(sprintf('2020-%s-13 13:00:00', $monthKey)));
|
||||
self::assertEquals(sprintf('2020-%s-01', $monthKey), $month->getMonth()->format('Y-m-d'));
|
||||
$month = $sut->getMonth(new \DateTimeImmutable(\sprintf('2020-%s-13 13:00:00', $monthKey)));
|
||||
self::assertEquals(\sprintf('2020-%s-01', $monthKey), $month->getMonth()->format('Y-m-d'));
|
||||
self::assertCount($days, $month->getDays());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ class TranslationsTest extends TestCase
|
||||
foreach ($body->children() as $transUnit) {
|
||||
self::assertNotEmpty(
|
||||
(string) $transUnit->target,
|
||||
sprintf(
|
||||
\sprintf(
|
||||
'Found empty translation in language "%s" and file "%s" for key "%s"',
|
||||
$xml->file->attributes()['target-language'],
|
||||
basename($file),
|
||||
@@ -88,14 +88,14 @@ class TranslationsTest extends TestCase
|
||||
// some special cases, which don't work properly - base translation should be changed
|
||||
preg_match_all('/%[a-zA-Z]{1,}%/Uu', (string) $transUnit->target, $matches);
|
||||
asort($matches[0]);
|
||||
self::assertEquals($transLang[$key], array_values($matches[0]), sprintf('Invalid replacer "%s" in "%s"', $key, basename($file)));
|
||||
self::assertEquals($transLang[$key], array_values($matches[0]), \sprintf('Invalid replacer "%s" in "%s"', $key, basename($file)));
|
||||
$counter++;
|
||||
unset($transLang[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
$counter += \count($transLang);
|
||||
self::assertEquals($expectedCounter, $counter, sprintf('Missing replacer in "%s", did not find translation keys: %s', basename($file), implode(', ', array_keys($transLang))));
|
||||
self::assertEquals($expectedCounter, $counter, \sprintf('Missing replacer in "%s", did not find translation keys: %s', basename($file), implode(', ', array_keys($transLang))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ class FormFormatConverterTest extends TestCase
|
||||
$sut = new FormFormatConverter();
|
||||
foreach ($this->getPossibleDateTimePattern() as $format => $example) {
|
||||
$pattern = $sut->convertToPattern($format, false);
|
||||
$this->assertMatchesRegularExpression($pattern, $example, sprintf('Invalid pattern %s for format %s, did not match %s', $pattern, $format, $example));
|
||||
$this->assertMatchesRegularExpression($pattern, $example, \sprintf('Invalid pattern %s for format %s, did not match %s', $pattern, $format, $example));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ class CustomerVoterTest extends AbstractVoterTest
|
||||
$sut = $this->getVoter(CustomerVoter::class);
|
||||
|
||||
$actual = $sut->vote($token, $subject, [$attribute]);
|
||||
$this->assertEquals($result, $actual, sprintf('Failed voting "%s" for User with roles %s.', $attribute, implode(', ', $user->getRoles())));
|
||||
$this->assertEquals($result, $actual, \sprintf('Failed voting "%s" for User with roles %s.', $attribute, implode(', ', $user->getRoles())));
|
||||
}
|
||||
|
||||
public function testVote(): void
|
||||
|
||||
@@ -32,7 +32,7 @@ class ProjectVoterTest extends AbstractVoterTest
|
||||
}
|
||||
|
||||
$actual = $sut->vote($token, $subject, [$attribute]);
|
||||
$this->assertEquals($result, $actual, sprintf('Failed voting "%s" for User with roles %s.', $attribute, implode(', ', $user->getRoles())));
|
||||
$this->assertEquals($result, $actual, \sprintf('Failed voting "%s" for User with roles %s.', $attribute, implode(', ', $user->getRoles())));
|
||||
}
|
||||
|
||||
public function testVote(): void
|
||||
|
||||
@@ -29,7 +29,7 @@ class RolePermissionVoterTest extends AbstractVoterTest
|
||||
$sut = $this->getVoter(RolePermissionVoter::class);
|
||||
|
||||
$actual = $sut->vote($token, $subject, [$attribute]);
|
||||
$this->assertEquals($result, $actual, sprintf('Failed voting "%s" for User with roles %s.', $attribute, implode(', ', $user->getRoles())));
|
||||
$this->assertEquals($result, $actual, \sprintf('Failed voting "%s" for User with roles %s.', $attribute, implode(', ', $user->getRoles())));
|
||||
}
|
||||
|
||||
public function getTestData()
|
||||
|
||||
@@ -29,9 +29,9 @@ class MonthTest extends TestCase
|
||||
foreach($months as $key => $days) {
|
||||
$index = ++$key;
|
||||
$monthKey = ($index < 10) ? '0' . $index : $index;
|
||||
$date = new \DateTimeImmutable(sprintf('2020-%s-25 13:00:00', $monthKey));
|
||||
$date = new \DateTimeImmutable(\sprintf('2020-%s-25 13:00:00', $monthKey));
|
||||
$month = new Month($date, $user);
|
||||
self::assertEquals(sprintf('2020-%s-25', $monthKey), $month->getMonth()->format('Y-m-d'));
|
||||
self::assertEquals(\sprintf('2020-%s-25', $monthKey), $month->getMonth()->format('Y-m-d'));
|
||||
self::assertCount($days, $month->getDays());
|
||||
self::assertFalse($month->isLocked());
|
||||
self::assertEquals(0, $month->getActualTime());
|
||||
|
||||
Reference in New Issue
Block a user