mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 01:25:55 +02:00
Applied code style to tests/
This commit is contained in:
parent
f861de791f
commit
fe0f69f762
44 changed files with 427 additions and 306 deletions
|
@ -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
|
||||
{
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -48,7 +51,7 @@ abstract class AbstractAdminControllerTest extends WebTestCase
|
|||
* @group slow
|
||||
* Tests if you can access the /new part which is used to list all entities. Checks if permissions are working
|
||||
*/
|
||||
public function testListEntries(string $user, bool $read)
|
||||
public function testListEntries(string $user, bool $read): void
|
||||
{
|
||||
static::ensureKernelShutdown();
|
||||
|
||||
|
@ -58,7 +61,7 @@ abstract class AbstractAdminControllerTest extends WebTestCase
|
|||
'PHP_AUTH_PW' => '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!');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -35,7 +38,7 @@ class RedirectControllerTest extends WebTestCase
|
|||
protected $userRepo;
|
||||
protected $client;
|
||||
|
||||
public function setUp(): void
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->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'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -99,7 +102,7 @@ class AttachmentTest extends TestCase
|
|||
|
||||
//This must not throw an exception
|
||||
$attachment->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);
|
||||
|
|
|
@ -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,7 +30,7 @@ use PHPUnit\Framework\TestCase;
|
|||
|
||||
class AttachmentTypeTest extends TestCase
|
||||
{
|
||||
public function testEmptyState()
|
||||
public function testEmptyState(): void
|
||||
{
|
||||
$attachment_type = new AttachmentType();
|
||||
$this->assertInstanceOf(Collection::class, $attachment_type->getAttachmentsForType());
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -26,7 +29,7 @@ use PHPUnit\Framework\TestCase;
|
|||
|
||||
class PartLotTest extends TestCase
|
||||
{
|
||||
public function testIsExpired()
|
||||
public function testIsExpired(): void
|
||||
{
|
||||
$lot = new PartLot();
|
||||
$this->assertNull($lot->isExpired(), 'Lot must be return null when no Expiration date is set!');
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -29,7 +32,7 @@ use PHPUnit\Framework\TestCase;
|
|||
|
||||
class PartTest extends TestCase
|
||||
{
|
||||
public function testAddRemovePartLot()
|
||||
public function testAddRemovePartLot(): void
|
||||
{
|
||||
$part = new Part();
|
||||
$this->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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -26,7 +29,7 @@ use PHPUnit\Framework\TestCase;
|
|||
|
||||
class CurrencyTest extends TestCase
|
||||
{
|
||||
public function testGetInverseExchangeRate()
|
||||
public function testGetInverseExchangeRate(): void
|
||||
{
|
||||
$currency = new Currency();
|
||||
|
||||
|
@ -37,6 +40,6 @@ class CurrencyTest extends TestCase
|
|||
$this->assertNull($currency->getInverseExchangeRate());
|
||||
|
||||
$currency->setExchangeRate('1.45643');
|
||||
$this->assertEquals('0.68661', $currency->getInverseExchangeRate());
|
||||
$this->assertSame('0.68661', $currency->getInverseExchangeRate());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -28,7 +31,7 @@ use PHPUnit\Framework\TestCase;
|
|||
|
||||
class OrderdetailTest extends TestCase
|
||||
{
|
||||
public function testAddRemovePricdetails()
|
||||
public function testAddRemovePricdetails(): void
|
||||
{
|
||||
$orderdetail = new Orderdetail();
|
||||
$this->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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -28,23 +31,23 @@ use PHPUnit\Framework\TestCase;
|
|||
|
||||
class PricedetailTest extends TestCase
|
||||
{
|
||||
public function testGetPricePerUnit()
|
||||
public function testGetPricePerUnit(): void
|
||||
{
|
||||
$pricedetail = new Pricedetail();
|
||||
$pricedetail->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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -39,7 +42,7 @@ class StructuralDBElementTest extends TestCase
|
|||
protected $child1_1;
|
||||
protected $child1_2;
|
||||
|
||||
public function setUp(): void
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp(); // TODO: Change the autogenerated stub
|
||||
|
||||
|
@ -58,14 +61,14 @@ class StructuralDBElementTest extends TestCase
|
|||
$this->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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,7 +30,7 @@ use PHPUnit\Framework\TestCase;
|
|||
|
||||
class PermissionsEmbedTest extends TestCase
|
||||
{
|
||||
public function testGetPermissionValue()
|
||||
public function testGetPermissionValue(): void
|
||||
{
|
||||
$embed = new PermissionsEmbed();
|
||||
//For newly created embedded, all things should be set to inherit => 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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,15 +30,15 @@ use PHPUnit\Framework\TestCase;
|
|||
|
||||
class UserTest extends TestCase
|
||||
{
|
||||
public function testGetFullName()
|
||||
public function testGetFullName(): void
|
||||
{
|
||||
$user = new User();
|
||||
$user->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());
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -29,7 +32,7 @@ use PHPUnit\Framework\TestCase;
|
|||
|
||||
class PasswordChangeNeededSubscriberTest extends TestCase
|
||||
{
|
||||
public function testTFARedirectNeeded()
|
||||
public function testTFARedirectNeeded(): void
|
||||
{
|
||||
$user = new User();
|
||||
$group = new Group();
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -28,7 +31,7 @@ class BBCodeToMarkdownConverterTest extends TestCase
|
|||
{
|
||||
protected $converter;
|
||||
|
||||
public function setUp(): void
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -35,7 +38,7 @@ class TreeViewNodeTest extends TestCase
|
|||
*/
|
||||
protected $node2;
|
||||
|
||||
public function setUp(): void
|
||||
protected function setUp(): void
|
||||
{
|
||||
$sub_nodes = [];
|
||||
$sub_nodes[] = new TreeViewNode('Subnode 1');
|
||||
|
@ -50,16 +53,16 @@ class TreeViewNodeTest extends TestCase
|
|||
$this->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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -35,9 +38,6 @@ class NamedDBElementRepositoryTest extends WebTestCase
|
|||
/** @var StructuralDBElementRepository */
|
||||
private $repo;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
$kernel = self::bootKernel();
|
||||
|
@ -49,14 +49,14 @@ class NamedDBElementRepositoryTest extends WebTestCase
|
|||
$this->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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -35,9 +38,6 @@ class StructuralDBElementRepositoryTest extends WebTestCase
|
|||
/** @var StructuralDBElementRepository */
|
||||
private $repo;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
$kernel = self::bootKernel();
|
||||
|
@ -56,9 +56,9 @@ class StructuralDBElementRepositoryTest extends WebTestCase
|
|||
$this->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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,24 +30,24 @@ use PHPUnit\Framework\TestCase;
|
|||
|
||||
class ColumnSecurityTest extends TestCase
|
||||
{
|
||||
public function testGetReadOperation()
|
||||
public function testGetReadOperation(): void
|
||||
{
|
||||
$annotation = new ColumnSecurity();
|
||||
$this->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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -30,12 +33,12 @@ class UserCheckerTest extends TestCase
|
|||
{
|
||||
protected $service;
|
||||
|
||||
public function setUp(): void
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->service = new UserChecker();
|
||||
}
|
||||
|
||||
public function testThrowDisabledException()
|
||||
public function testThrowDisabledException(): void
|
||||
{
|
||||
$user = new User();
|
||||
$user->setDisabled(false);
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -32,7 +35,7 @@ class AmountFormatterTest extends WebTestCase
|
|||
*/
|
||||
protected $service;
|
||||
|
||||
public function setUp(): void
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp(); // TODO: Change the autogenerated stub
|
||||
|
||||
|
@ -41,56 +44,56 @@ class AmountFormatterTest extends WebTestCase
|
|||
$this->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]));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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:');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -38,7 +41,7 @@ class ElementTypeNameGeneratorTest extends WebTestCase
|
|||
*/
|
||||
protected $service;
|
||||
|
||||
public function setUp(): void
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
|
@ -47,14 +50,14 @@ class ElementTypeNameGeneratorTest extends WebTestCase
|
|||
$this->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('Test<Part');
|
||||
//When the text version is used, dont escape the name
|
||||
$this->assertEquals('Part: Test<Part', $this->service->getTypeNameCombination($part, false));
|
||||
$this->assertSame('Part: Test<Part', $this->service->getTypeNameCombination($part, false));
|
||||
|
||||
$this->assertEquals('<i>Part:</i> Test<Part', $this->service->getTypeNameCombination($part, true));
|
||||
$this->assertSame('<i>Part:</i> Test<Part', $this->service->getTypeNameCombination($part, true));
|
||||
|
||||
//Test exception
|
||||
$this->expectException(EntityNotSupportedException::class);
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -36,7 +39,7 @@ class EntityImporterTest extends WebTestCase
|
|||
*/
|
||||
protected $service;
|
||||
|
||||
public function setUp(): void
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
|
@ -45,7 +48,7 @@ class EntityImporterTest extends WebTestCase
|
|||
$this->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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -31,7 +34,7 @@ class FAIconGeneratorTest extends WebTestCase
|
|||
*/
|
||||
protected $service;
|
||||
|
||||
public function setUp(): void
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp(); // TODO: Change the autogenerated stub
|
||||
|
||||
|
@ -57,15 +60,15 @@ class FAIconGeneratorTest extends WebTestCase
|
|||
/**
|
||||
* @dataProvider fileExtensionDataProvider
|
||||
*/
|
||||
public function testFileExtensionToFAType(string $ext, string $expected)
|
||||
public function testFileExtensionToFAType(string $ext, string $expected): void
|
||||
{
|
||||
$this->assertEquals($expected, $this->service->fileExtensionToFAType($ext));
|
||||
$this->assertSame($expected, $this->service->fileExtensionToFAType($ext));
|
||||
}
|
||||
|
||||
public function testGenerateIconHTML()
|
||||
public function testGenerateIconHTML(): void
|
||||
{
|
||||
$this->assertEquals('<i class="fas fa-file "></i>', $this->service->generateIconHTML('fa-file'));
|
||||
$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'));
|
||||
$this->assertSame('<i class="fas fa-file "></i>', $this->service->generateIconHTML('fa-file'));
|
||||
$this->assertSame('<i class="far fa-file "></i>', $this->service->generateIconHTML('fa-file', 'far'));
|
||||
$this->assertSame('<i class="far fa-file fa-2x"></i>', $this->service->generateIconHTML('fa-file', 'far', 'fa-2x'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -38,7 +41,7 @@ class PermissionResolverTest extends WebTestCase
|
|||
protected $user_withoutGroup;
|
||||
protected $group;
|
||||
|
||||
public function setUp(): void
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp(); // TODO: Change the autogenerated stub
|
||||
|
||||
|
@ -119,7 +122,7 @@ class PermissionResolverTest extends WebTestCase
|
|||
/**
|
||||
* @dataProvider getPermissionNames
|
||||
*/
|
||||
public function testListOperationsForPermission($perm_name)
|
||||
public function testListOperationsForPermission($perm_name): void
|
||||
{
|
||||
$arr = $this->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'));
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -35,7 +38,7 @@ class PricedetailHelperTest extends WebTestCase
|
|||
*/
|
||||
protected $service;
|
||||
|
||||
public function setUp(): void
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
//Get an service instance.
|
||||
|
@ -84,8 +87,8 @@ class PricedetailHelperTest extends WebTestCase
|
|||
/**
|
||||
* @dataProvider maxDiscountAmountDataProvider
|
||||
*/
|
||||
public function testGetMaxDiscountAmount(Part $part, ?float $expected_result, string $message)
|
||||
public function testGetMaxDiscountAmount(Part $part, ?float $expected_result, string $message): void
|
||||
{
|
||||
$this->assertEquals($expected_result, $this->service->getMaxDiscountAmount($part), $message);
|
||||
$this->assertSame($expected_result, $this->service->getMaxDiscountAmount($part), $message);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -31,7 +34,7 @@ class SIFormatterTest extends WebTestCase
|
|||
*/
|
||||
protected $service;
|
||||
|
||||
public function setUp(): void
|
||||
protected function setUp(): void
|
||||
{
|
||||
//Get an service instance.
|
||||
self::bootKernel();
|
||||
|
@ -40,7 +43,7 @@ class SIFormatterTest extends WebTestCase
|
|||
$this->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'));
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -29,7 +32,7 @@ class BackupCodeGeneratorTest extends TestCase
|
|||
/**
|
||||
* Test if an exception is thrown if you are using a too high code length.
|
||||
*/
|
||||
public function testLengthUpperLimit()
|
||||
public function testLengthUpperLimit(): void
|
||||
{
|
||||
$this->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());
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -32,22 +35,22 @@ class BackupCodeManagerTest extends WebTestCase
|
|||
*/
|
||||
protected $service;
|
||||
|
||||
public function setUp(): void
|
||||
protected function setUp(): void
|
||||
{
|
||||
self::bootKernel();
|
||||
$this->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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -37,7 +40,7 @@ class NodesListBuilderTest extends WebTestCase
|
|||
protected $service;
|
||||
protected $em;
|
||||
|
||||
public function setUp(): void
|
||||
protected function setUp(): void
|
||||
{
|
||||
self::bootKernel();
|
||||
$this->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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -39,7 +42,7 @@ class TreeViewGeneratorTest extends WebTestCase
|
|||
protected $service;
|
||||
protected $em;
|
||||
|
||||
public function setUp(): void
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp(); // TODO: Change the autogenerated stub
|
||||
|
||||
|
@ -49,7 +52,7 @@ class TreeViewGeneratorTest extends WebTestCase
|
|||
$this->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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue