-
-
Notifications
You must be signed in to change notification settings - Fork 895
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add constants for event's priorities
- Loading branch information
Showing
2 changed files
with
65 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the API Platform project. | ||
* | ||
* (c) Kévin Dunglas <dunglas@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace ApiPlatform\Core\EventListener; | ||
|
||
/** | ||
* Constants for common priorities. | ||
* | ||
* @author Kévin Dunglas <dunglas@gmail.com> | ||
*/ | ||
final class EventPriorities | ||
{ | ||
const PRE_READ = 5; | ||
const POST_READ = 3; | ||
const PRE_DESERIALIZE = 3; | ||
const POST_DESERIALIZE = 1; | ||
const PRE_VALIDATE = 65; | ||
const POST_VALIDATE = 63; | ||
const PRE_WRITE = 33; | ||
const POST_WRITE = 31; | ||
const PRE_RESPOND = 9; | ||
const POST_RESPOND = 7; | ||
} |
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,34 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the API Platform project. | ||
* | ||
* (c) Kévin Dunglas <dunglas@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace ApiPlatform\Core\Tests\EventListener; | ||
|
||
use ApiPlatform\Core\EventListener\EventPriorities; | ||
|
||
/** | ||
* @author Kévin Dunglas <dunglas@gmail.com> | ||
*/ | ||
class EventPrioritiesTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
public function testConstants() | ||
{ | ||
$this->assertEquals(5, EventPriorities::PRE_READ); | ||
$this->assertEquals(3, EventPriorities::POST_READ); | ||
$this->assertEquals(3, EventPriorities::PRE_DESERIALIZE); | ||
$this->assertEquals(1, EventPriorities::POST_DESERIALIZE); | ||
$this->assertEquals(65, EventPriorities::PRE_VALIDATE); | ||
$this->assertEquals(63, EventPriorities::POST_VALIDATE); | ||
$this->assertEquals(33, EventPriorities::PRE_WRITE); | ||
$this->assertEquals(31, EventPriorities::POST_WRITE); | ||
$this->assertEquals(9, EventPriorities::PRE_RESPOND); | ||
$this->assertEquals(7, EventPriorities::POST_RESPOND); | ||
} | ||
} |