* use php-cs-fixer instead of phpcodesniffer * updated scrutinizer config * adjusted code yules to all files * updated CONTRIBUTING guidelines
This commit is contained in:
@@ -65,7 +65,7 @@ class CreateUserCommandTest extends KernelTestCase
|
||||
$command = $this->application->find('kimai:create-user');
|
||||
$commandTester = new CommandTester($command);
|
||||
$commandTester->execute([
|
||||
'command' => $command->getName(),
|
||||
'command' => $command->getName(),
|
||||
'username' => $username,
|
||||
'email' => $email,
|
||||
'role' => $role,
|
||||
@@ -77,7 +77,7 @@ class CreateUserCommandTest extends KernelTestCase
|
||||
|
||||
public function testUserAlreadyExisting()
|
||||
{
|
||||
$commandTester = $this->createUser('MyTestUser', 'user@example.com', 'ROLE_USER', 'foobar');
|
||||
$this->createUser('MyTestUser', 'user@example.com', 'ROLE_USER', 'foobar');
|
||||
$commandTester = $this->createUser('MyTestUser', 'user@example.com', 'ROLE_USER', 'foobar');
|
||||
|
||||
$output = $commandTester->getDisplay();
|
||||
|
||||
@@ -15,7 +15,6 @@ namespace App\Tests\Controller;
|
||||
*/
|
||||
class ActivityControllerTest extends ControllerBaseTest
|
||||
{
|
||||
|
||||
public function testIsSecure()
|
||||
{
|
||||
$this->markTestSkipped('no public route available');
|
||||
|
||||
@@ -18,7 +18,6 @@ use App\Tests\Controller\ControllerBaseTest;
|
||||
*/
|
||||
class ActivityControllerTest extends ControllerBaseTest
|
||||
{
|
||||
|
||||
public function testIsSecure()
|
||||
{
|
||||
$this->assertUrlIsSecured('/admin/activity/');
|
||||
|
||||
@@ -18,7 +18,6 @@ use App\Tests\Controller\ControllerBaseTest;
|
||||
*/
|
||||
class CustomerControllerTest extends ControllerBaseTest
|
||||
{
|
||||
|
||||
public function testIsSecure()
|
||||
{
|
||||
$this->assertUrlIsSecured('/admin/customer/');
|
||||
|
||||
@@ -18,7 +18,6 @@ use App\Tests\Controller\ControllerBaseTest;
|
||||
*/
|
||||
class ProjectControllerTest extends ControllerBaseTest
|
||||
{
|
||||
|
||||
public function testIsSecure()
|
||||
{
|
||||
$this->assertUrlIsSecured('/admin/project/');
|
||||
|
||||
@@ -18,7 +18,6 @@ use App\Tests\Controller\ControllerBaseTest;
|
||||
*/
|
||||
class TimesheetControllerTest extends ControllerBaseTest
|
||||
{
|
||||
|
||||
public function testIsSecure()
|
||||
{
|
||||
$this->assertUrlIsSecured('/team/timesheet/');
|
||||
|
||||
@@ -18,7 +18,6 @@ use App\Tests\Controller\ControllerBaseTest;
|
||||
*/
|
||||
class UserControllerTest extends ControllerBaseTest
|
||||
{
|
||||
|
||||
public function testIsSecure()
|
||||
{
|
||||
$this->assertUrlIsSecured('/admin/user/');
|
||||
|
||||
@@ -13,14 +13,14 @@ use App\DataFixtures\AppFixtures;
|
||||
use App\Entity\User;
|
||||
use Symfony\Bundle\FrameworkBundle\Client;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
|
||||
/**
|
||||
* ControllerBaseTest adds some useful functions for writing integration tests.
|
||||
*/
|
||||
abstract class ControllerBaseTest extends WebTestCase
|
||||
{
|
||||
|
||||
const DEFAULT_LANGUAGE = 'en';
|
||||
public const DEFAULT_LANGUAGE = 'en';
|
||||
|
||||
/**
|
||||
* @param string $role
|
||||
@@ -28,7 +28,7 @@ abstract class ControllerBaseTest extends WebTestCase
|
||||
*/
|
||||
protected function getClientForAuthenticatedUser(string $role = User::ROLE_USER)
|
||||
{
|
||||
switch($role) {
|
||||
switch ($role) {
|
||||
case User::ROLE_SUPER_ADMIN:
|
||||
$client = self::createClient([], [
|
||||
'PHP_AUTH_USER' => AppFixtures::USERNAME_SUPER_ADMIN,
|
||||
@@ -85,14 +85,17 @@ abstract class ControllerBaseTest extends WebTestCase
|
||||
{
|
||||
$client->request($method, '/' . self::DEFAULT_LANGUAGE . $url);
|
||||
|
||||
/* @var RedirectResponse $response */
|
||||
$response = $client->getResponse();
|
||||
|
||||
$this->assertTrue(
|
||||
$client->getResponse()->isRedirect(),
|
||||
sprintf('The secure URL %s is not protected.', $url . $client->getResponse()->getContent())
|
||||
$response->isRedirect(),
|
||||
sprintf('The secure URL %s is not protected.', $url . $response->getContent())
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
'http://localhost/' . self::DEFAULT_LANGUAGE . '/login',
|
||||
$client->getResponse()->getTargetUrl(),
|
||||
$response->getTargetUrl(),
|
||||
sprintf('The secure URL %s does not redirect to the login form.', $url)
|
||||
);
|
||||
}
|
||||
@@ -150,7 +153,7 @@ abstract class ControllerBaseTest extends WebTestCase
|
||||
*/
|
||||
protected function assertMainContentClass(Client $client, $classname)
|
||||
{
|
||||
$this->assertContains('<section class="content '.$classname.'">', $client->getResponse()->getContent());
|
||||
$this->assertContains('<section class="content ' . $classname . '">', $client->getResponse()->getContent());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,7 +15,6 @@ namespace App\Tests\Controller;
|
||||
*/
|
||||
class DashboardControllerTest extends ControllerBaseTest
|
||||
{
|
||||
|
||||
public function testIsSecure()
|
||||
{
|
||||
$this->assertUrlIsSecured('/dashboard/');
|
||||
|
||||
@@ -15,7 +15,6 @@ namespace App\Tests\Controller;
|
||||
*/
|
||||
class HelpControllerTest extends ControllerBaseTest
|
||||
{
|
||||
|
||||
public function testIsSecure()
|
||||
{
|
||||
$this->assertUrlIsSecured('/help/');
|
||||
|
||||
@@ -17,7 +17,6 @@ use App\Entity\User;
|
||||
*/
|
||||
class InvoiceControllerTest extends ControllerBaseTest
|
||||
{
|
||||
|
||||
public function testIsSecure()
|
||||
{
|
||||
$this->assertUrlIsSecured('/invoice/');
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
namespace App\Tests\Controller;
|
||||
|
||||
use App\DataFixtures\AppFixtures;
|
||||
use App\Entity\User;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \App\Controller\InvoiceController
|
||||
@@ -18,7 +17,6 @@ use App\Entity\User;
|
||||
*/
|
||||
class ProfileControllerTest extends ControllerBaseTest
|
||||
{
|
||||
|
||||
public function testIsSecure()
|
||||
{
|
||||
$this->assertUrlIsSecured('/profile/' . AppFixtures::USERNAME_USER);
|
||||
|
||||
@@ -15,7 +15,6 @@ namespace App\Tests\Controller;
|
||||
*/
|
||||
class SidebarControllerTest extends ControllerBaseTest
|
||||
{
|
||||
|
||||
public function testIsSecure()
|
||||
{
|
||||
$this->markTestSkipped('no public route available');
|
||||
|
||||
@@ -9,16 +9,12 @@
|
||||
|
||||
namespace App\Tests\Controller;
|
||||
|
||||
use App\DataFixtures\AppFixtures;
|
||||
use App\Entity\User;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \App\Controller\TimesheetController
|
||||
* @group integration
|
||||
*/
|
||||
class TimesheetControllerTest extends ControllerBaseTest
|
||||
{
|
||||
|
||||
public function testIsSecure()
|
||||
{
|
||||
$this->assertUrlIsSecured('/timesheet/');
|
||||
|
||||
@@ -16,7 +16,6 @@ use App\Entity\Timesheet;
|
||||
use App\Entity\User;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Validator\ConstraintViolationInterface;
|
||||
use Symfony\Component\Validator\ConstraintViolationListInterface;
|
||||
use Symfony\Component\Validator\Validation;
|
||||
|
||||
/**
|
||||
@@ -24,7 +23,6 @@ use Symfony\Component\Validator\Validation;
|
||||
*/
|
||||
class TimesheetTest extends TestCase
|
||||
{
|
||||
|
||||
protected function getEntity()
|
||||
{
|
||||
$customer = new Customer();
|
||||
@@ -103,12 +101,11 @@ class TimesheetTest extends TestCase
|
||||
|
||||
$violatedFields = [];
|
||||
/** @var ConstraintViolationInterface $validation */
|
||||
foreach($validations as $validation) {
|
||||
foreach ($validations as $validation) {
|
||||
$violatedFields[] = $validation->getPropertyPath();
|
||||
}
|
||||
|
||||
|
||||
foreach($fieldNames as $id => $propertyPath) {
|
||||
foreach ($fieldNames as $id => $propertyPath) {
|
||||
$foundField = false;
|
||||
if (in_array($propertyPath, $violatedFields)) {
|
||||
$foundField = true;
|
||||
|
||||
@@ -11,14 +11,13 @@ namespace App\Tests\Repository\Query;
|
||||
|
||||
use App\Entity\User;
|
||||
use App\Repository\Query\BaseQuery;
|
||||
use \PHPUnit\Framework\TestCase;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Repository\Query\BaseQuery
|
||||
*/
|
||||
class BaseQueryTest extends TestCase
|
||||
{
|
||||
|
||||
public function testQuery()
|
||||
{
|
||||
$this->assertBaseQuery(new BaseQuery());
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace App\Tests\Timesheet\Calculator;
|
||||
|
||||
use App\Entity\Timesheet;
|
||||
use App\Timesheet\Calculator\DurationCalculator;
|
||||
use \PHPUnit\Framework\TestCase;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Timesheet\Calculator\DurationCalculator
|
||||
@@ -118,7 +118,7 @@ class DurationCalculatorTest extends TestCase
|
||||
'duration' => 0,
|
||||
],
|
||||
'weekdays' => [
|
||||
'days' => ['monday','tuesday','wednesday','thursday','friday','saturday','sunday'],
|
||||
'days' => ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'],
|
||||
'begin' => 0,
|
||||
'end' => 1,
|
||||
'duration' => 30,
|
||||
@@ -137,7 +137,7 @@ class DurationCalculatorTest extends TestCase
|
||||
'duration' => 30,
|
||||
],
|
||||
'weekdays' => [
|
||||
'days' => ['monday','tuesday','wednesday','thursday','friday','saturday','sunday'],
|
||||
'days' => ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'],
|
||||
'begin' => 0,
|
||||
'end' => 1,
|
||||
'duration' => 0,
|
||||
|
||||
@@ -13,14 +13,14 @@ use App\Entity\Timesheet;
|
||||
use App\Entity\User;
|
||||
use App\Entity\UserPreference;
|
||||
use App\Timesheet\Calculator\RateCalculator;
|
||||
use \PHPUnit\Framework\TestCase;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Timesheet\Calculator\RateCalculator
|
||||
*/
|
||||
class RateCalculatorTest extends TestCase
|
||||
{
|
||||
const HOURLY_RATE = 75;
|
||||
public const HOURLY_RATE = 75;
|
||||
|
||||
protected function getTestUser()
|
||||
{
|
||||
@@ -144,7 +144,7 @@ class RateCalculatorTest extends TestCase
|
||||
'factor' => 2.0
|
||||
],
|
||||
'weekdays' => [
|
||||
'days' => ['monday','tuesday','wednesday','thursday','friday','saturday','sunday'],
|
||||
'days' => ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'],
|
||||
'factor' => 1.5
|
||||
],
|
||||
],
|
||||
|
||||
@@ -19,7 +19,6 @@ use Twig\TwigFilter;
|
||||
*/
|
||||
class ExtensionsTest extends TestCase
|
||||
{
|
||||
|
||||
public function testGetFilters()
|
||||
{
|
||||
$filters = ['duration', 'money', 'currency', 'country'];
|
||||
@@ -123,6 +122,7 @@ class ExtensionsTest extends TestCase
|
||||
$record->setBegin($begin);
|
||||
$record->setEnd($end);
|
||||
$record->setDuration($seconds);
|
||||
|
||||
return $record;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ use PHPUnit\Framework\TestCase;
|
||||
*/
|
||||
class MarkdownExtensionTest extends TestCase
|
||||
{
|
||||
|
||||
public function testGetFilters()
|
||||
{
|
||||
$sut = new MarkdownExtension(new Markdown());
|
||||
|
||||
@@ -17,7 +17,6 @@ use PHPUnit\Framework\TestCase;
|
||||
*/
|
||||
class DurationTest extends TestCase
|
||||
{
|
||||
|
||||
public function testFormat()
|
||||
{
|
||||
$sut = new Duration();
|
||||
|
||||
@@ -17,7 +17,6 @@ use PHPUnit\Framework\TestCase;
|
||||
*/
|
||||
class MarkdownTest extends TestCase
|
||||
{
|
||||
|
||||
public function testMarkdownToHtml()
|
||||
{
|
||||
$sut = new Markdown();
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
namespace App\Tests\Voter;
|
||||
|
||||
use App\Entity\User;
|
||||
use \PHPUnit\Framework\TestCase;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
|
||||
use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface;
|
||||
use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;
|
||||
@@ -23,7 +23,6 @@ use App\Voter\TimesheetVoter;
|
||||
*/
|
||||
class TimesheetVoterTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @dataProvider getTestData
|
||||
*/
|
||||
@@ -42,8 +41,8 @@ class TimesheetVoterTest extends TestCase
|
||||
public function getTestData()
|
||||
{
|
||||
$user0 = $this->getUser(0, 'ROLE_CUSTOMER');
|
||||
$user1 = $this->getUser(1, 'ROLE_USER');
|
||||
$user2 = $this->getUser(1, 'ROLE_TEAMLEAD');
|
||||
$user1 = $this->getUser(1, 'ROLE_USER');
|
||||
$user2 = $this->getUser(1, 'ROLE_TEAMLEAD');
|
||||
|
||||
return [
|
||||
[$user0, false, new Customer(), ['edit'], VoterInterface::ACCESS_ABSTAIN],
|
||||
@@ -57,6 +56,7 @@ class TimesheetVoterTest extends TestCase
|
||||
{
|
||||
$timesheet = new Timesheet();
|
||||
$timesheet->setUser($user);
|
||||
|
||||
return $timesheet;
|
||||
}
|
||||
|
||||
@@ -65,6 +65,7 @@ class TimesheetVoterTest extends TestCase
|
||||
$user = $this->getMockBuilder(User::class)->getMock();
|
||||
$user->method('getId')->willReturn($id);
|
||||
$user->method('getRoles')->willReturn([$role]);
|
||||
|
||||
return $user;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user