mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-08-03 17:55:03 +02:00
Added an PHP CS fixer config file and applied it to files.
We now use the same the same style as the symfony project, and it allows us to simply fix the style by executing php_cs_fixer fix in the project root.
This commit is contained in:
parent
89258bc102
commit
e557bdedd5
210 changed files with 2099 additions and 2742 deletions
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
|
||||
*
|
||||
|
@ -17,12 +17,10 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*
|
||||
*/
|
||||
|
||||
namespace App\Tests\Entity\Attachments;
|
||||
|
||||
|
||||
use App\Entity\Attachments\Attachment;
|
||||
use App\Entity\Attachments\AttachmentType;
|
||||
use App\Entity\Attachments\AttachmentTypeAttachment;
|
||||
|
@ -50,11 +48,10 @@ use App\Entity\UserSystem\Group;
|
|||
use App\Entity\UserSystem\User;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use ReflectionClass;
|
||||
use Symfony\Component\HttpKernel\HttpCache\Store;
|
||||
|
||||
class AttachmentTest extends TestCase
|
||||
{
|
||||
public function testEmptyState() : void
|
||||
public function testEmptyState(): void
|
||||
{
|
||||
$attachment = new PartAttachment();
|
||||
|
||||
|
@ -73,7 +70,7 @@ class AttachmentTest extends TestCase
|
|||
$this->assertEmpty($attachment->getFilename());
|
||||
}
|
||||
|
||||
public function subClassesDataProvider() : array
|
||||
public function subClassesDataProvider(): array
|
||||
{
|
||||
return [
|
||||
[AttachmentTypeAttachment::class, AttachmentType::class],
|
||||
|
@ -87,16 +84,14 @@ class AttachmentTest extends TestCase
|
|||
[PartAttachment::class, Part::class],
|
||||
[StorelocationAttachment::class, Storelocation::class],
|
||||
[SupplierAttachment::class, Supplier::class],
|
||||
[UserAttachment::class, User::class]
|
||||
[UserAttachment::class, User::class],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider subClassesDataProvider
|
||||
* @param string $attachment_class
|
||||
* @param string $allowed_class
|
||||
*/
|
||||
public function testSetElement(string $attachment_class, string $allowed_class) : void
|
||||
public function testSetElement(string $attachment_class, string $allowed_class): void
|
||||
{
|
||||
/** @var Attachment $attachment */
|
||||
$attachment = new $attachment_class();
|
||||
|
@ -110,16 +105,17 @@ class AttachmentTest extends TestCase
|
|||
/**
|
||||
* Test that all attachment subclasses like PartAttachment or similar returns an exception, when an not allowed
|
||||
* element is passed.
|
||||
*
|
||||
* @dataProvider subClassesDataProvider
|
||||
* @depends testSetElement
|
||||
*/
|
||||
public function testSetElementExceptionOnSubClasses(string $attachment_class, string $allowed_class) : void
|
||||
public function testSetElementExceptionOnSubClasses(string $attachment_class, string $allowed_class): void
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
|
||||
/** @var Attachment $attachment */
|
||||
$attachment = new $attachment_class();
|
||||
if ($allowed_class !== Device::class) {
|
||||
if (Device::class !== $allowed_class) {
|
||||
$element = new Device();
|
||||
} else {
|
||||
$element = new Category();
|
||||
|
@ -138,7 +134,7 @@ class AttachmentTest extends TestCase
|
|||
['%SECURE%/test.txt', false],
|
||||
['%test%/foo/bar.ghp', true],
|
||||
['foo%MEDIA%/foo.jpg', true],
|
||||
['foo%MEDIA%/%BASE%foo.jpg', true]
|
||||
['foo%MEDIA%/%BASE%foo.jpg', true],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -211,7 +207,7 @@ class AttachmentTest extends TestCase
|
|||
['%BASE%/foo/bar.txt', false],
|
||||
['/', false],
|
||||
['https://google.de', false],
|
||||
['%FOOTPRINTS%/foo/bar.txt', true]
|
||||
['%FOOTPRINTS%/foo/bar.txt', true],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -249,7 +245,7 @@ class AttachmentTest extends TestCase
|
|||
return [
|
||||
['%MEDIA%/foo/bar.txt', null, 'bar.txt'],
|
||||
['%MEDIA%/foo/bar.JPeg', 'test.txt', 'test.txt'],
|
||||
['https://www.google.de/test.txt', null, null]
|
||||
['https://www.google.de/test.txt', null, null],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -278,11 +274,11 @@ class AttachmentTest extends TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* Sets a protected property on a given object via reflection
|
||||
* Sets a protected property on a given object via reflection.
|
||||
*
|
||||
* @param object $object - instance in which protected value is being modified
|
||||
* @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
|
||||
* @param mixed $value - new value of the property being modified
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
@ -293,5 +289,4 @@ class AttachmentTest extends TestCase
|
|||
$reflection_property->setAccessible(true);
|
||||
$reflection_property->setValue($object, $value);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
|
||||
*
|
||||
|
@ -17,12 +17,10 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*
|
||||
*/
|
||||
|
||||
namespace App\Tests\Entity\Attachments;
|
||||
|
||||
|
||||
use App\Entity\Attachments\AttachmentType;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
@ -35,4 +33,4 @@ class AttachmentTypeTest extends TestCase
|
|||
$this->assertInstanceOf(Collection::class, $attachment_type->getAttachmentsForType());
|
||||
$this->assertEmpty($attachment_type->getFiletypeFilter());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
|
||||
*
|
||||
|
@ -17,12 +17,10 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*
|
||||
*/
|
||||
|
||||
namespace App\Tests\Entity\Parts;
|
||||
|
||||
|
||||
use App\Entity\Parts\PartLot;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
|
@ -41,4 +39,4 @@ class PartLotTest extends TestCase
|
|||
$lot->setExpirationDate($datetime->setTimestamp(strtotime('now -1 hour')));
|
||||
$this->assertTrue($lot->isExpired(), 'Lot with expiration date in the past must be expired!');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
|
||||
*
|
||||
|
@ -17,12 +17,10 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*
|
||||
*/
|
||||
|
||||
namespace App\Tests\Entity\Parts;
|
||||
|
||||
|
||||
use App\Entity\Parts\MeasurementUnit;
|
||||
use App\Entity\Parts\Part;
|
||||
use App\Entity\Parts\PartLot;
|
||||
|
@ -109,4 +107,4 @@ class PartTest extends TestCase
|
|||
$measurement_unit->setIsInteger(true);
|
||||
$this->assertEquals(1000000013, $part->getAmountSum());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
|
||||
*
|
||||
|
@ -17,12 +17,10 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*
|
||||
*/
|
||||
|
||||
namespace App\Tests\Entity\PriceSystem;
|
||||
|
||||
|
||||
use App\Entity\PriceInformations\Currency;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
|
@ -38,7 +36,7 @@ class CurrencyTest extends TestCase
|
|||
$currency->setExchangeRate('0');
|
||||
$this->assertNull($currency->getInverseExchangeRate());
|
||||
|
||||
$currency->setExchangeRate("1.45643");
|
||||
$this->assertEquals("0.68661", $currency->getInverseExchangeRate());
|
||||
$currency->setExchangeRate('1.45643');
|
||||
$this->assertEquals('0.68661', $currency->getInverseExchangeRate());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
|
||||
*
|
||||
|
@ -17,12 +17,10 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*
|
||||
*/
|
||||
|
||||
namespace App\Tests\Entity\PriceSystem;
|
||||
|
||||
|
||||
use App\Entity\PriceInformations\Orderdetail;
|
||||
use App\Entity\PriceInformations\Pricedetail;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
|
@ -62,4 +60,4 @@ class OrderdetailTest extends TestCase
|
|||
$this->assertEquals($price5, $orderdetail->findPriceForQty(5.3));
|
||||
$this->assertEquals($price5, $orderdetail->findPriceForQty(10000));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
|
||||
*
|
||||
|
@ -17,13 +17,10 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*
|
||||
*/
|
||||
|
||||
namespace App\Tests\Entity\PriceSystem;
|
||||
|
||||
|
||||
use App\Entity\Parts\MeasurementUnit;
|
||||
use App\Entity\Parts\Part;
|
||||
use App\Entity\PriceInformations\Orderdetail;
|
||||
use App\Entity\PriceInformations\Pricedetail;
|
||||
|
@ -42,7 +39,6 @@ class PricedetailTest extends TestCase
|
|||
$this->assertEquals('43.58000', $pricedetail->getPricePerUnit());
|
||||
$this->assertEquals('139.45600', $pricedetail->getPricePerUnit('3.2'));
|
||||
|
||||
|
||||
$pricedetail->setPrice('10000000.2345'); //Ten million
|
||||
$pricedetail->setPriceRelatedQuantity(1.234e9); //100 billion
|
||||
$this->assertEquals('0.00810', $pricedetail->getPricePerUnit());
|
||||
|
@ -61,7 +57,6 @@ class PricedetailTest extends TestCase
|
|||
$orderdetail2 = $this->createMock(Orderdetail::class);
|
||||
$orderdetail2->method('getPart')->willReturn($part2);
|
||||
|
||||
|
||||
//By default a price detail returns 1
|
||||
$this->assertEquals(1, $pricedetail->getPriceRelatedQuantity());
|
||||
|
||||
|
@ -90,7 +85,6 @@ class PricedetailTest extends TestCase
|
|||
$orderdetail2 = $this->createMock(Orderdetail::class);
|
||||
$orderdetail2->method('getPart')->willReturn($part2);
|
||||
|
||||
|
||||
//By default a price detail returns 1
|
||||
$this->assertEquals(1, $pricedetail->getMinDiscountQuantity());
|
||||
|
||||
|
@ -105,4 +99,4 @@ class PricedetailTest extends TestCase
|
|||
$pricedetail->setOrderdetail($orderdetail2);
|
||||
$this->assertEquals(0.23, $pricedetail->getMinDiscountQuantity());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
|
||||
*
|
||||
|
@ -17,12 +17,10 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*
|
||||
*/
|
||||
|
||||
namespace App\Tests\Entity;
|
||||
|
||||
|
||||
use App\Entity\Attachments\AttachmentType;
|
||||
use App\Entity\Parts\Category;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
@ -31,7 +29,6 @@ use Symfony\Component\Yaml\Tests\A;
|
|||
/**
|
||||
* Test StructuralDBElement entities.
|
||||
* Note: Because StructuralDBElement is abstract we use AttachmentType here as a placeholder.
|
||||
* @package App\Tests\Entity
|
||||
*/
|
||||
class StructuralDBElementTest extends TestCase
|
||||
{
|
||||
|
@ -92,7 +89,8 @@ class StructuralDBElementTest extends TestCase
|
|||
public function testChildOfExtendedClass()
|
||||
{
|
||||
//Doctrine extends the entities for proxy classes so the isChildOf mus also work for inheritance types
|
||||
$inheritance = new class extends AttachmentType {};
|
||||
$inheritance = new class() extends AttachmentType {
|
||||
};
|
||||
$inheritance->setParent($this->root);
|
||||
$this->assertTrue($inheritance->isChildOf($this->root));
|
||||
$this->assertFalse($this->root->isChildOf($inheritance));
|
||||
|
@ -119,5 +117,4 @@ class StructuralDBElementTest extends TestCase
|
|||
$this->assertEquals([$this->root, $this->child1], $this->child1->getPathArray());
|
||||
$this->assertEquals([$this->root], $this->root->getPathArray());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
|
||||
*
|
||||
|
@ -17,7 +17,6 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*
|
||||
*/
|
||||
|
||||
namespace App\Tests\Entity\UserSystem;
|
||||
|
@ -25,7 +24,6 @@ namespace App\Tests\Entity\UserSystem;
|
|||
use App\Entity\UserSystem\PermissionsEmbed;
|
||||
use Doctrine\ORM\Mapping\Embedded;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Security\Http\RememberMe\PersistentTokenBasedRememberMeServices;
|
||||
|
||||
class PermissionsEmbedTest extends TestCase
|
||||
{
|
||||
|
@ -40,29 +38,28 @@ class PermissionsEmbedTest extends TestCase
|
|||
//For newly created embedded, all things should be set to inherit => null
|
||||
//Test both normal name and constants
|
||||
|
||||
$this->assertNull( $embed->getPermissionValue(PermissionsEmbed::PARTS, 0));
|
||||
$this->assertEquals(null, $embed->getPermissionValue(PermissionsEmbed::CONFIG, 0));
|
||||
$this->assertEquals(null, $embed->getPermissionValue(PermissionsEmbed::ATTACHMENT_TYPES, 0));
|
||||
$this->assertEquals(null, $embed->getPermissionValue(PermissionsEmbed::CATEGORIES, 0));
|
||||
$this->assertEquals(null, $embed->getPermissionValue(PermissionsEmbed::DATABASE, 0));
|
||||
$this->assertEquals(null, $embed->getPermissionValue(PermissionsEmbed::DEVICE_PARTS, 0));
|
||||
$this->assertEquals(null, $embed->getPermissionValue(PermissionsEmbed::DEVICES, 0));
|
||||
$this->assertEquals(null, $embed->getPermissionValue(PermissionsEmbed::FOOTRPINTS, 0));
|
||||
$this->assertEquals(null, $embed->getPermissionValue(PermissionsEmbed::GROUPS, 0));
|
||||
$this->assertEquals(null, $embed->getPermissionValue(PermissionsEmbed::DATABASE, 0));
|
||||
$this->assertEquals(null, $embed->getPermissionValue(PermissionsEmbed::LABELS, 0));
|
||||
$this->assertEquals(null, $embed->getPermissionValue(PermissionsEmbed::MANUFACTURERS, 0));
|
||||
$this->assertEquals(null, $embed->getPermissionValue(PermissionsEmbed::PARTS_ATTACHMENTS, 0));
|
||||
$this->assertEquals(null, $embed->getPermissionValue(PermissionsEmbed::PARTS_COMMENT, 0));
|
||||
$this->assertEquals(null, $embed->getPermissionValue(PermissionsEmbed::PARTS_DESCRIPTION, 0));
|
||||
$this->assertEquals(null, $embed->getPermissionValue(PermissionsEmbed::PARTS_FOOTPRINT, 0));
|
||||
$this->assertEquals(null, $embed->getPermissionValue(PermissionsEmbed::PARTS_MANUFACTURER, 0));
|
||||
$this->assertEquals(null, $embed->getPermissionValue(PermissionsEmbed::PARTS_MINAMOUNT, 0));
|
||||
$this->assertEquals(null, $embed->getPermissionValue(PermissionsEmbed::PARTS_NAME, 0));
|
||||
$this->assertEquals(null, $embed->getPermissionValue(PermissionsEmbed::PARTS_ORDER, 0));
|
||||
$this->assertEquals(null, $embed->getPermissionValue(PermissionsEmbed::PARTS_ORDERDETAILS, 0));
|
||||
$this->assertEquals(null, $embed->getPermissionValue(PermissionsEmbed::USERS, 0));
|
||||
|
||||
$this->assertNull($embed->getPermissionValue(PermissionsEmbed::PARTS, 0));
|
||||
$this->assertNull($embed->getPermissionValue(PermissionsEmbed::CONFIG, 0));
|
||||
$this->assertNull($embed->getPermissionValue(PermissionsEmbed::ATTACHMENT_TYPES, 0));
|
||||
$this->assertNull($embed->getPermissionValue(PermissionsEmbed::CATEGORIES, 0));
|
||||
$this->assertNull($embed->getPermissionValue(PermissionsEmbed::DATABASE, 0));
|
||||
$this->assertNull($embed->getPermissionValue(PermissionsEmbed::DEVICE_PARTS, 0));
|
||||
$this->assertNull($embed->getPermissionValue(PermissionsEmbed::DEVICES, 0));
|
||||
$this->assertNull($embed->getPermissionValue(PermissionsEmbed::FOOTRPINTS, 0));
|
||||
$this->assertNull($embed->getPermissionValue(PermissionsEmbed::GROUPS, 0));
|
||||
$this->assertNull($embed->getPermissionValue(PermissionsEmbed::DATABASE, 0));
|
||||
$this->assertNull($embed->getPermissionValue(PermissionsEmbed::LABELS, 0));
|
||||
$this->assertNull($embed->getPermissionValue(PermissionsEmbed::MANUFACTURERS, 0));
|
||||
$this->assertNull($embed->getPermissionValue(PermissionsEmbed::PARTS_ATTACHMENTS, 0));
|
||||
$this->assertNull($embed->getPermissionValue(PermissionsEmbed::PARTS_COMMENT, 0));
|
||||
$this->assertNull($embed->getPermissionValue(PermissionsEmbed::PARTS_DESCRIPTION, 0));
|
||||
$this->assertNull($embed->getPermissionValue(PermissionsEmbed::PARTS_FOOTPRINT, 0));
|
||||
$this->assertNull($embed->getPermissionValue(PermissionsEmbed::PARTS_MANUFACTURER, 0));
|
||||
$this->assertNull($embed->getPermissionValue(PermissionsEmbed::PARTS_MINAMOUNT, 0));
|
||||
$this->assertNull($embed->getPermissionValue(PermissionsEmbed::PARTS_NAME, 0));
|
||||
$this->assertNull($embed->getPermissionValue(PermissionsEmbed::PARTS_ORDER, 0));
|
||||
$this->assertNull($embed->getPermissionValue(PermissionsEmbed::PARTS_ORDERDETAILS, 0));
|
||||
$this->assertNull($embed->getPermissionValue(PermissionsEmbed::USERS, 0));
|
||||
|
||||
//Set a value for testing to the part property
|
||||
$reflection = new \ReflectionClass($embed);
|
||||
|
@ -77,13 +74,10 @@ class PermissionsEmbedTest extends TestCase
|
|||
$this->assertTrue($embed->getPermissionValue(PermissionsEmbed::PARTS, 4));
|
||||
// 11 is reserved, but it should be also treat as INHERIT.
|
||||
$this->assertNull($embed->getPermissionValue(PermissionsEmbed::PARTS, 6));
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function testGetBitValue()
|
||||
{
|
||||
|
||||
$embed = new PermissionsEmbed();
|
||||
|
||||
//Set a value for testing to the part property
|
||||
|
@ -94,11 +88,11 @@ 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->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));
|
||||
// 11 is reserved, but it should be also treat as INHERIT.
|
||||
$this->assertEquals(0b11 ,$embed->getBitValue(PermissionsEmbed::PARTS, 6));
|
||||
$this->assertEquals(0b11, $embed->getBitValue(PermissionsEmbed::PARTS, 6));
|
||||
}
|
||||
|
||||
public function testInvalidPermissionName()
|
||||
|
@ -139,7 +133,7 @@ class PermissionsEmbedTest extends TestCase
|
|||
'ALLOW' => [PermissionsEmbed::ALLOW],
|
||||
'DISALLOW' => [PermissionsEmbed::DISALLOW],
|
||||
'INHERIT' => [PermissionsEmbed::INHERIT],
|
||||
'0b11' => [0b11]
|
||||
'0b11' => [0b11],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -149,7 +143,7 @@ class PermissionsEmbedTest extends TestCase
|
|||
'ALLOW' => [true],
|
||||
'DISALLOW' => [false],
|
||||
'INHERIT' => [null],
|
||||
'0b11' => [null]
|
||||
'0b11' => [null],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -188,7 +182,7 @@ class PermissionsEmbedTest extends TestCase
|
|||
$embed->setRawPermissionValues([
|
||||
PermissionsEmbed::PARTS => 0,
|
||||
PermissionsEmbed::USERS => 100,
|
||||
PermissionsEmbed::CATEGORIES => 1304
|
||||
PermissionsEmbed::CATEGORIES => 1304,
|
||||
]);
|
||||
|
||||
$this->assertEquals(0, $embed->getRawPermissionValue(PermissionsEmbed::PARTS));
|
||||
|
@ -204,7 +198,5 @@ class PermissionsEmbedTest extends TestCase
|
|||
$this->assertEquals(0, $embed->getRawPermissionValue(PermissionsEmbed::PARTS));
|
||||
$this->assertEquals(100, $embed->getRawPermissionValue(PermissionsEmbed::USERS));
|
||||
$this->assertEquals(1304, $embed->getRawPermissionValue(PermissionsEmbed::CATEGORIES));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
|
||||
*
|
||||
|
@ -17,12 +17,10 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*
|
||||
*/
|
||||
|
||||
namespace App\Tests\Entity\UserSystem;
|
||||
|
||||
|
||||
use App\Entity\UserSystem\User;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
|
@ -38,4 +36,4 @@ class UserTest extends TestCase
|
|||
$this->assertEquals('John Doe', $user->getFullName(false));
|
||||
$this->assertEquals('John Doe (username)', $user->getFullName(true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue