Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add constants for event's priorities
  • Loading branch information
dunglas committed Nov 2, 2016
1 parent 6cddcd2 commit 2e7b73e
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/EventListener/EventPriorities.php
@@ -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;
}
34 changes: 34 additions & 0 deletions tests/EventListener/EventPrioritiesTest.php
@@ -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);
}
}

0 comments on commit 2e7b73e

Please sign in to comment.