mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-12-27 13:29:32 +00:00
Applied rector suggestions
This commit is contained in:
parent
4106bcef5f
commit
20f32c7f12
170 changed files with 808 additions and 761 deletions
|
|
@ -69,7 +69,7 @@ class AttachmentPathResolverTest extends WebTestCase
|
|||
$this->assertNull($this->service->parameterToAbsolutePath('/./this/one/too'));
|
||||
}
|
||||
|
||||
public function placeholderDataProvider(): array
|
||||
public function placeholderDataProvider(): \Iterator
|
||||
{
|
||||
//We need to do initialization (again), as dataprovider is called before setUp()
|
||||
self::bootKernel();
|
||||
|
|
@ -77,28 +77,28 @@ class AttachmentPathResolverTest extends WebTestCase
|
|||
$this->projectDir = str_replace('\\', '/', $this->projectDir_orig);
|
||||
$this->media_path = $this->projectDir.'/public/media';
|
||||
$this->footprint_path = $this->projectDir.'/public/img/footprints';
|
||||
|
||||
return [
|
||||
['%FOOTPRINTS%/test/test.jpg', $this->footprint_path.'/test/test.jpg'],
|
||||
['%FOOTPRINTS%/test/', $this->footprint_path.'/test/'],
|
||||
['%MEDIA%/test', $this->media_path.'/test'],
|
||||
['%MEDIA%', $this->media_path],
|
||||
['%FOOTPRINTS%', $this->footprint_path],
|
||||
//Footprints 3D are disabled
|
||||
['%FOOTPRINTS_3D%', null],
|
||||
//Check that invalid pathes return null
|
||||
['/no/placeholder', null],
|
||||
['%INVALID_PLACEHOLDER%', null],
|
||||
['%FOOTPRINTS/test/', null], //Malformed placeholder
|
||||
['/wrong/%FOOTRPINTS%/', null], //Placeholder not at beginning
|
||||
['%FOOTPRINTS%/%MEDIA%', null], //No more than one placholder
|
||||
['%FOOTPRINTS%/%FOOTPRINTS%', null],
|
||||
['%FOOTPRINTS%/../../etc/passwd', null],
|
||||
['%FOOTPRINTS%/0\..\test', null],
|
||||
];
|
||||
yield ['%FOOTPRINTS%/test/test.jpg', $this->footprint_path.'/test/test.jpg'];
|
||||
yield ['%FOOTPRINTS%/test/', $this->footprint_path.'/test/'];
|
||||
yield ['%MEDIA%/test', $this->media_path.'/test'];
|
||||
yield ['%MEDIA%', $this->media_path];
|
||||
yield ['%FOOTPRINTS%', $this->footprint_path];
|
||||
//Footprints 3D are disabled
|
||||
yield ['%FOOTPRINTS_3D%', null];
|
||||
//Check that invalid pathes return null
|
||||
yield ['/no/placeholder', null];
|
||||
yield ['%INVALID_PLACEHOLDER%', null];
|
||||
yield ['%FOOTPRINTS/test/', null];
|
||||
//Malformed placeholder
|
||||
yield ['/wrong/%FOOTRPINTS%/', null];
|
||||
//Placeholder not at beginning
|
||||
yield ['%FOOTPRINTS%/%MEDIA%', null];
|
||||
//No more than one placholder
|
||||
yield ['%FOOTPRINTS%/%FOOTPRINTS%', null];
|
||||
yield ['%FOOTPRINTS%/../../etc/passwd', null];
|
||||
yield ['%FOOTPRINTS%/0\..\test', null];
|
||||
}
|
||||
|
||||
public function realPathDataProvider(): array
|
||||
public function realPathDataProvider(): \Iterator
|
||||
{
|
||||
//We need to do initialization (again), as dataprovider is called before setUp()
|
||||
self::bootKernel();
|
||||
|
|
@ -106,20 +106,17 @@ class AttachmentPathResolverTest extends WebTestCase
|
|||
$this->projectDir = str_replace('\\', '/', $this->projectDir_orig);
|
||||
$this->media_path = $this->projectDir.'/public/media';
|
||||
$this->footprint_path = $this->projectDir.'/public/img/footprints';
|
||||
|
||||
return [
|
||||
[$this->media_path.'/test/img.jpg', '%MEDIA%/test/img.jpg'],
|
||||
[$this->media_path.'/test/img.jpg', '%BASE%/data/media/test/img.jpg', true],
|
||||
[$this->footprint_path.'/foo.jpg', '%FOOTPRINTS%/foo.jpg'],
|
||||
[$this->footprint_path.'/foo.jpg', '%FOOTPRINTS%/foo.jpg', true],
|
||||
//Every kind of absolute path, that is not based with our placeholder dirs must be invald
|
||||
['/etc/passwd', null],
|
||||
['C:\\not\\existing.txt', null],
|
||||
//More than one placeholder is not allowed
|
||||
[$this->footprint_path.'/test/'.$this->footprint_path, null],
|
||||
//Path must begin with path
|
||||
['/not/root'.$this->footprint_path, null],
|
||||
];
|
||||
yield [$this->media_path.'/test/img.jpg', '%MEDIA%/test/img.jpg'];
|
||||
yield [$this->media_path.'/test/img.jpg', '%BASE%/data/media/test/img.jpg', true];
|
||||
yield [$this->footprint_path.'/foo.jpg', '%FOOTPRINTS%/foo.jpg'];
|
||||
yield [$this->footprint_path.'/foo.jpg', '%FOOTPRINTS%/foo.jpg', true];
|
||||
//Every kind of absolute path, that is not based with our placeholder dirs must be invald
|
||||
yield ['/etc/passwd', null];
|
||||
yield ['C:\\not\\existing.txt', null];
|
||||
//More than one placeholder is not allowed
|
||||
yield [$this->footprint_path.'/test/'.$this->footprint_path, null];
|
||||
//Path must begin with path
|
||||
yield ['/not/root'.$this->footprint_path, null];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -35,56 +35,52 @@ class FileTypeFilterToolsTest extends WebTestCase
|
|||
self::$service = self::getContainer()->get(FileTypeFilterTools::class);
|
||||
}
|
||||
|
||||
public function validateDataProvider(): array
|
||||
public function validateDataProvider(): \Iterator
|
||||
{
|
||||
return [
|
||||
['', true], //Empty string is valid
|
||||
['.jpeg,.png, .gif', true], //Only extensions are valid
|
||||
['image/*, video/*, .mp4, video/x-msvideo, application/vnd.amazon.ebook', true],
|
||||
['application/vnd.amazon.ebook, audio/opus', true],
|
||||
|
||||
['*.notvalid, .png', false], //No stars in extension
|
||||
['test.png', false], //No full filename
|
||||
['application/*', false], //Only certain placeholders are allowed
|
||||
['.png;.png,.jpg', false], //Wrong separator
|
||||
['.png .jpg .gif', false],
|
||||
];
|
||||
yield ['', true];
|
||||
//Empty string is valid
|
||||
yield ['.jpeg,.png, .gif', true];
|
||||
//Only extensions are valid
|
||||
yield ['image/*, video/*, .mp4, video/x-msvideo, application/vnd.amazon.ebook', true];
|
||||
yield ['application/vnd.amazon.ebook, audio/opus', true];
|
||||
yield ['*.notvalid, .png', false];
|
||||
//No stars in extension
|
||||
yield ['test.png', false];
|
||||
//No full filename
|
||||
yield ['application/*', false];
|
||||
//Only certain placeholders are allowed
|
||||
yield ['.png;.png,.jpg', false];
|
||||
//Wrong separator
|
||||
yield ['.png .jpg .gif', false];
|
||||
}
|
||||
|
||||
public function normalizeDataProvider(): array
|
||||
public function normalizeDataProvider(): \Iterator
|
||||
{
|
||||
return [
|
||||
['', ''],
|
||||
['.jpeg,.png,.gif', '.jpeg,.png,.gif'],
|
||||
['.jpeg, .png, .gif,', '.jpeg,.png,.gif'],
|
||||
['jpg, *.gif', '.jpg,.gif'],
|
||||
['video, image/', 'video/*,image/*'],
|
||||
['video/*', 'video/*'],
|
||||
['video/x-msvideo,.jpeg', 'video/x-msvideo,.jpeg'],
|
||||
['.video', '.video'],
|
||||
//Remove duplicate entries
|
||||
['png, .gif, .png,', '.png,.gif'],
|
||||
];
|
||||
yield ['', ''];
|
||||
yield ['.jpeg,.png,.gif', '.jpeg,.png,.gif'];
|
||||
yield ['.jpeg, .png, .gif,', '.jpeg,.png,.gif'];
|
||||
yield ['jpg, *.gif', '.jpg,.gif'];
|
||||
yield ['video, image/', 'video/*,image/*'];
|
||||
yield ['video/*', 'video/*'];
|
||||
yield ['video/x-msvideo,.jpeg', 'video/x-msvideo,.jpeg'];
|
||||
yield ['.video', '.video'];
|
||||
//Remove duplicate entries
|
||||
yield ['png, .gif, .png,', '.png,.gif'];
|
||||
}
|
||||
|
||||
public function extensionAllowedDataProvider(): array
|
||||
public function extensionAllowedDataProvider(): \Iterator
|
||||
{
|
||||
return [
|
||||
['', 'txt', true],
|
||||
['', 'everything_should_match', true],
|
||||
|
||||
['.jpg,.png', 'jpg', true],
|
||||
['.jpg,.png', 'png', true],
|
||||
['.jpg,.png', 'txt', false],
|
||||
|
||||
['image/*', 'jpeg', true],
|
||||
['image/*', 'png', true],
|
||||
['image/*', 'txt', false],
|
||||
|
||||
['application/pdf,.txt', 'pdf', true],
|
||||
['application/pdf,.txt', 'txt', true],
|
||||
['application/pdf,.txt', 'jpg', false],
|
||||
];
|
||||
yield ['', 'txt', true];
|
||||
yield ['', 'everything_should_match', true];
|
||||
yield ['.jpg,.png', 'jpg', true];
|
||||
yield ['.jpg,.png', 'png', true];
|
||||
yield ['.jpg,.png', 'txt', false];
|
||||
yield ['image/*', 'jpeg', true];
|
||||
yield ['image/*', 'png', true];
|
||||
yield ['image/*', 'txt', false];
|
||||
yield ['application/pdf,.txt', 'pdf', true];
|
||||
yield ['application/pdf,.txt', 'txt', true];
|
||||
yield ['application/pdf,.txt', 'jpg', false];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue