Fixed code style.

This commit is contained in:
Jan Böhmer 2020-01-04 20:24:09 +01:00
parent 1aed1d1d26
commit 9a7223a301
142 changed files with 534 additions and 716 deletions

View file

@ -21,12 +21,11 @@
namespace App\Tests;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
/**
* This test just ensures that different pages are available (do not throw an exception)
* @package App\Tests
* This test just ensures that different pages are available (do not throw an exception).
*
* @group DB
* @group slow
*/
@ -35,10 +34,10 @@ class ApplicationAvailabilityFunctionalTest extends WebTestCase
/**
* @dataProvider urlProvider
*/
public function testPageIsSuccessful(string $url) : void
public function testPageIsSuccessful(string $url): void
{
//We have localized routes
$url = '/en' . $url;
$url = '/en'.$url;
//Try to access pages with admin, because he should be able to view every page!
$client = static::createClient([], [
@ -48,10 +47,9 @@ class ApplicationAvailabilityFunctionalTest extends WebTestCase
$client->request('GET', $url);
$this->assertTrue($client->getResponse()->isSuccessful(), 'Request not successful. Status code is ' . $client->getResponse()->getStatusCode());
$this->assertTrue($client->getResponse()->isSuccessful(), 'Request not successful. Status code is '.$client->getResponse()->getStatusCode());
}
public function urlProvider()
{
//Homepage
@ -92,4 +90,4 @@ class ApplicationAvailabilityFunctionalTest extends WebTestCase
yield ['/typeahead/builtInResources/search/DIP8'];
yield ['/typeahead/tags/search/test'];
}
}
}

View file

