-
-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit tests for the logic exception
- Loading branch information
1 parent
b226a7f
commit c84b0c6
Showing
2 changed files
with
54 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,5 +28,4 @@ public function __construct( | |
details: $lock->toArray() | ||
); | ||
} | ||
|
||
} |
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,54 @@ | ||
<?php | ||
|
||
namespace Kirby\Content; | ||
|
||
use Kirby\Cms\User; | ||
|
||
/** | ||
* @coversDefaultClass \Kirby\Content\LockException | ||
* @covers ::__construct | ||
*/ | ||
class LockExceptionTest extends TestCase | ||
{ | ||
/** | ||
* @covers ::__construct | ||
* @covers ::getCode | ||
* @covers ::getDetails | ||
* @covers ::getHttpCode | ||
* @covers ::getMessage | ||
*/ | ||
public function testException() | ||
{ | ||
$lock = new Lock( | ||
user: new User(['username' => 'test']), | ||
modified: $time = time() | ||
); | ||
|
||
$exception = new LockException( | ||
lock: $lock | ||
); | ||
|
||
$this->assertSame('The version is locked', $exception->getMessage()); | ||
$this->assertSame($lock->toArray(), $exception->getDetails()); | ||
$this->assertSame(423, $exception->getHttpCode()); | ||
$this->assertSame('error.lock', $exception->getCode()); | ||
} | ||
|
||
/** | ||
* @covers ::getMessage | ||
*/ | ||
public function testCustomMessage() | ||
{ | ||
$lock = new Lock( | ||
user: new User(['username' => 'test']), | ||
modified: $time = time() | ||
); | ||
|
||
$exception = new LockException( | ||
lock: $lock, | ||
message: $message = 'The version is locked and cannot be deleted' | ||
); | ||
|
||
$this->assertSame($message, $exception->getMessage()); | ||
} | ||
} |