diff --git a/Account/PermissionAbstract.php b/Account/PermissionAbstract.php index 06ecd6e87..44b14cbca 100644 --- a/Account/PermissionAbstract.php +++ b/Account/PermissionAbstract.php @@ -62,7 +62,7 @@ class PermissionAbstract implements \JsonSerializable /** * Providing module id. * - * @var int|null + * @var int * @since 1.0.0 */ protected $from = 0; @@ -192,11 +192,11 @@ class PermissionAbstract implements \JsonSerializable /** * Get providing module id. * - * @return int|null + * @return int * * @since 1.0.0 */ - public function getFrom() : ?int + public function getFrom() : int { return $this->from; } @@ -210,7 +210,7 @@ class PermissionAbstract implements \JsonSerializable * * @since 1.0.0 */ - public function setFrom(int $from = null) : void + public function setFrom(int $from = 0) : void { $this->from = $from; } @@ -353,14 +353,14 @@ class PermissionAbstract implements \JsonSerializable public function jsonSerialize() { return [ - 'id' => $this->id, - 'unit' => $this->unit, - 'app' => $this->app, - 'module' => $this->module, - 'from' => $this->from, - 'type' => $this->type, - 'element' => $this->element, - 'component' => $this->component, + 'id' => $this->id, + 'unit' => $this->unit, + 'app' => $this->app, + 'module' => $this->module, + 'from' => $this->from, + 'type' => $this->type, + 'element' => $this->element, + 'component' => $this->component, 'permission' => $this->permission, ]; } diff --git a/Views/PaginationView.php b/Views/PaginationView.php index fab22f0a3..a1a3f36b2 100644 --- a/Views/PaginationView.php +++ b/Views/PaginationView.php @@ -39,7 +39,7 @@ class PaginationView extends View * @var int * @since 1.0.0 */ - protected $page = 50; + protected $page = 1; /** * How many pages exists? @@ -47,7 +47,7 @@ class PaginationView extends View * @var int * @since 1.0.0 */ - protected $pages = 100; + protected $pages = 1; /** * How many results exists? diff --git a/tests/Account/AccountTest.php b/tests/Account/AccountTest.php index f6d4eb2c0..1455233e6 100644 --- a/tests/Account/AccountTest.php +++ b/tests/Account/AccountTest.php @@ -151,6 +151,12 @@ class AccountTest extends \PHPUnit\Framework\TestCase ]); self::assertEquals(4, \count($account->getPermissions())); + $account->addPermissions([[ + new class extends PermissionAbstract {}, + new class extends PermissionAbstract {}, + ]]); + self::assertEquals(6, \count($account->getPermissions())); + self::assertFalse($account->hasPermission(PermissionType::READ, 1, 'a', 'a', 1, 1, 1)); self::assertTrue($account->hasPermission(PermissionType::NONE)); diff --git a/tests/Account/PermissionAbstractTest.php b/tests/Account/PermissionAbstractTest.php index 85a40f59b..00cfdf2ce 100644 --- a/tests/Account/PermissionAbstractTest.php +++ b/tests/Account/PermissionAbstractTest.php @@ -28,11 +28,26 @@ class PermissionAbstractTest extends \PHPUnit\Framework\TestCase self::assertEquals(null, $perm->getUnit()); self::assertEquals(null, $perm->getApp()); self::assertEquals(null, $perm->getModule()); - self::assertEquals(null, $perm->getFrom()); + self::assertEquals(0, $perm->getFrom()); self::assertEquals(null, $perm->getType()); self::assertEquals(null, $perm->getElement()); self::assertEquals(null, $perm->getComponent()); self::assertEquals(PermissionType::NONE, $perm->getPermission()); + + self::assertEquals( + [ + 'id' => 0, + 'unit' => null, + 'app' => null, + 'module' => null, + 'from' => 0, + 'type' => null, + 'element' => null, + 'component' => null, + 'permission' => PermissionType::NONE, + ], + $perm->jsonSerialize() + ); } public function testAbstractGetSet() diff --git a/tests/Views/PaginationViewTest.php b/tests/Views/PaginationViewTest.php new file mode 100644 index 000000000..60276ab59 --- /dev/null +++ b/tests/Views/PaginationViewTest.php @@ -0,0 +1,47 @@ +getMaxPages()); + self::assertEquals(1, $view->getPages()); + self::assertEquals(1, $view->getPage()); + self::assertEquals(0, $view->getResults()); + } + + public function testGetSet() + { + $view = new PaginationView(); + + $view->setMaxPages(9); + self::assertEquals(9, $view->getMaxPages()); + + $view->setPages(2); + self::assertEquals(2, $view->getPages()); + + $view->setPage(3); + self::assertEquals(3, $view->getPage()); + + $view->setResults(12); + self::assertEquals(12, $view->getResults()); + } +} \ No newline at end of file