@ -35,7 +35,7 @@ class RedirectControllerTest extends WebTestCase
protected $userRepo;
protected $client;
public function setUp() : void
public function setUp(): void
{
$this->client = static::createClient([], [
'PHP_AUTH_USER' => 'user',
@ -114,8 +114,6 @@ class RedirectControllerTest extends WebTestCase
$user->setLanguage($user_locale);
$this->em->flush();
$this->client->followRedirects(false);
$this->client->request('GET', $input_path);
$this->assertEquals($redirect_path, $this->client->getResponse()->headers->get('Location'));

View file

@ -39,7 +39,7 @@ class StructuralDBElementTest extends TestCase
protected $child1_1;
protected $child1_2;
public function setUp() : void
public function setUp(): void
{
parent::setUp(); // TODO: Change the autogenerated stub

View file

@ -27,7 +27,6 @@ use PHPUnit\Framework\TestCase;
class PermissionsEmbedTest extends TestCase
{
public function testGetPermissionValue()
{
$embed = new PermissionsEmbed();

View file

@ -38,12 +38,12 @@ class UserTest extends TestCase
$this->assertEquals('John Doe (username)', $user->getFullName(true));
}
public function googleAuthenticatorEnabledDataProvider() : array
public function googleAuthenticatorEnabledDataProvider(): array
{
return [
[null, false],
['', false],
['SSSk38498', true]
['SSSk38498', true],
];
}
@ -54,7 +54,7 @@ class UserTest extends TestCase
{
$user = new User();
$user->setGoogleAuthenticatorSecret($secret);
$this->assertSame($expected ,$user->isGoogleAuthenticatorEnabled());
$this->assertSame($expected, $user->isGoogleAuthenticatorEnabled());
}
/**
@ -63,7 +63,7 @@ class UserTest extends TestCase
public function testSetBackupCodes()
{
$user = new User();
$codes = ["test", "invalid", "test"];
$codes = ['test', 'invalid', 'test'];
$user->setBackupCodes($codes);
// Backup Codes generation date must be changed!
$this->assertEqualsWithDelta(new \DateTime(), $user->getBackupCodesGenerationDate(), 0.1);

View file

@ -29,7 +29,6 @@ use PHPUnit\Framework\TestCase;
class PasswordChangeNeededSubscriberTest extends TestCase
{
public function testTFARedirectNeeded()
{
$user = new User();
@ -55,6 +54,5 @@ class PasswordChangeNeededSubscriberTest extends TestCase
$user->setGoogleAuthenticatorSecret(null);
$user->addU2FKey(new U2FKey());
$this->assertFalse(PasswordChangeNeededSubscriber::TFARedirectNeeded($user));
}
}

View file

@ -28,7 +28,7 @@ class BBCodeToMarkdownConverterTest extends TestCase
{
protected $converter;
public function setUp() : void
public function setUp(): void
{
$this->converter = new BBCodeToMarkdownConverter();
}

View file

@ -35,7 +35,7 @@ class TreeViewNodeTest extends TestCase
*/
protected $node2;
public function setUp() : void
public function setUp(): void
{
$sub_nodes = [];
$sub_nodes[] = new TreeViewNode('Subnode 1');

View file

@ -21,12 +21,9 @@
namespace App\Tests\Repository;
use App\Entity\Attachments\AttachmentType;
use App\Entity\UserSystem\User;
use App\Helpers\Trees\TreeViewNode;
use App\Repository\NamedDBElementRepository;
use App\Repository\StructuralDBElementRepository;
use PHPUnit\Framework\TestCase;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
/**
@ -34,15 +31,14 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
*/
class NamedDBElementRepositoryTest extends WebTestCase
{
private $entityManager;
/** @var StructuralDBElementRepository */
private $repo;
/**
* {@inheritDoc}
* {@inheritdoc}
*/
protected function setUp() : void
protected function setUp(): void
{
$kernel = self::bootKernel();

View file

@ -24,7 +24,6 @@ namespace App\Tests\Repository;
use App\Entity\Attachments\AttachmentType;
use App\Helpers\Trees\TreeViewNode;
use App\Repository\StructuralDBElementRepository;
use PHPUnit\Framework\TestCase;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
/**
@ -32,15 +31,14 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
*/
class StructuralDBElementRepositoryTest extends WebTestCase
{
private $entityManager;
/** @var StructuralDBElementRepository */
private $repo;
/**
* {@inheritDoc}
* {@inheritdoc}
*/
protected function setUp() : void
protected function setUp(): void
{
$kernel = self::bootKernel();
@ -51,7 +49,7 @@ class StructuralDBElementRepositoryTest extends WebTestCase
$this->repo = $this->entityManager->getRepository(AttachmentType::class);
}
public function testFindRootNodes() : void
public function testFindRootNodes(): void
{
$root_nodes = $this->repo->findRootNodes();
$this->assertCount(3, $root_nodes);
@ -63,7 +61,7 @@ class StructuralDBElementRepositoryTest extends WebTestCase
$this->assertEquals('Node 3', $root_nodes[2]->getName());
}
public function testGetGenericTree() : void
public function testGetGenericTree(): void
{
$tree = $this->repo->getGenericNodeTree();
$this->assertIsArray($tree);
@ -86,13 +84,12 @@ class StructuralDBElementRepositoryTest extends WebTestCase
$this->assertEquals(1, $tree[0]->getId());
$this->assertEquals(2, $tree[1]->getId());
$this->assertEquals(7, $tree[0]->getNodes()[0]->getNodes()[0]->getId());
}
/**
* Test $repo->toNodesList() for null as parameter
* Test $repo->toNodesList() for null as parameter.
*/
public function testToNodesListRoot() : void
public function testToNodesListRoot(): void
{
//List all root nodes and their children
$nodes = $this->repo->toNodesList();
@ -108,7 +105,7 @@ class StructuralDBElementRepositoryTest extends WebTestCase
$this->assertEquals('Node 3', $nodes[6]->getName());
}
public function testToNodesListElement() : void
public function testToNodesListElement(): void
{
//List all nodes that are children to Node 1
$node1 = $this->repo->find(1);

View file

@ -21,7 +21,6 @@
namespace App\Tests\Security\Annotations;
use App\Entity\Attachments\AttachmentType;
use App\Security\Annotations\ColumnSecurity;
use PHPUnit\Framework\TestCase;
@ -48,7 +47,7 @@ class ColumnSecurityTest extends TestCase
$this->assertEquals('prefix.overwritten', $annotation->getEditOperationName());
}
public function placeholderScalarDataProvider() : array
public function placeholderScalarDataProvider(): array
{
return [
['string', '???'],
@ -64,7 +63,7 @@ class ColumnSecurityTest extends TestCase
/**
* @dataProvider placeholderScalarDataProvider
* @param string $type
*
* @param $expected_value
*/
public function testGetPlaceholderScalar(string $type, $expected_value)
@ -84,7 +83,7 @@ class ColumnSecurityTest extends TestCase
$this->assertCount(1, $annotation->getPlaceholder());
//If a placeholder is specified we allow every type
$annotation->type = "type2";
$annotation->type = 'type2';
$annotation->placeholder = 'invalid';
$this->assertEquals('invalid', $annotation->getPlaceholder());
}
@ -104,4 +103,4 @@ class ColumnSecurityTest extends TestCase
$this->assertInstanceOf(AttachmentType::class, $placeholder);
$this->assertEquals('test', $placeholder->getName());
}
}
}

View file

@ -21,7 +21,6 @@
namespace App\Tests\Security;
use App\Entity\UserSystem\User;
use App\Security\UserChecker;
use PHPUnit\Framework\TestCase;
@ -31,7 +30,7 @@ class UserCheckerTest extends TestCase
{
protected $service;
public function setUp() : void
public function setUp(): void
{
$this->service = new UserChecker();
}
@ -49,4 +48,4 @@ class UserCheckerTest extends TestCase
$this->expectException(DisabledException::class);
$this->service->checkPostAuth($user);
}
}
}

View file

@ -32,7 +32,7 @@ class AmountFormatterTest extends WebTestCase
*/
protected $service;
public function setUp() : void
public function setUp(): void
{
parent::setUp(); // TODO: Change the autogenerated stub

View file

@ -48,7 +48,7 @@ class AttachmentPathResolverTest extends WebTestCase
self::$footprint_path = self::$projectDir.'/public/img/footprints';
}
public static function setUpBeforeClass() : void
public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();

View file

@ -30,7 +30,7 @@ class AttachmentURLGeneratorTest extends WebTestCase
protected static $service;
public static function setUpBeforeClass() : void
public static function setUpBeforeClass(): void
{
//Get an service instance.
self::bootKernel();

View file

@ -34,7 +34,7 @@ class BuiltinAttachmentsFinderTest extends WebTestCase
'%FOOTPRINTS_3D%/test.jpg', '%FOOTPRINTS_3D%/hallo.txt',
];
public static function setUpBeforeClass() : void
public static function setUpBeforeClass(): void
{
//Get an service instance.
self::bootKernel();

View file

@ -28,7 +28,7 @@ class FileTypeFilterToolsTest extends WebTestCase
{
protected static $service;
public static function setUpBeforeClass() : void
public static function setUpBeforeClass(): void
{
self::bootKernel();
self::$service = self::$container->get(FileTypeFilterTools::class);

View file

@ -21,7 +21,6 @@
namespace App\Tests\Services;
use App\Entity\Attachments\PartAttachment;
use App\Entity\Base\DBElement;
use App\Entity\Base\NamedDBElement;
@ -30,7 +29,6 @@ use App\Entity\Parts\Part;
use App\Exceptions\EntityNotSupportedException;
use App\Services\AmountFormatter;
use App\Services\ElementTypeNameGenerator;
use PHPUnit\Framework\TestCase;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class ElementTypeNameGeneratorTest extends WebTestCase
@ -40,7 +38,7 @@ class ElementTypeNameGeneratorTest extends WebTestCase
*/
protected $service;
public function setUp() : void
public function setUp(): void
{
parent::setUp();
@ -60,7 +58,7 @@ class ElementTypeNameGeneratorTest extends WebTestCase
//Test exception for unknpwn type
$this->expectException(EntityNotSupportedException::class);
$this->service->getLocalizedTypeLabel(new class extends DBElement {
$this->service->getLocalizedTypeLabel(new class() extends DBElement {
public function getIDString(): string
{
return 'Stub';
@ -79,11 +77,11 @@ class ElementTypeNameGeneratorTest extends WebTestCase
//Test exception
$this->expectException(EntityNotSupportedException::class);
$this->service->getTypeNameCombination(new class extends NamedDBElement {
$this->service->getTypeNameCombination(new class() extends NamedDBElement {
public function getIDString(): string
{
return 'Stub';
}
});
}
}
}

View file

@ -21,10 +21,8 @@
namespace App\Tests\Services;
use App\Entity\Attachments\AttachmentType;
use App\Services\AmountFormatter;
use App\Services\ElementTypeNameGenerator;
use App\Services\EntityImporter;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
@ -38,7 +36,7 @@ class EntityImporterTest extends WebTestCase
*/
protected $service;
public function setUp() : void
public function setUp(): void
{
parent::setUp();
@ -84,4 +82,4 @@ class EntityImporterTest extends WebTestCase
$this->assertCount(2, $errors);
$this->assertEquals('Node 1', $errors[0]['entity']->getName());
}
}
}

View file

@ -21,7 +21,6 @@
namespace App\Tests\Services;
use App\Services\FAIconGenerator;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
@ -32,7 +31,7 @@ class FAIconGeneratorTest extends WebTestCase
*/
protected $service;
public function setUp() : void
public function setUp(): void
{
parent::setUp(); // TODO: Change the autogenerated stub
@ -41,7 +40,7 @@ class FAIconGeneratorTest extends WebTestCase
$this->service = self::$container->get(FAIconGenerator::class);
}
public function fileExtensionDataProvider() : array
public function fileExtensionDataProvider(): array
{
return [
['pdf', 'fa-file-pdf'],
@ -69,4 +68,4 @@ class FAIconGeneratorTest extends WebTestCase
$this->assertEquals('<i class="far fa-file "></i>', $this->service->generateIconHTML('fa-file', 'far'));
$this->assertEquals('<i class="far fa-file fa-2x"></i>', $this->service->generateIconHTML('fa-file', 'far', 'fa-2x'));
}
}
}

View file

@ -38,7 +38,7 @@ class PermissionResolverTest extends WebTestCase
protected $user_withoutGroup;
protected $group;
public function setUp() : void
public function setUp(): void
{
parent::setUp(); // TODO: Change the autogenerated stub

View file

@ -35,7 +35,7 @@ class PricedetailHelperTest extends WebTestCase
*/
protected $service;
public function setUp() : void
public function setUp(): void
{
parent::setUp();
//Get an service instance.

View file

@ -31,7 +31,7 @@ class SIFormatterTest extends WebTestCase
*/
protected $service;
public function setUp() : void
public function setUp(): void
{
//Get an service instance.
self::bootKernel();

View file

@ -27,7 +27,7 @@ use PHPUnit\Framework\TestCase;
class BackupCodeGeneratorTest extends TestCase
{
/**
* Test if an exception is thrown if you are using a too high code length
* Test if an exception is thrown if you are using a too high code length.
*/
public function testLengthUpperLimit()
{
@ -36,7 +36,7 @@ class BackupCodeGeneratorTest extends TestCase
}
/**
* Test if an exception is thrown if you are using a too high code length
* Test if an exception is thrown if you are using a too high code length.
*/
public function testLengthLowerLimit()
{
@ -44,7 +44,6 @@ class BackupCodeGeneratorTest extends TestCase
new BackupCodeGenerator(4, 10);
}
public function codeLengthDataProvider()
{
return [[6], [8], [10], [16]];

View file

@ -21,7 +21,6 @@
namespace App\Tests\Services\TFA;
use App\Entity\UserSystem\U2FKey;
use App\Entity\UserSystem\User;
use App\Services\TFA\BackupCodeManager;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
@ -29,7 +28,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class BackupCodeManagerTest extends WebTestCase
{
/**
* @var BackupCodeManager $service
* @var BackupCodeManager
*/
protected $service;

View file

@ -28,13 +28,11 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
/**
* @Group DB
* @package App\Tests\Services\Trees
*/
class NodesListBuilderTest extends WebTestCase
{
/**
* @var NodesListBuilder $service
* @var NodesListBuilder
*/
protected $service;
protected $em;
@ -47,9 +45,9 @@ class NodesListBuilderTest extends WebTestCase
}
/**
* Test $repo->toNodesList() for null as parameter
* Test $repo->toNodesList() for null as parameter.
*/
public function testTypeToNodesListtRoot() : void
public function testTypeToNodesListtRoot(): void
{
//List all root nodes and their children
$nodes = $this->service->typeToNodesList(AttachmentType::class);
@ -65,7 +63,7 @@ class NodesListBuilderTest extends WebTestCase
$this->assertEquals('Node 3', $nodes[6]->getName());
}
public function testTypeToNodesListElement() : void
public function testTypeToNodesListElement(): void
{
//List all nodes that are children to Node 1
$node1 = $this->em->find(AttachmentType::class, 1);

View file

@ -24,10 +24,8 @@ namespace App\Tests\Services\Trees;
use App\Entity\Attachments\AttachmentType;
use App\Entity\Parts\Category;
use App\Helpers\Trees\TreeViewNode;
use App\Services\AmountFormatter;
use App\Services\Trees\TreeViewGenerator;
use Doctrine\ORM\EntityManagerInterface;
use PHPUnit\Framework\TestCase;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
/**
@ -41,7 +39,7 @@ class TreeViewGeneratorTest extends WebTestCase
protected $service;
protected $em;
public function setUp() : void
public function setUp(): void
{
parent::setUp(); // TODO: Change the autogenerated stub