Applied code style to tests/

This commit is contained in:
Jan Böhmer 2020-01-05 15:55:16 +01:00
parent f861de791f
commit fe0f69f762
44 changed files with 427 additions and 306 deletions

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -27,6 +30,8 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class AttachmentPathResolverTest extends WebTestCase
{
public static $media_path;
public static $footprint_path;
/**
* @var AmountFormatter
*/
@ -34,9 +39,6 @@ class AttachmentPathResolverTest extends WebTestCase
protected static $projectDir_orig;
protected static $projectDir;
public static $media_path;
public static $footprint_path;
public function __construct($name = null, array $data = [], $dataName = '')
{
parent::__construct($name, $data, $dataName);
@ -57,17 +59,17 @@ class AttachmentPathResolverTest extends WebTestCase
self::$service = self::$container->get(AttachmentPathResolver::class);
}
public function testParameterToAbsolutePath()
public function testParameterToAbsolutePath(): void
{
//If null is passed, null must be returned
$this->assertNull(self::$service->parameterToAbsolutePath(null));
//Absolute path should be returned like they are (we use projectDir here, because we know that this dir exists)
$this->assertEquals(self::$projectDir_orig, self::$service->parameterToAbsolutePath(self::$projectDir));
$this->assertSame(self::$projectDir_orig, self::$service->parameterToAbsolutePath(self::$projectDir));
//Relative pathes should be resolved
$this->assertEquals(self::$projectDir_orig.\DIRECTORY_SEPARATOR.'src', self::$service->parameterToAbsolutePath('src'));
$this->assertEquals(self::$projectDir_orig.\DIRECTORY_SEPARATOR.'src', self::$service->parameterToAbsolutePath('./src'));
$this->assertSame(self::$projectDir_orig.\DIRECTORY_SEPARATOR.'src', self::$service->parameterToAbsolutePath('src'));
$this->assertSame(self::$projectDir_orig.\DIRECTORY_SEPARATOR.'src', self::$service->parameterToAbsolutePath('./src'));
//Invalid pathes should return null
$this->assertNull(self::$service->parameterToAbsolutePath('/this/path/does/not/exist'));
@ -116,16 +118,16 @@ class AttachmentPathResolverTest extends WebTestCase
/**
* @dataProvider placeholderDataProvider
*/
public function testPlaceholderToRealPath($param, $expected)
public function testPlaceholderToRealPath($param, $expected): void
{
$this->assertEquals($expected, self::$service->placeholderToRealPath($param));
$this->assertSame($expected, self::$service->placeholderToRealPath($param));
}
/**
* @dataProvider realPathDataProvider
*/
public function testRealPathToPlaceholder($param, $expected, $old_method = false)
public function testRealPathToPlaceholder($param, $expected, $old_method = false): void
{
$this->assertEquals($expected, self::$service->realPathToPlaceholder($param, $old_method));
$this->assertSame($expected, self::$service->realPathToPlaceholder($param, $old_method));
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -54,8 +57,8 @@ class AttachmentURLGeneratorTest extends WebTestCase
* @param $input
* @param $expected
*/
public function testabsolutePathToAssetPath($input, $expected)
public function testTestabsolutePathToAssetPath($input, $expected): void
{
$this->assertEquals($expected, static::$service->absolutePathToAssetPath($input, static::PUBLIC_DIR));
$this->assertSame($expected, static::$service->absolutePathToAssetPath($input, static::PUBLIC_DIR));
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -60,11 +63,11 @@ class BuiltinAttachmentsFinderTest extends WebTestCase
/**
* @dataProvider dataProvider
*/
public function testFind($keyword, $options, $expected)
public function testFind($keyword, $options, $expected): void
{
$value = static::$service->find($keyword, $options, static::$mock_list);
//$this->assertEquals($expected, static::$service->find($keyword, $options, static::$mock_list));
$this->assertEquals([], array_diff($value, $expected), 'Additional');
$this->assertEquals([], array_diff($expected, $value), 'Missing:');
$this->assertSame([], array_diff($value, $expected), 'Additional');
$this->assertSame([], array_diff($expected, $value), 'Missing:');
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -91,24 +94,24 @@ class FileTypeFilterToolsTest extends WebTestCase
*
* @dataProvider validateDataProvider
*/
public function testValidateFilterString(string $filter, bool $expected)
public function testValidateFilterString(string $filter, bool $expected): void
{
$this->assertEquals($expected, self::$service->validateFilterString($filter));
$this->assertSame($expected, self::$service->validateFilterString($filter));
}
/**
* @dataProvider normalizeDataProvider
*/
public function testNormalizeFilterString(string $filter, string $expected)
public function testNormalizeFilterString(string $filter, string $expected): void
{
$this->assertEquals($expected, self::$service->normalizeFilterString($filter));
$this->assertSame($expected, self::$service->normalizeFilterString($filter));
}
/**
* @dataProvider extensionAllowedDataProvider
*/
public function testIsExtensionAllowed(string $filter, string $extension, bool $expected)
public function testIsExtensionAllowed(string $filter, string $extension, bool $expected): void
{
$this->assertEquals($expected, self::$service->isExtensionAllowed($filter, $extension), $expected);
$this->assertSame($expected, self::$service->isExtensionAllowed($filter, $extension));
}
}