diff --git a/src/Entity/PriceInformations/Pricedetail.php b/src/Entity/PriceInformations/Pricedetail.php index ce719b11..be5d4276 100644 --- a/src/Entity/PriceInformations/Pricedetail.php +++ b/src/Entity/PriceInformations/Pricedetail.php @@ -280,6 +280,7 @@ class Pricedetail extends DBElement * quantity to 100. The single price (20$/100 = 0.2$) will be calculated automatically. * * @param float $new_price_related_quantity the price related quantity + * @return $this */ public function setPriceRelatedQuantity(float $new_price_related_quantity): self { diff --git a/tests/ApplicationAvailabilityFunctionalTest.php b/tests/ApplicationAvailabilityFunctionalTest.php index 321b9db2..6d61a9f6 100644 --- a/tests/ApplicationAvailabilityFunctionalTest.php +++ b/tests/ApplicationAvailabilityFunctionalTest.php @@ -1,4 +1,7 @@ 'test', ]); - if (false == $read) { + if (false === $read) { $this->expectException(AccessDeniedException::class); } @@ -67,8 +70,8 @@ abstract class AbstractAdminControllerTest extends WebTestCase //Test read/list access by access /new overview page $crawler = $client->request('GET', static::$base_path.'/new'); $this->assertFalse($client->getResponse()->isRedirect()); - $this->assertEquals($read, $client->getResponse()->isSuccessful(), 'Controller was not successful!'); - $this->assertEquals($read, !$client->getResponse()->isForbidden(), 'Permission Checking not working!'); + $this->assertSame($read, $client->getResponse()->isSuccessful(), 'Controller was not successful!'); + $this->assertSame($read, ! $client->getResponse()->isForbidden(), 'Permission Checking not working!'); } /** @@ -76,7 +79,7 @@ abstract class AbstractAdminControllerTest extends WebTestCase * @group slow * Tests if it possible to access an specific entity. Checks if permissions are working. */ - public function testReadEntity(string $user, bool $read) + public function testReadEntity(string $user, bool $read): void { //Test read access $client = static::createClient([], [ @@ -85,15 +88,15 @@ abstract class AbstractAdminControllerTest extends WebTestCase ]); $client->catchExceptions(false); - if (false == $read) { + if (false === $read) { $this->expectException(AccessDeniedException::class); } //Test read/list access by access /new overview page $crawler = $client->request('GET', static::$base_path.'/1'); $this->assertFalse($client->getResponse()->isRedirect()); - $this->assertEquals($read, $client->getResponse()->isSuccessful(), 'Controller was not successful!'); - $this->assertEquals($read, !$client->getResponse()->isForbidden(), 'Permission Checking not working!'); + $this->assertSame($read, $client->getResponse()->isSuccessful(), 'Controller was not successful!'); + $this->assertSame($read, ! $client->getResponse()->isForbidden(), 'Permission Checking not working!'); } public function deleteDataProvider() @@ -112,7 +115,7 @@ abstract class AbstractAdminControllerTest extends WebTestCase * @group slow * @dataProvider deleteDataProvider */ - public function testDeleteEntity(string $user, bool $delete) + public function testDeleteEntity(string $user, bool $delete): void { //Test read access $client = static::createClient([], [ @@ -121,7 +124,7 @@ abstract class AbstractAdminControllerTest extends WebTestCase ]); $client->catchExceptions(false); - if (false == $delete) { + if (false === $delete) { $this->expectException(AccessDeniedException::class); } @@ -129,7 +132,7 @@ abstract class AbstractAdminControllerTest extends WebTestCase $crawler = $client->request('DELETE', static::$base_path.'/7'); //Page is redirected to '/new', when delete was successful - $this->assertEquals($delete, $client->getResponse()->isRedirect(static::$base_path.'/new')); - $this->assertEquals($delete, !$client->getResponse()->isForbidden(), 'Permission Checking not working!'); + $this->assertSame($delete, $client->getResponse()->isRedirect(static::$base_path.'/new')); + $this->assertSame($delete, ! $client->getResponse()->isForbidden(), 'Permission Checking not working!'); } } diff --git a/tests/Controller/AdminPages/AttachmentTypeControllerTest.php b/tests/Controller/AdminPages/AttachmentTypeControllerTest.php index 952211a6..8739c475 100644 --- a/tests/Controller/AdminPages/AttachmentTypeControllerTest.php +++ b/tests/Controller/AdminPages/AttachmentTypeControllerTest.php @@ -1,4 +1,7 @@ client = static::createClient([], [ 'PHP_AUTH_USER' => 'user', @@ -66,15 +69,15 @@ class RedirectControllerTest extends WebTestCase * @dataProvider urlMatchDataProvider * @group slow */ - public function testUrlMatch($url, $expect_redirect) + public function testUrlMatch($url, $expect_redirect): void { //$client = static::createClient(); $this->client->request('GET', $url); $response = $this->client->getResponse(); if ($expect_redirect) { - $this->assertEquals(302, $response->getStatusCode()); + $this->assertSame(302, $response->getStatusCode()); } - $this->assertEquals($expect_redirect, $response->isRedirect()); + $this->assertSame($expect_redirect, $response->isRedirect()); } public function urlAddLocaleDataProvider() @@ -103,7 +106,7 @@ class RedirectControllerTest extends WebTestCase * @param $input_path * @param $redirect_path */ - public function testAddLocale($user_locale, $input_path, $redirect_path) + public function testAddLocale($user_locale, $input_path, $redirect_path): void { //Redirect path is absolute $redirect_path = 'http://localhost'.$redirect_path; @@ -116,6 +119,6 @@ class RedirectControllerTest extends WebTestCase $this->client->followRedirects(false); $this->client->request('GET', $input_path); - $this->assertEquals($redirect_path, $this->client->getResponse()->headers->get('Location')); + $this->assertSame($redirect_path, $this->client->getResponse()->headers->get('Location')); } } diff --git a/tests/Entity/Attachments/AttachmentTest.php b/tests/Entity/Attachments/AttachmentTest.php index b39e1f62..1fd2ec98 100644 --- a/tests/Entity/Attachments/AttachmentTest.php +++ b/tests/Entity/Attachments/AttachmentTest.php @@ -1,4 +1,7 @@ setElement($element); - $this->assertEquals($element, $attachment->getElement()); + $this->assertSame($element, $attachment->getElement()); } /** @@ -141,11 +144,11 @@ class AttachmentTest extends TestCase /** * @dataProvider externalDataProvider */ - public function testIsExternal($path, $expected) + public function testIsExternal($path, $expected): void { $attachment = new PartAttachment(); $this->setProtectedProperty($attachment, 'path', $path); - $this->assertEquals($expected, $attachment->isExternal()); + $this->assertSame($expected, $attachment->isExternal()); } public function extensionDataProvider() @@ -167,12 +170,12 @@ class AttachmentTest extends TestCase /** * @dataProvider extensionDataProvider */ - public function testGetExtension($path, $originalFilename, $expected) + public function testGetExtension($path, $originalFilename, $expected): void { $attachment = new PartAttachment(); $this->setProtectedProperty($attachment, 'path', $path); $this->setProtectedProperty($attachment, 'original_filename', $originalFilename); - $this->assertEquals($expected, $attachment->getExtension()); + $this->assertSame($expected, $attachment->getExtension()); } public function pictureDataProvider() @@ -192,11 +195,11 @@ class AttachmentTest extends TestCase /** * @dataProvider pictureDataProvider */ - public function testIsPicture($path, $expected) + public function testIsPicture($path, $expected): void { $attachment = new PartAttachment(); $this->setProtectedProperty($attachment, 'path', $path); - $this->assertEquals($expected, $attachment->isPicture()); + $this->assertSame($expected, $attachment->isPicture()); } public function builtinDataProvider() @@ -214,11 +217,11 @@ class AttachmentTest extends TestCase /** * @dataProvider builtinDataProvider */ - public function testIsBuiltIn($path, $expected) + public function testIsBuiltIn($path, $expected): void { $attachment = new PartAttachment(); $this->setProtectedProperty($attachment, 'path', $path); - $this->assertEquals($expected, $attachment->isBuiltIn()); + $this->assertSame($expected, $attachment->isBuiltIn()); } public function hostDataProvider() @@ -233,11 +236,11 @@ class AttachmentTest extends TestCase /** * @dataProvider hostDataProvider */ - public function testGetHost($path, $expected) + public function testGetHost($path, $expected): void { $attachment = new PartAttachment(); $this->setProtectedProperty($attachment, 'path', $path); - $this->assertEquals($expected, $attachment->getHost()); + $this->assertSame($expected, $attachment->getHost()); } public function filenameProvider() @@ -252,15 +255,15 @@ class AttachmentTest extends TestCase /** * @dataProvider filenameProvider */ - public function testGetFilename($path, $original_filename, $expected) + public function testGetFilename($path, $original_filename, $expected): void { $attachment = new PartAttachment(); $this->setProtectedProperty($attachment, 'path', $path); $this->setProtectedProperty($attachment, 'original_filename', $original_filename); - $this->assertEquals($expected, $attachment->getFilename()); + $this->assertSame($expected, $attachment->getFilename()); } - public function testIsURL() + public function testIsURL(): void { $url = '%MEDIA%/test.txt'; $this->assertFalse(Attachment::isURL($url)); @@ -279,10 +282,8 @@ class AttachmentTest extends TestCase * @param object $object - instance in which protected value is being modified * @param string $property - property on instance being modified * @param mixed $value - new value of the property being modified - * - * @return void */ - public function setProtectedProperty($object, $property, $value) + public function setProtectedProperty($object, $property, $value): void { $reflection = new ReflectionClass($object); $reflection_property = $reflection->getProperty($property); diff --git a/tests/Entity/Attachments/AttachmentTypeTest.php b/tests/Entity/Attachments/AttachmentTypeTest.php index 1754cb3f..13911ced 100644 --- a/tests/Entity/Attachments/AttachmentTypeTest.php +++ b/tests/Entity/Attachments/AttachmentTypeTest.php @@ -1,4 +1,7 @@ assertInstanceOf(Collection::class, $attachment_type->getAttachmentsForType()); diff --git a/tests/Entity/Parts/PartLotTest.php b/tests/Entity/Parts/PartLotTest.php index 84fe5f62..d5ed40c8 100644 --- a/tests/Entity/Parts/PartLotTest.php +++ b/tests/Entity/Parts/PartLotTest.php @@ -1,4 +1,7 @@ assertNull($lot->isExpired(), 'Lot must be return null when no Expiration date is set!'); diff --git a/tests/Entity/Parts/PartTest.php b/tests/Entity/Parts/PartTest.php index 6842ee3b..c3f7d1cf 100644 --- a/tests/Entity/Parts/PartTest.php +++ b/tests/Entity/Parts/PartTest.php @@ -1,4 +1,7 @@ assertInstanceOf(Collection::class, $part->getPartLots()); @@ -38,33 +41,33 @@ class PartTest extends TestCase //Add element $lot = new PartLot(); $part->addPartLot($lot); - $this->assertEquals($part, $lot->getPart()); - $this->assertEquals(1, $part->getPartLots()->count()); + $this->assertSame($part, $lot->getPart()); + $this->assertSame(1, $part->getPartLots()->count()); //Remove element $part->removePartLot($lot); $this->assertTrue($part->getPartLots()->isEmpty()); } - public function testGetSetMinamount() + public function testGetSetMinamount(): void { $part = new Part(); $measurement_unit = new MeasurementUnit(); //Without an set measurement unit the part must return an int $part->setMinAmount(1.345); - $this->assertEquals(1, $part->getMinAmount()); + $this->assertSame(1.0, $part->getMinAmount()); //If an non int-based unit is assigned, an float is returned $part->setPartUnit($measurement_unit); - $this->assertEquals(1.345, $part->getMinAmount()); + $this->assertSame(1.345, $part->getMinAmount()); //If an int-based unit is assigned an int is returned $measurement_unit->setIsInteger(true); - $this->assertEquals(1, $part->getMinAmount()); + $this->assertSame(1.0, $part->getMinAmount()); } - public function testUseFloatAmount() + public function testUseFloatAmount(): void { $part = new Part(); $measurement_unit = new MeasurementUnit(); @@ -79,13 +82,13 @@ class PartTest extends TestCase $this->assertFalse($part->useFloatAmount()); } - public function testGetAmountSum() + public function testGetAmountSum(): void { $part = new Part(); $measurement_unit = new MeasurementUnit(); $datetime = new \DateTime(); - $this->assertEquals(0, $part->getAmountSum()); + $this->assertSame(0.0, $part->getAmountSum()); $part->addPartLot((new PartLot())->setAmount(3.141)); $part->addPartLot((new PartLot())->setAmount(10.0)); @@ -96,15 +99,15 @@ class PartTest extends TestCase ->setExpirationDate($datetime->setTimestamp(strtotime('now -1 hour'))) ); - $this->assertEquals(13, $part->getAmountSum()); + $this->assertSame(13.0, $part->getAmountSum()); $part->setPartUnit($measurement_unit); - $this->assertEquals(13.141, $part->getAmountSum()); + $this->assertSame(13.141, $part->getAmountSum()); //1 billion part lot $part->addPartLot((new PartLot())->setAmount(1000000000)); - $this->assertEquals(1000000013.141, $part->getAmountSum()); + $this->assertSame(1000000013.141, $part->getAmountSum()); $measurement_unit->setIsInteger(true); - $this->assertEquals(1000000013, $part->getAmountSum()); + $this->assertSame(1000000013.0, $part->getAmountSum()); } } diff --git a/tests/Entity/PriceSystem/CurrencyTest.php b/tests/Entity/PriceSystem/CurrencyTest.php index 46540581..81b65c60 100644 --- a/tests/Entity/PriceSystem/CurrencyTest.php +++ b/tests/Entity/PriceSystem/CurrencyTest.php @@ -1,4 +1,7 @@ assertNull($currency->getInverseExchangeRate()); $currency->setExchangeRate('1.45643'); - $this->assertEquals('0.68661', $currency->getInverseExchangeRate()); + $this->assertSame('0.68661', $currency->getInverseExchangeRate()); } } diff --git a/tests/Entity/PriceSystem/OrderdetailTest.php b/tests/Entity/PriceSystem/OrderdetailTest.php index d9ae8666..0e46553a 100644 --- a/tests/Entity/PriceSystem/OrderdetailTest.php +++ b/tests/Entity/PriceSystem/OrderdetailTest.php @@ -1,4 +1,7 @@ assertInstanceOf(Collection::class, $orderdetail->getPricedetails()); @@ -36,15 +39,15 @@ class OrderdetailTest extends TestCase $pricedetail = new Pricedetail(); $orderdetail->addPricedetail($pricedetail); - $this->assertEquals($orderdetail, $pricedetail->getOrderdetail()); - $this->assertEquals(1, $orderdetail->getPricedetails()->count()); + $this->assertSame($orderdetail, $pricedetail->getOrderdetail()); + $this->assertSame(1, $orderdetail->getPricedetails()->count()); //After removal of the pricedetail, the orderdetail must be empty again $orderdetail->removePricedetail($pricedetail); $this->assertTrue($orderdetail->getPricedetails()->isEmpty()); } - public function testFindPriceForQty() + public function testFindPriceForQty(): void { $price0 = (new Pricedetail())->setMinDiscountQuantity(0.23); $price1 = (new Pricedetail())->setMinDiscountQuantity(1); @@ -54,10 +57,10 @@ class OrderdetailTest extends TestCase $this->assertNull($orderdetail->findPriceForQty(0)); $this->assertNull($orderdetail->findPriceForQty(0.1)); - $this->assertEquals($price0, $orderdetail->findPriceForQty(0.5)); - $this->assertEquals($price1, $orderdetail->findPriceForQty(1)); - $this->assertEquals($price1, $orderdetail->findPriceForQty(1.5)); - $this->assertEquals($price5, $orderdetail->findPriceForQty(5.3)); - $this->assertEquals($price5, $orderdetail->findPriceForQty(10000)); + $this->assertSame($price0, $orderdetail->findPriceForQty(0.5)); + $this->assertSame($price1, $orderdetail->findPriceForQty(1)); + $this->assertSame($price1, $orderdetail->findPriceForQty(1.5)); + $this->assertSame($price5, $orderdetail->findPriceForQty(5.3)); + $this->assertSame($price5, $orderdetail->findPriceForQty(10000)); } } diff --git a/tests/Entity/PriceSystem/PricedetailTest.php b/tests/Entity/PriceSystem/PricedetailTest.php index 860fc48a..954448fe 100644 --- a/tests/Entity/PriceSystem/PricedetailTest.php +++ b/tests/Entity/PriceSystem/PricedetailTest.php @@ -1,4 +1,7 @@ setPrice('100.234'); - $this->assertEquals('100.23400', $pricedetail->getPricePerUnit()); + $this->assertSame('100.23400', $pricedetail->getPricePerUnit()); - $pricedetail->setPriceRelatedQuantity('2.3'); - $this->assertEquals('43.58000', $pricedetail->getPricePerUnit()); - $this->assertEquals('139.45600', $pricedetail->getPricePerUnit('3.2')); + $pricedetail->setPriceRelatedQuantity(2.3); + $this->assertSame('43.58000', $pricedetail->getPricePerUnit()); + $this->assertSame('139.45600', $pricedetail->getPricePerUnit('3.2')); $pricedetail->setPrice('10000000.2345'); //Ten million $pricedetail->setPriceRelatedQuantity(1.234e9); //100 billion - $this->assertEquals('0.00810', $pricedetail->getPricePerUnit()); + $this->assertSame('0.00810', $pricedetail->getPricePerUnit()); } - public function testGetPriceRelatedQuantity() + public function testGetPriceRelatedQuantity(): void { $pricedetail = new Pricedetail(); $part = $this->createMock(Part::class); @@ -58,21 +61,21 @@ class PricedetailTest extends TestCase $orderdetail2->method('getPart')->willReturn($part2); //By default a price detail returns 1 - $this->assertEquals(1, $pricedetail->getPriceRelatedQuantity()); + $this->assertSame(1.0, $pricedetail->getPriceRelatedQuantity()); $pricedetail->setOrderdetail($orderdetail); $pricedetail->setPriceRelatedQuantity(10.23); - $this->assertEquals(10, $pricedetail->getPriceRelatedQuantity()); + $this->assertSame(10.0, $pricedetail->getPriceRelatedQuantity()); //Price related quantity must not be zero! $pricedetail->setPriceRelatedQuantity(0.23); - $this->assertEquals(1, $pricedetail->getPriceRelatedQuantity()); + $this->assertSame(1.0, $pricedetail->getPriceRelatedQuantity()); //With an part that has an float amount unit, also values like 0.23 can be returned $pricedetail->setOrderdetail($orderdetail2); - $this->assertEquals(0.23, $pricedetail->getPriceRelatedQuantity()); + $this->assertSame(0.23, $pricedetail->getPriceRelatedQuantity()); } - public function testGetMinDiscountQuantity() + public function testGetMinDiscountQuantity(): void { $pricedetail = new Pricedetail(); $part = $this->createMock(Part::class); @@ -86,17 +89,17 @@ class PricedetailTest extends TestCase $orderdetail2->method('getPart')->willReturn($part2); //By default a price detail returns 1 - $this->assertEquals(1, $pricedetail->getMinDiscountQuantity()); + $this->assertSame(1.0, $pricedetail->getMinDiscountQuantity()); $pricedetail->setOrderdetail($orderdetail); $pricedetail->setMinDiscountQuantity(10.23); - $this->assertEquals(10, $pricedetail->getMinDiscountQuantity()); + $this->assertSame(10.0, $pricedetail->getMinDiscountQuantity()); //Price related quantity must not be zero! $pricedetail->setMinDiscountQuantity(0.23); - $this->assertEquals(1, $pricedetail->getMinDiscountQuantity()); + $this->assertSame(1.0, $pricedetail->getMinDiscountQuantity()); //With an part that has an float amount unit, also values like 0.23 can be returned $pricedetail->setOrderdetail($orderdetail2); - $this->assertEquals(0.23, $pricedetail->getMinDiscountQuantity()); + $this->assertSame(0.23, $pricedetail->getMinDiscountQuantity()); } } diff --git a/tests/Entity/StructuralDBElementTest.php b/tests/Entity/StructuralDBElementTest.php index bc431627..3125e3c9 100644 --- a/tests/Entity/StructuralDBElementTest.php +++ b/tests/Entity/StructuralDBElementTest.php @@ -1,4 +1,7 @@ child1_2->setName('child1_2')->setParent($this->child1); } - public function testIsRoot() + public function testIsRoot(): void { $this->assertTrue($this->root->isRoot()); $this->assertFalse($this->child1->isRoot()); $this->assertFalse($this->child1_2->isRoot()); } - public function testIsChildOf() + public function testIsChildOf(): void { //Root must not be the child of any other node $this->assertFalse($this->root->isChildOf($this->child1)); @@ -79,14 +82,14 @@ class StructuralDBElementTest extends TestCase $this->assertTrue($this->child1_2->isChildOf($this->root)); } - public function testChildOfDifferentClasses() + public function testChildOfDifferentClasses(): void { $this->expectException(\InvalidArgumentException::class); $category = new Category(); $this->root->isChildOf($category); } - public function testChildOfExtendedClass() + public function testChildOfExtendedClass(): void { //Doctrine extends the entities for proxy classes so the isChildOf mus also work for inheritance types $inheritance = new class() extends AttachmentType { @@ -96,25 +99,25 @@ class StructuralDBElementTest extends TestCase $this->assertFalse($this->root->isChildOf($inheritance)); } - public function testGetLevel() + public function testGetLevel(): void { - $this->assertEquals(0, $this->root->getLevel()); - $this->assertEquals(1, $this->child1->getLevel()); + $this->assertSame(0, $this->root->getLevel()); + $this->assertSame(1, $this->child1->getLevel()); $this->assertSame(1, $this->child2->getLevel()); $this->assertSame(2, $this->child1_2->getLevel()); $this->assertSame(2, $this->child1_1->getLevel()); } - public function testGetFullPath() + public function testGetFullPath(): void { $this->assertSame('root/child1/child1_1', $this->child1_1->getFullPath('/')); $this->assertSame('root#child2', $this->child2->getFullPath('#')); } - public function testGetPathArray() + public function testGetPathArray(): void { - $this->assertEquals([$this->root, $this->child1, $this->child1_1], $this->child1_1->getPathArray()); - $this->assertEquals([$this->root, $this->child1], $this->child1->getPathArray()); - $this->assertEquals([$this->root], $this->root->getPathArray()); + $this->assertSame([$this->root, $this->child1, $this->child1_1], $this->child1_1->getPathArray()); + $this->assertSame([$this->root, $this->child1], $this->child1->getPathArray()); + $this->assertSame([$this->root], $this->root->getPathArray()); } } diff --git a/tests/Entity/UserSystem/PermissionsEmbedTest.php b/tests/Entity/UserSystem/PermissionsEmbedTest.php index ef7c7be7..fa7b308d 100644 --- a/tests/Entity/UserSystem/PermissionsEmbedTest.php +++ b/tests/Entity/UserSystem/PermissionsEmbedTest.php @@ -1,4 +1,7 @@ null @@ -71,7 +74,7 @@ class PermissionsEmbedTest extends TestCase $this->assertNull($embed->getPermissionValue(PermissionsEmbed::PARTS, 6)); } - public function testGetBitValue() + public function testGetBitValue(): void { $embed = new PermissionsEmbed(); @@ -83,14 +86,14 @@ class PermissionsEmbedTest extends TestCase $property->setValue($embed, 0b11011000); // 11 01 10 00 //Test if function is working correctly - $this->assertEquals(PermissionsEmbed::INHERIT, $embed->getBitValue(PermissionsEmbed::PARTS, 0)); - $this->assertEquals(PermissionsEmbed::DISALLOW, $embed->getBitValue(PermissionsEmbed::PARTS, 2)); - $this->assertEquals(PermissionsEmbed::ALLOW, $embed->getBitValue(PermissionsEmbed::PARTS, 4)); + $this->assertSame(PermissionsEmbed::INHERIT, $embed->getBitValue(PermissionsEmbed::PARTS, 0)); + $this->assertSame(PermissionsEmbed::DISALLOW, $embed->getBitValue(PermissionsEmbed::PARTS, 2)); + $this->assertSame(PermissionsEmbed::ALLOW, $embed->getBitValue(PermissionsEmbed::PARTS, 4)); // 11 is reserved, but it should be also treat as INHERIT. - $this->assertEquals(0b11, $embed->getBitValue(PermissionsEmbed::PARTS, 6)); + $this->assertSame(0b11, $embed->getBitValue(PermissionsEmbed::PARTS, 6)); } - public function testInvalidPermissionName() + public function testInvalidPermissionName(): void { $embed = new PermissionsEmbed(); //When encoutering an unknown permission name the class must throw an exception @@ -98,7 +101,7 @@ class PermissionsEmbedTest extends TestCase $embed->getPermissionValue('invalid', 0); } - public function testInvalidBit1() + public function testInvalidBit1(): void { $embed = new PermissionsEmbed(); //When encoutering an negative bit the class must throw an exception @@ -106,7 +109,7 @@ class PermissionsEmbedTest extends TestCase $embed->getPermissionValue('parts', -1); } - public function testInvalidBit2() + public function testInvalidBit2(): void { $embed = new PermissionsEmbed(); //When encoutering an odd bit number it must throw an error. @@ -114,7 +117,7 @@ class PermissionsEmbedTest extends TestCase $embed->getPermissionValue('parts', 1); } - public function testInvalidBit3() + public function testInvalidBit3(): void { $embed = new PermissionsEmbed(); //When encoutering an too high bit number it must throw an error. @@ -145,33 +148,33 @@ class PermissionsEmbedTest extends TestCase /** * @dataProvider getStatesBINARY */ - public function testsetBitValue($value) + public function testTestsetBitValue($value): void { $embed = new PermissionsEmbed(); //Check if it returns itself, for chaining. - $this->assertEquals($embed, $embed->setBitValue(PermissionsEmbed::PARTS, 0, $value)); - $this->assertEquals($value, $embed->getBitValue(PermissionsEmbed::PARTS, 0)); + $this->assertSame($embed, $embed->setBitValue(PermissionsEmbed::PARTS, 0, $value)); + $this->assertSame($value, $embed->getBitValue(PermissionsEmbed::PARTS, 0)); } /** * @dataProvider getStatesBOOL */ - public function testSetPermissionValue($value) + public function testSetPermissionValue($value): void { $embed = new PermissionsEmbed(); //Check if it returns itself, for chaining. - $this->assertEquals($embed, $embed->setPermissionValue(PermissionsEmbed::PARTS, 0, $value)); - $this->assertEquals($value, $embed->getPermissionValue(PermissionsEmbed::PARTS, 0)); + $this->assertSame($embed, $embed->setPermissionValue(PermissionsEmbed::PARTS, 0, $value)); + $this->assertSame($value, $embed->getPermissionValue(PermissionsEmbed::PARTS, 0)); } - public function testSetRawPermissionValue() + public function testSetRawPermissionValue(): void { $embed = new PermissionsEmbed(); $embed->setRawPermissionValue(PermissionsEmbed::PARTS, 10); - $this->assertEquals(10, $embed->getRawPermissionValue(PermissionsEmbed::PARTS)); + $this->assertSame(10, $embed->getRawPermissionValue(PermissionsEmbed::PARTS)); } - public function testSetRawPermissionValues() + public function testSetRawPermissionValues(): void { $embed = new PermissionsEmbed(); $embed->setRawPermissionValues([ @@ -180,9 +183,9 @@ class PermissionsEmbedTest extends TestCase PermissionsEmbed::CATEGORIES => 1304, ]); - $this->assertEquals(0, $embed->getRawPermissionValue(PermissionsEmbed::PARTS)); - $this->assertEquals(100, $embed->getRawPermissionValue(PermissionsEmbed::USERS)); - $this->assertEquals(1304, $embed->getRawPermissionValue(PermissionsEmbed::CATEGORIES)); + $this->assertSame(0, $embed->getRawPermissionValue(PermissionsEmbed::PARTS)); + $this->assertSame(100, $embed->getRawPermissionValue(PermissionsEmbed::USERS)); + $this->assertSame(1304, $embed->getRawPermissionValue(PermissionsEmbed::CATEGORIES)); //Test second method to pass perm names and values $embed->setRawPermissionValues( @@ -190,8 +193,8 @@ class PermissionsEmbedTest extends TestCase [0, 100, 1304] ); - $this->assertEquals(0, $embed->getRawPermissionValue(PermissionsEmbed::PARTS)); - $this->assertEquals(100, $embed->getRawPermissionValue(PermissionsEmbed::USERS)); - $this->assertEquals(1304, $embed->getRawPermissionValue(PermissionsEmbed::CATEGORIES)); + $this->assertSame(0, $embed->getRawPermissionValue(PermissionsEmbed::PARTS)); + $this->assertSame(100, $embed->getRawPermissionValue(PermissionsEmbed::USERS)); + $this->assertSame(1304, $embed->getRawPermissionValue(PermissionsEmbed::CATEGORIES)); } } diff --git a/tests/Entity/UserSystem/UserTest.php b/tests/Entity/UserSystem/UserTest.php index 6a4a43ff..e82f2840 100644 --- a/tests/Entity/UserSystem/UserTest.php +++ b/tests/Entity/UserSystem/UserTest.php @@ -1,4 +1,7 @@ setName('username'); $user->setFirstName('John'); $user->setLastName('Doe'); - $this->assertEquals('John Doe', $user->getFullName(false)); - $this->assertEquals('John Doe (username)', $user->getFullName(true)); + $this->assertSame('John Doe', $user->getFullName(false)); + $this->assertSame('John Doe (username)', $user->getFullName(true)); } public function googleAuthenticatorEnabledDataProvider(): array @@ -50,7 +53,7 @@ class UserTest extends TestCase /** * @dataProvider googleAuthenticatorEnabledDataProvider */ - public function testIsGoogleAuthenticatorEnabled(?string $secret, bool $expected) + public function testIsGoogleAuthenticatorEnabled(?string $secret, bool $expected): void { $user = new User(); $user->setGoogleAuthenticatorSecret($secret); @@ -60,14 +63,14 @@ class UserTest extends TestCase /** * @requires PHPUnit 8 */ - public function testSetBackupCodes() + public function testSetBackupCodes(): void { $user = new User(); $codes = ['test', 'invalid', 'test']; $user->setBackupCodes($codes); // Backup Codes generation date must be changed! $this->assertEqualsWithDelta(new \DateTime(), $user->getBackupCodesGenerationDate(), 0.1); - $this->assertEquals($codes, $user->getBackupCodes()); + $this->assertSame($codes, $user->getBackupCodes()); //Test what happens if we delete the backup keys $user->setBackupCodes([]); @@ -75,7 +78,7 @@ class UserTest extends TestCase $this->assertNull($user->getBackupCodesGenerationDate()); } - public function testIsBackupCode() + public function testIsBackupCode(): void { $user = new User(); $codes = ['aaaa', 'bbbb', 'cccc', 'dddd']; @@ -88,7 +91,7 @@ class UserTest extends TestCase $this->assertFalse($user->isBackupCode('zzzz')); } - public function testInvalidateBackupCode() + public function testInvalidateBackupCode(): void { $user = new User(); $codes = ['aaaa', 'bbbb', 'cccc', 'dddd']; @@ -106,7 +109,7 @@ class UserTest extends TestCase $user->invalidateBackupCode('zzzz'); } - public function testInvalidateTrustedDeviceTokens() + public function testInvalidateTrustedDeviceTokens(): void { $user = new User(); $old_value = $user->getTrustedTokenVersion(); @@ -115,7 +118,7 @@ class UserTest extends TestCase $this->assertGreaterThan($old_value, $user->getTrustedTokenVersion()); } - public function testIsU2fEnabled() + public function testIsU2fEnabled(): void { $user = new User(); $user->addU2FKey(new U2FKey()); diff --git a/tests/EventSubscriber/PasswordChangeNeededSubscriberTest.php b/tests/EventSubscriber/PasswordChangeNeededSubscriberTest.php index f152f617..e1e15199 100644 --- a/tests/EventSubscriber/PasswordChangeNeededSubscriberTest.php +++ b/tests/EventSubscriber/PasswordChangeNeededSubscriberTest.php @@ -1,4 +1,7 @@ converter = new BBCodeToMarkdownConverter(); } @@ -52,8 +55,8 @@ class BBCodeToMarkdownConverterTest extends TestCase * @param $bbcode * @param $expected */ - public function testConvert($bbcode, $expected) + public function testConvert($bbcode, $expected): void { - $this->assertEquals($expected, $this->converter->convert($bbcode)); + $this->assertSame($expected, $this->converter->convert($bbcode)); } } diff --git a/tests/Helpers/TreeViewNodeTest.php b/tests/Helpers/TreeViewNodeTest.php index e0115878..89f3bcce 100644 --- a/tests/Helpers/TreeViewNodeTest.php +++ b/tests/Helpers/TreeViewNodeTest.php @@ -1,4 +1,7 @@ node2 = new TreeViewNode('Name', 'www.foo.bar', $sub_nodes); } - public function testConstructor() + public function testConstructor(): void { //A node without things should have null values on its properties: $this->assertNull($this->node1->getHref()); $this->assertNull($this->node1->getNodes()); - $this->assertEquals('Name', $this->node1->getText()); + $this->assertSame('Name', $this->node1->getText()); //The second node must have the given things as properties. - $this->assertEquals('Name', $this->node2->getText()); - $this->assertEquals('www.foo.bar', $this->node2->getHref()); + $this->assertSame('Name', $this->node2->getText()); + $this->assertSame('www.foo.bar', $this->node2->getHref()); $this->assertNotEmpty($this->node2->getNodes()); } } diff --git a/tests/Repository/NamedDBElementRepositoryTest.php b/tests/Repository/NamedDBElementRepositoryTest.php index 66414b4d..0487c9d1 100644 --- a/tests/Repository/NamedDBElementRepositoryTest.php +++ b/tests/Repository/NamedDBElementRepositoryTest.php @@ -1,4 +1,7 @@ repo = $this->entityManager->getRepository(User::class); } - public function testGetGenericNodeTree() + public function testGetGenericNodeTree(): void { $tree = $this->repo->getGenericNodeTree(); $this->assertIsArray($tree); $this->assertContainsOnlyInstancesOf(TreeViewNode::class, $tree); $this->assertCount(4, $tree); - $this->assertEquals('admin', $tree[0]->getText()); + $this->assertSame('admin', $tree[0]->getText()); $this->assertEmpty($tree[0]->getNodes()); } } diff --git a/tests/Repository/StructuralDBElementRepositoryTest.php b/tests/Repository/StructuralDBElementRepositoryTest.php index f568ee65..e3157abc 100644 --- a/tests/Repository/StructuralDBElementRepositoryTest.php +++ b/tests/Repository/StructuralDBElementRepositoryTest.php @@ -1,4 +1,7 @@ assertContainsOnlyInstancesOf(AttachmentType::class, $root_nodes); //Asc sorting - $this->assertEquals('Node 1', $root_nodes[0]->getName()); - $this->assertEquals('Node 2', $root_nodes[1]->getName()); - $this->assertEquals('Node 3', $root_nodes[2]->getName()); + $this->assertSame('Node 1', $root_nodes[0]->getName()); + $this->assertSame('Node 2', $root_nodes[1]->getName()); + $this->assertSame('Node 3', $root_nodes[2]->getName()); } public function testGetGenericTree(): void @@ -74,16 +74,16 @@ class StructuralDBElementRepositoryTest extends WebTestCase $this->assertEmpty($tree[1]->getNodes()[0]->getNodes()); //Check text - $this->assertEquals('Node 1', $tree[0]->getText()); - $this->assertEquals('Node 2', $tree[1]->getText()); - $this->assertEquals('Node 3', $tree[2]->getText()); - $this->assertEquals('Node 1.1', $tree[0]->getNodes()[0]->getText()); - $this->assertEquals('Node 1.1.1', $tree[0]->getNodes()[0]->getNodes()[0]->getText()); + $this->assertSame('Node 1', $tree[0]->getText()); + $this->assertSame('Node 2', $tree[1]->getText()); + $this->assertSame('Node 3', $tree[2]->getText()); + $this->assertSame('Node 1.1', $tree[0]->getNodes()[0]->getText()); + $this->assertSame('Node 1.1.1', $tree[0]->getNodes()[0]->getNodes()[0]->getText()); //Check that IDs were set correctly - $this->assertEquals(1, $tree[0]->getId()); - $this->assertEquals(2, $tree[1]->getId()); - $this->assertEquals(7, $tree[0]->getNodes()[0]->getNodes()[0]->getId()); + $this->assertSame(1, $tree[0]->getId()); + $this->assertSame(2, $tree[1]->getId()); + $this->assertSame(7, $tree[0]->getNodes()[0]->getNodes()[0]->getId()); } /** @@ -96,13 +96,13 @@ class StructuralDBElementRepositoryTest extends WebTestCase $this->assertCount(7, $nodes); $this->assertContainsOnlyInstancesOf(AttachmentType::class, $nodes); - $this->assertEquals('Node 1', $nodes[0]->getName()); - $this->assertEquals('Node 1.1', $nodes[1]->getName()); - $this->assertEquals('Node 1.1.1', $nodes[2]->getName()); - $this->assertEquals('Node 1.2', $nodes[3]->getName()); - $this->assertEquals('Node 2', $nodes[4]->getName()); - $this->assertEquals('Node 2.1', $nodes[5]->getName()); - $this->assertEquals('Node 3', $nodes[6]->getName()); + $this->assertSame('Node 1', $nodes[0]->getName()); + $this->assertSame('Node 1.1', $nodes[1]->getName()); + $this->assertSame('Node 1.1.1', $nodes[2]->getName()); + $this->assertSame('Node 1.2', $nodes[3]->getName()); + $this->assertSame('Node 2', $nodes[4]->getName()); + $this->assertSame('Node 2.1', $nodes[5]->getName()); + $this->assertSame('Node 3', $nodes[6]->getName()); } public function testToNodesListElement(): void @@ -113,8 +113,8 @@ class StructuralDBElementRepositoryTest extends WebTestCase $this->assertCount(3, $nodes); $this->assertContainsOnlyInstancesOf(AttachmentType::class, $nodes); - $this->assertEquals('Node 1.1', $nodes[0]->getName()); - $this->assertEquals('Node 1.1.1', $nodes[1]->getName()); - $this->assertEquals('Node 1.2', $nodes[2]->getName()); + $this->assertSame('Node 1.1', $nodes[0]->getName()); + $this->assertSame('Node 1.1.1', $nodes[1]->getName()); + $this->assertSame('Node 1.2', $nodes[2]->getName()); } } diff --git a/tests/Security/Annotations/ColumnSecurityTest.php b/tests/Security/Annotations/ColumnSecurityTest.php index 51d7959d..113e80ab 100644 --- a/tests/Security/Annotations/ColumnSecurityTest.php +++ b/tests/Security/Annotations/ColumnSecurityTest.php @@ -1,4 +1,7 @@ assertEquals('read', $annotation->getReadOperationName(), 'A new annotation must return read'); + $this->assertSame('read', $annotation->getReadOperationName(), 'A new annotation must return read'); $annotation->read = 'overwritten'; - $this->assertEquals('overwritten', $annotation->getReadOperationName()); + $this->assertSame('overwritten', $annotation->getReadOperationName()); $annotation->prefix = 'prefix'; - $this->assertEquals('prefix.overwritten', $annotation->getReadOperationName()); + $this->assertSame('prefix.overwritten', $annotation->getReadOperationName()); } - public function testGetEditOperation() + public function testGetEditOperation(): void { $annotation = new ColumnSecurity(); - $this->assertEquals('edit', $annotation->getEditOperationName(), 'A new annotation must return read'); + $this->assertSame('edit', $annotation->getEditOperationName(), 'A new annotation must return read'); $annotation->edit = 'overwritten'; - $this->assertEquals('overwritten', $annotation->getEditOperationName()); + $this->assertSame('overwritten', $annotation->getEditOperationName()); $annotation->prefix = 'prefix'; - $this->assertEquals('prefix.overwritten', $annotation->getEditOperationName()); + $this->assertSame('prefix.overwritten', $annotation->getEditOperationName()); } public function placeholderScalarDataProvider(): array @@ -66,18 +69,18 @@ class ColumnSecurityTest extends TestCase * * @param $expected_value */ - public function testGetPlaceholderScalar(string $type, $expected_value) + public function testGetPlaceholderScalar(string $type, $expected_value): void { $annotation = new ColumnSecurity(); $annotation->type = $type; - $this->assertEquals($expected_value, $annotation->getPlaceholder()); + $this->assertSame($expected_value, $annotation->getPlaceholder()); } - public function testGetPlaceholderSpecifiedValue() + public function testGetPlaceholderSpecifiedValue(): void { $annotation = new ColumnSecurity(); $annotation->placeholder = 3434; - $this->assertEquals(3434, $annotation->getPlaceholder()); + $this->assertSame(3434, $annotation->getPlaceholder()); $annotation->placeholder = [323]; $this->assertCount(1, $annotation->getPlaceholder()); @@ -85,10 +88,10 @@ class ColumnSecurityTest extends TestCase //If a placeholder is specified we allow every type $annotation->type = 'type2'; $annotation->placeholder = 'invalid'; - $this->assertEquals('invalid', $annotation->getPlaceholder()); + $this->assertSame('invalid', $annotation->getPlaceholder()); } - public function testGetPlaceholderDBElement() + public function testGetPlaceholderDBElement(): void { $annotation = new ColumnSecurity(); $annotation->type = AttachmentType::class; @@ -96,11 +99,11 @@ class ColumnSecurityTest extends TestCase /** @var AttachmentType $placeholder */ $placeholder = $annotation->getPlaceholder(); $this->assertInstanceOf(AttachmentType::class, $placeholder); - $this->assertEquals('???', $placeholder->getName()); + $this->assertSame('???', $placeholder->getName()); $annotation->placeholder = 'test'; $placeholder = $annotation->getPlaceholder(); $this->assertInstanceOf(AttachmentType::class, $placeholder); - $this->assertEquals('test', $placeholder->getName()); + $this->assertSame('test', $placeholder->getName()); } } diff --git a/tests/Security/UserCheckerTest.php b/tests/Security/UserCheckerTest.php index edb17f74..9835467c 100644 --- a/tests/Security/UserCheckerTest.php +++ b/tests/Security/UserCheckerTest.php @@ -1,4 +1,7 @@ service = new UserChecker(); } - public function testThrowDisabledException() + public function testThrowDisabledException(): void { $user = new User(); $user->setDisabled(false); diff --git a/tests/Services/AmountFormatterTest.php b/tests/Services/AmountFormatterTest.php index c1aa6826..85dee35f 100644 --- a/tests/Services/AmountFormatterTest.php +++ b/tests/Services/AmountFormatterTest.php @@ -1,4 +1,7 @@ service = self::$container->get(AmountFormatter::class); } - public function testFormatWithoutUnit() + public function testFormatWithoutUnit(): void { - $this->assertEquals('2', $this->service->format(2.321)); - $this->assertEquals('1002', $this->service->format(1002.356)); - $this->assertEquals('1000454', $this->service->format(1000454.0)); - $this->assertEquals('0', $this->service->format(0.01)); - $this->assertEquals('0', $this->service->format(0)); + $this->assertSame('2', $this->service->format(2.321)); + $this->assertSame('1002', $this->service->format(1002.356)); + $this->assertSame('1000454', $this->service->format(1000454.0)); + $this->assertSame('0', $this->service->format(0.01)); + $this->assertSame('0', $this->service->format(0)); } - public function testInvalidInput() + public function testInvalidInput(): void { $this->expectException(\InvalidArgumentException::class); $this->service->format('test'); } - public function testFormatUnitWithoutSI() + public function testFormatUnitWithoutSI(): void { $meters = new MeasurementUnit(); $meters->setIsInteger(false)->setUseSIPrefix(false)->setUnit('m'); - $this->assertEquals('0.32 m', $this->service->format(0.3245, $meters)); - $this->assertEquals('10003.56 m', $this->service->format(10003.556, $meters)); - $this->assertEquals('0.00 m', $this->service->format(0.0004, $meters)); + $this->assertSame('0.32 m', $this->service->format(0.3245, $meters)); + $this->assertSame('10003.56 m', $this->service->format(10003.556, $meters)); + $this->assertSame('0.00 m', $this->service->format(0.0004, $meters)); } - public function testFormatUnitWithSI() + public function testFormatUnitWithSI(): void { $meters = new MeasurementUnit(); $meters->setIsInteger(false)->setUseSIPrefix(true)->setUnit('m'); - $this->assertEquals('0.32 m', $this->service->format(0.3245, $meters)); - $this->assertEquals('12.32 m', $this->service->format(12.323, $meters)); - $this->assertEquals('120.32 km', $this->service->format(120320.45, $meters)); + $this->assertSame('0.32 m', $this->service->format(0.3245, $meters)); + $this->assertSame('12.32 m', $this->service->format(12.323, $meters)); + $this->assertSame('120.32 km', $this->service->format(120320.45, $meters)); - $this->assertEquals('0.32 mm', $this->service->format(0.00032, $meters)); + $this->assertSame('0.32 mm', $this->service->format(0.00032, $meters)); } - public function testFormatMoreDigits() + public function testFormatMoreDigits(): void { - $this->assertEquals('12.12345', $this->service->format(12.1234532, null, ['is_integer' => false, 'decimals' => 5])); - $this->assertEquals('12.1', $this->service->format(12.1234532, null, ['is_integer' => false, 'decimals' => 1])); + $this->assertSame('12.12345', $this->service->format(12.1234532, null, ['is_integer' => false, 'decimals' => 5])); + $this->assertSame('12.1', $this->service->format(12.1234532, null, ['is_integer' => false, 'decimals' => 1])); } - public function testFormatOptionsOverride() + public function testFormatOptionsOverride(): void { $meters = new MeasurementUnit(); $meters->setIsInteger(false)->setUseSIPrefix(true)->setUnit('m'); - $this->assertEquals('12.32', $this->service->format(12.323, $meters, ['unit' => ''])); - $this->assertEquals('12002.32 m', $this->service->format(12002.32, $meters, ['show_prefix' => false])); - $this->assertEquals('123 m', $this->service->format(123.234, $meters, ['is_integer' => true])); + $this->assertSame('12.32', $this->service->format(12.323, $meters, ['unit' => ''])); + $this->assertSame('12002.32 m', $this->service->format(12002.32, $meters, ['show_prefix' => false])); + $this->assertSame('123 m', $this->service->format(123.234, $meters, ['is_integer' => true])); } } diff --git a/tests/Services/Attachments/AttachmentPathResolverTest.php b/tests/Services/Attachments/AttachmentPathResolverTest.php index 19093550..26be1b19 100644 --- a/tests/Services/Attachments/AttachmentPathResolverTest.php +++ b/tests/Services/Attachments/AttachmentPathResolverTest.php @@ -1,4 +1,7 @@ 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)); } } diff --git a/tests/Services/Attachments/AttachmentURLGeneratorTest.php b/tests/Services/Attachments/AttachmentURLGeneratorTest.php index cf094c72..f6db98c5 100644 --- a/tests/Services/Attachments/AttachmentURLGeneratorTest.php +++ b/tests/Services/Attachments/AttachmentURLGeneratorTest.php @@ -1,4 +1,7 @@ assertEquals($expected, static::$service->absolutePathToAssetPath($input, static::PUBLIC_DIR)); + $this->assertSame($expected, static::$service->absolutePathToAssetPath($input, static::PUBLIC_DIR)); } } diff --git a/tests/Services/Attachments/BuiltinAttachmentsFinderTest.php b/tests/Services/Attachments/BuiltinAttachmentsFinderTest.php index 43329df7..04b37d74 100644 --- a/tests/Services/Attachments/BuiltinAttachmentsFinderTest.php +++ b/tests/Services/Attachments/BuiltinAttachmentsFinderTest.php @@ -1,4 +1,7 @@ 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:'); } } diff --git a/tests/Services/Attachments/FileTypeFilterToolsTest.php b/tests/Services/Attachments/FileTypeFilterToolsTest.php index b4d940f4..99d3e6d6 100644 --- a/tests/Services/Attachments/FileTypeFilterToolsTest.php +++ b/tests/Services/Attachments/FileTypeFilterToolsTest.php @@ -1,4 +1,7 @@ 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)); } } diff --git a/tests/Services/ElementTypeNameGeneratorTest.php b/tests/Services/ElementTypeNameGeneratorTest.php index 1fdf4aff..eb55e2cb 100644 --- a/tests/Services/ElementTypeNameGeneratorTest.php +++ b/tests/Services/ElementTypeNameGeneratorTest.php @@ -1,4 +1,7 @@ service = self::$container->get(ElementTypeNameGenerator::class); } - public function testGetLocalizedTypeNameCombination() + public function testGetLocalizedTypeNameCombination(): void { //We only test in english - $this->assertEquals('Part', $this->service->getLocalizedTypeLabel(new Part())); - $this->assertEquals('Category', $this->service->getLocalizedTypeLabel(new Category())); + $this->assertSame('Part', $this->service->getLocalizedTypeLabel(new Part())); + $this->assertSame('Category', $this->service->getLocalizedTypeLabel(new Category())); //Test inheritance - $this->assertEquals('Attachment', $this->service->getLocalizedTypeLabel(new PartAttachment())); + $this->assertSame('Attachment', $this->service->getLocalizedTypeLabel(new PartAttachment())); //Test exception for unknpwn type $this->expectException(EntityNotSupportedException::class); @@ -66,14 +69,14 @@ class ElementTypeNameGeneratorTest extends WebTestCase }); } - public function testGetTypeNameCombination() + public function testGetTypeNameCombination(): void { $part = new Part(); $part->setName('TestassertEquals('Part: Testservice->getTypeNameCombination($part, false)); + $this->assertSame('Part: Testservice->getTypeNameCombination($part, false)); - $this->assertEquals('Part: Test<Part', $this->service->getTypeNameCombination($part, true)); + $this->assertSame('Part: Test<Part', $this->service->getTypeNameCombination($part, true)); //Test exception $this->expectException(EntityNotSupportedException::class); diff --git a/tests/Services/EntityImporterTest.php b/tests/Services/EntityImporterTest.php index 76d16284..9fabcaaa 100644 --- a/tests/Services/EntityImporterTest.php +++ b/tests/Services/EntityImporterTest.php @@ -1,4 +1,7 @@ service = self::$container->get(EntityImporter::class); } - public function testMassCreationResults() + public function testMassCreationResults(): void { $errors = []; $results = $this->service->massCreation('', AttachmentType::class, null, $errors); @@ -60,26 +63,26 @@ class EntityImporterTest extends WebTestCase //Check type $this->assertInstanceOf(AttachmentType::class, $results[0]); //Check names - $this->assertEquals('Test 1', $results[0]->getName()); - $this->assertEquals('Test 2', $results[1]->getName()); + $this->assertSame('Test 1', $results[0]->getName()); + $this->assertSame('Test 2', $results[1]->getName()); //Check parent $this->assertNull($results[0]->getMasterPictureAttachment()); $parent = new AttachmentType(); $results = $this->service->massCreation($lines, AttachmentType::class, $parent, $errors); $this->assertCount(3, $results); - $this->assertEquals($parent, $results[0]->getParent()); + $this->assertSame($parent, $results[0]->getParent()); } - public function testMassCreationErrors() + public function testMassCreationErrors(): void { $errors = []; //Node 1 and Node 2 are created in datafixtures, so their attemp to create them again must fail. $lines = "Test 1 \n Node 1 \n Node 2"; $results = $this->service->massCreation($lines, AttachmentType::class, null, $errors); $this->assertCount(1, $results); - $this->assertEquals('Test 1', $results[0]->getName()); + $this->assertSame('Test 1', $results[0]->getName()); $this->assertCount(2, $errors); - $this->assertEquals('Node 1', $errors[0]['entity']->getName()); + $this->assertSame('Node 1', $errors[0]['entity']->getName()); } } diff --git a/tests/Services/FAIconGeneratorTest.php b/tests/Services/FAIconGeneratorTest.php index 0d1498b3..0d935a0f 100644 --- a/tests/Services/FAIconGeneratorTest.php +++ b/tests/Services/FAIconGeneratorTest.php @@ -1,4 +1,7 @@ assertEquals($expected, $this->service->fileExtensionToFAType($ext)); + $this->assertSame($expected, $this->service->fileExtensionToFAType($ext)); } - public function testGenerateIconHTML() + public function testGenerateIconHTML(): void { - $this->assertEquals('', $this->service->generateIconHTML('fa-file')); - $this->assertEquals('', $this->service->generateIconHTML('fa-file', 'far')); - $this->assertEquals('', $this->service->generateIconHTML('fa-file', 'far', 'fa-2x')); + $this->assertSame('', $this->service->generateIconHTML('fa-file')); + $this->assertSame('', $this->service->generateIconHTML('fa-file', 'far')); + $this->assertSame('', $this->service->generateIconHTML('fa-file', 'far', 'fa-2x')); } } diff --git a/tests/Services/PermissionResolverTest.php b/tests/Services/PermissionResolverTest.php index 055e054c..09461d82 100644 --- a/tests/Services/PermissionResolverTest.php +++ b/tests/Services/PermissionResolverTest.php @@ -1,4 +1,7 @@ service->listOperationsForPermission($perm_name); @@ -127,20 +130,20 @@ class PermissionResolverTest extends WebTestCase $this->assertNotEmpty($arr); } - public function testInvalidListOperationsForPermission() + public function testInvalidListOperationsForPermission(): void { $this->expectException(\InvalidArgumentException::class); //Must throw an exception $this->service->listOperationsForPermission('invalid'); } - public function testisValidPermission() + public function testisValidPermission(): void { $this->assertTrue($this->service->isValidPermission('parts')); $this->assertFalse($this->service->isValidPermission('invalid')); } - public function testIsValidOperation() + public function testIsValidOperation(): void { $this->assertTrue($this->service->isValidOperation('parts', 'read')); @@ -150,7 +153,7 @@ class PermissionResolverTest extends WebTestCase $this->assertFalse($this->service->isValidOperation('invalid', 'invalid')); } - public function testDontInherit() + public function testDontInherit(): void { //Check with faked object $this->assertTrue($this->service->dontInherit($this->user, 'parts', 'read')); @@ -167,7 +170,7 @@ class PermissionResolverTest extends WebTestCase $this->assertNull($this->service->dontInherit($this->user_withoutGroup, 'parts', 'delete')); } - public function testInherit() + public function testInherit(): void { //Not inherited values should be same as dont inherit: $this->assertTrue($this->service->inherit($this->user, 'parts', 'read')); diff --git a/tests/Services/PricedetailHelperTest.php b/tests/Services/PricedetailHelperTest.php index 7fc40074..8beb7af5 100644 --- a/tests/Services/PricedetailHelperTest.php +++ b/tests/Services/PricedetailHelperTest.php @@ -1,4 +1,7 @@ assertEquals($expected_result, $this->service->getMaxDiscountAmount($part), $message); + $this->assertSame($expected_result, $this->service->getMaxDiscountAmount($part), $message); } } diff --git a/tests/Services/SIFormatterTest.php b/tests/Services/SIFormatterTest.php index f75611af..e786808e 100644 --- a/tests/Services/SIFormatterTest.php +++ b/tests/Services/SIFormatterTest.php @@ -1,4 +1,7 @@ service = new SIFormatter(); } - public function testGetMagnitude() + public function testGetMagnitude(): void { //Get an service instance. $this->assertSame(0, $this->service->getMagnitude(7.0)); @@ -61,7 +64,7 @@ class SIFormatterTest extends WebTestCase $this->assertSame(12, $this->service->getMagnitude(9.99e12)); } - public function testgetPrefixByMagnitude() + public function testgetPrefixByMagnitude(): void { $this->assertSame([1, ''], $this->service->getPrefixByMagnitude(2)); @@ -74,10 +77,10 @@ class SIFormatterTest extends WebTestCase $this->assertSame([0.001, 'm'], $this->service->getPrefixByMagnitude(-4)); } - public function testFormat() + public function testFormat(): void { $this->assertSame('2.32 km', $this->service->format(2321, 'm')); - $this->assertEquals('230.45 km', $this->service->format(230450.3, 'm')); + $this->assertSame('230.45 km', $this->service->format(230450.3, 'm')); $this->assertSame('-98.20 mg', $this->service->format(-0.0982, 'g')); $this->assertSame('-0.23 g', $this->service->format(-0.23, 'g')); } diff --git a/tests/Services/TFA/BackupCodeGeneratorTest.php b/tests/Services/TFA/BackupCodeGeneratorTest.php index 753b49d8..87e2320a 100644 --- a/tests/Services/TFA/BackupCodeGeneratorTest.php +++ b/tests/Services/TFA/BackupCodeGeneratorTest.php @@ -1,4 +1,7 @@ expectException(\RuntimeException::class); new BackupCodeGenerator(33, 10); @@ -38,7 +41,7 @@ class BackupCodeGeneratorTest extends TestCase /** * Test if an exception is thrown if you are using a too high code length. */ - public function testLengthLowerLimit() + public function testLengthLowerLimit(): void { $this->expectException(\RuntimeException::class); new BackupCodeGenerator(4, 10); @@ -52,7 +55,7 @@ class BackupCodeGeneratorTest extends TestCase /** * @dataProvider codeLengthDataProvider */ - public function testGenerateSingleCode(int $code_length) + public function testGenerateSingleCode(int $code_length): void { $generator = new BackupCodeGenerator($code_length, 10); $this->assertRegExp("/^([a-f0-9]){{$code_length}}\$/", $generator->generateSingleCode()); @@ -66,7 +69,7 @@ class BackupCodeGeneratorTest extends TestCase /** * @dataProvider codeCountDataProvider */ - public function testGenerateCodeSet(int $code_count) + public function testGenerateCodeSet(int $code_count): void { $generator = new BackupCodeGenerator(8, $code_count); $this->assertCount($code_count, $generator->generateCodeSet()); diff --git a/tests/Services/TFA/BackupCodeManagerTest.php b/tests/Services/TFA/BackupCodeManagerTest.php index 5bef0aa8..8c6ac743 100644 --- a/tests/Services/TFA/BackupCodeManagerTest.php +++ b/tests/Services/TFA/BackupCodeManagerTest.php @@ -1,4 +1,7 @@ service = self::$container->get(BackupCodeManager::class); } - public function testRegenerateBackupCodes() + public function testRegenerateBackupCodes(): void { $user = new User(); $old_codes = ['aaaa', 'bbbb']; $user->setBackupCodes($old_codes); $this->service->regenerateBackupCodes($user); - $this->assertNotEquals($old_codes, $user->getBackupCodes()); + $this->assertNotSame($old_codes, $user->getBackupCodes()); } - public function testEnableBackupCodes() + public function testEnableBackupCodes(): void { $user = new User(); //Check that nothing is changed, if there are already backup codes @@ -55,7 +58,7 @@ class BackupCodeManagerTest extends WebTestCase $old_codes = ['aaaa', 'bbbb']; $user->setBackupCodes($old_codes); $this->service->enableBackupCodes($user); - $this->assertEquals($old_codes, $user->getBackupCodes()); + $this->assertSame($old_codes, $user->getBackupCodes()); //When no old codes are existing, it should generate a set $user->setBackupCodes([]); @@ -63,7 +66,7 @@ class BackupCodeManagerTest extends WebTestCase $this->assertNotEmpty($user->getBackupCodes()); } - public function testDisableBackupCodesIfUnused() + public function testDisableBackupCodesIfUnused(): void { $user = new User(); @@ -77,6 +80,6 @@ class BackupCodeManagerTest extends WebTestCase $user->setGoogleAuthenticatorSecret('jskf'); $this->service->disableBackupCodesIfUnused($user); - $this->assertEquals($codes, $user->getBackupCodes()); + $this->assertSame($codes, $user->getBackupCodes()); } } diff --git a/tests/Services/Trees/NodesListBuilderTest.php b/tests/Services/Trees/NodesListBuilderTest.php index 7266fe1a..37e963e0 100644 --- a/tests/Services/Trees/NodesListBuilderTest.php +++ b/tests/Services/Trees/NodesListBuilderTest.php @@ -1,4 +1,7 @@ service = self::$container->get(NodesListBuilder::class); @@ -54,13 +57,13 @@ class NodesListBuilderTest extends WebTestCase $this->assertCount(7, $nodes); $this->assertContainsOnlyInstancesOf(AttachmentType::class, $nodes); - $this->assertEquals('Node 1', $nodes[0]->getName()); - $this->assertEquals('Node 1.1', $nodes[1]->getName()); - $this->assertEquals('Node 1.1.1', $nodes[2]->getName()); - $this->assertEquals('Node 1.2', $nodes[3]->getName()); - $this->assertEquals('Node 2', $nodes[4]->getName()); - $this->assertEquals('Node 2.1', $nodes[5]->getName()); - $this->assertEquals('Node 3', $nodes[6]->getName()); + $this->assertSame('Node 1', $nodes[0]->getName()); + $this->assertSame('Node 1.1', $nodes[1]->getName()); + $this->assertSame('Node 1.1.1', $nodes[2]->getName()); + $this->assertSame('Node 1.2', $nodes[3]->getName()); + $this->assertSame('Node 2', $nodes[4]->getName()); + $this->assertSame('Node 2.1', $nodes[5]->getName()); + $this->assertSame('Node 3', $nodes[6]->getName()); } public function testTypeToNodesListElement(): void @@ -71,8 +74,8 @@ class NodesListBuilderTest extends WebTestCase $this->assertCount(3, $nodes); $this->assertContainsOnlyInstancesOf(AttachmentType::class, $nodes); - $this->assertEquals('Node 1.1', $nodes[0]->getName()); - $this->assertEquals('Node 1.1.1', $nodes[1]->getName()); - $this->assertEquals('Node 1.2', $nodes[2]->getName()); + $this->assertSame('Node 1.1', $nodes[0]->getName()); + $this->assertSame('Node 1.1.1', $nodes[1]->getName()); + $this->assertSame('Node 1.2', $nodes[2]->getName()); } } diff --git a/tests/Services/Trees/TreeViewGeneratorTest.php b/tests/Services/Trees/TreeViewGeneratorTest.php index 43e57eaf..74c1c521 100644 --- a/tests/Services/Trees/TreeViewGeneratorTest.php +++ b/tests/Services/Trees/TreeViewGeneratorTest.php @@ -1,4 +1,7 @@ em = self::$container->get(EntityManagerInterface::class); } - public function testGetGenericTree() + public function testGetGenericTree(): void { $tree = $this->service->getGenericTree(AttachmentType::class, null); @@ -63,19 +66,19 @@ class TreeViewGeneratorTest extends WebTestCase $this->assertEmpty($tree[1]->getNodes()[0]->getNodes()); //Check text - $this->assertEquals('Node 1', $tree[0]->getText()); - $this->assertEquals('Node 2', $tree[1]->getText()); - $this->assertEquals('Node 3', $tree[2]->getText()); - $this->assertEquals('Node 1.1', $tree[0]->getNodes()[0]->getText()); - $this->assertEquals('Node 1.1.1', $tree[0]->getNodes()[0]->getNodes()[0]->getText()); + $this->assertSame('Node 1', $tree[0]->getText()); + $this->assertSame('Node 2', $tree[1]->getText()); + $this->assertSame('Node 3', $tree[2]->getText()); + $this->assertSame('Node 1.1', $tree[0]->getNodes()[0]->getText()); + $this->assertSame('Node 1.1.1', $tree[0]->getNodes()[0]->getNodes()[0]->getText()); //Check that IDs were set correctly - $this->assertEquals(1, $tree[0]->getId()); - $this->assertEquals(2, $tree[1]->getId()); - $this->assertEquals(7, $tree[0]->getNodes()[0]->getNodes()[0]->getId()); + $this->assertSame(1, $tree[0]->getId()); + $this->assertSame(2, $tree[1]->getId()); + $this->assertSame(7, $tree[0]->getNodes()[0]->getNodes()[0]->getId()); } - public function testGetTreeViewBasic() + public function testGetTreeViewBasic(): void { $tree = $this->service->getTreeView(Category::class); $this->assertIsArray($tree); @@ -86,30 +89,30 @@ class TreeViewGeneratorTest extends WebTestCase $this->assertCount(1, $tree[0]->getNodes()[0]->getNodes()); //Assert that the nodes contain the correct links - $this->assertEquals('/en/category/1/parts', $tree[0]->getHref()); - $this->assertEquals('/en/category/2/parts', $tree[1]->getHref()); - $this->assertEquals('/en/category/7/parts', $tree[0]->getNodes()[0]->getNodes()[0]->getHref()); + $this->assertSame('/en/category/1/parts', $tree[0]->getHref()); + $this->assertSame('/en/category/2/parts', $tree[1]->getHref()); + $this->assertSame('/en/category/7/parts', $tree[0]->getNodes()[0]->getNodes()[0]->getHref()); } - public function testGetTreeViewNewEdit() + public function testGetTreeViewNewEdit(): void { $tree = $this->service->getTreeView(Category::class, null, 'newEdit'); //First element should link to new category $this->assertStringContainsStringIgnoringCase('New', $tree[0]->getText()); - $this->assertEquals('/en/category/new', $tree[0]->getHref()); + $this->assertSame('/en/category/new', $tree[0]->getHref()); //By default the new element node is selected $this->assertTrue($tree[0]->getState()->getSelected()); //Next element is spacing - $this->assertEquals('', $tree[1]->getText()); + $this->assertSame('', $tree[1]->getText()); $this->assertTrue($tree[1]->getState()->getDisabled()); //All other elements should be normal $this->assertCount(5, $tree); } - public function testGetTreeViewSelectedNode() + public function testGetTreeViewSelectedNode(): void { $selected = $this->em->find(Category::class, 2); $tree = $this->service->getTreeView(Category::class, null, 'edit', $selected);