-
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#111. Add coverage on BitMask extension + bug fixing
- Loading branch information
1 parent
215583e
commit 0545590
Showing
11 changed files
with
137 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<?php | ||
namespace rjapi\exception; | ||
namespace rjapi\exceptions; | ||
|
||
class AttributesException extends BaseException | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?php | ||
|
||
namespace rjapi\exception; | ||
namespace rjapi\exceptions; | ||
|
||
use rjapi\helpers\Json; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?php | ||
|
||
namespace rjapi\exception; | ||
namespace rjapi\exceptions; | ||
|
||
class DirectoryException extends BaseException | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?php | ||
|
||
namespace rjapi\exception; | ||
namespace rjapi\exceptions; | ||
|
||
class ModelException extends BaseException | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<?php | ||
namespace rjapi\exception; | ||
namespace rjapi\exceptions; | ||
|
||
class SchemaException extends BaseException | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
|
||
namespace rjapitest\unit\extensions; | ||
|
||
use rjapi\extension\BitMask; | ||
use rjapitest\unit\TestCase; | ||
|
||
/** | ||
* Class BitMaskTest | ||
* @package rjapitest\unit\extensions | ||
* | ||
* @property BitMask bitMask | ||
*/ | ||
class BitMaskTest extends TestCase | ||
{ | ||
private const FIELD = 'permissions'; | ||
private $bitMask; | ||
|
||
public function setUp() | ||
{ | ||
parent::setUp(); | ||
$this->bitMask = new BitMask([ | ||
self::FIELD => [ | ||
'enabled' => true, | ||
'flags' => [ | ||
'publisher' => 1, | ||
'editor' => 2, | ||
'manager' => 4, | ||
'photo_reporter' => 8, | ||
'admin' => 16, | ||
], | ||
], | ||
]); | ||
} | ||
|
||
/** | ||
* @test | ||
* @throws \rjapi\exceptions\AttributesException | ||
* @expectedException \rjapi\exceptions\AttributesException | ||
*/ | ||
public function it_gets_flags_and_fields() | ||
{ | ||
$this->assertArraySubset([ | ||
'publisher' => 1, | ||
'editor' => 2, | ||
'manager' => 4, | ||
'photo_reporter' => 8, | ||
'admin' => 16, | ||
], $this->bitMask->getFlags()); | ||
$this->assertTrue($this->bitMask->isEnabled()); | ||
$this->assertFalse($this->bitMask->isHidden()); | ||
$this->assertEquals(self::FIELD, $this->bitMask->getField()); | ||
// testing that it throws exception | ||
$this->bitMask = new BitMask([ | ||
self::FIELD => [ | ||
'enabled' => true, | ||
'publisher' => 1, | ||
'editor' => 2, | ||
'manager' => 4, | ||
'photo_reporter' => 8, | ||
'admin' => 16, | ||
], | ||
]); | ||
$this->bitMask->getFlags(); | ||
} | ||
} |