. * * @author TechFuze * @copyright Copyright (c) 2013 - 2016, Techfuze. (http://techfuze.net) * @copyright Copyright (c) 1996 - 2015, Free Software Foundation, Inc. (http://www.fsf.org/) * @license http://opensource.org/licenses/GPL-3.0 GPLv3 License * * @link http://fuzeworks.techfuze.net * @since Version 0.0.1 * * @version Version 0.0.1 */ use FuzeWorks\Events; use FuzeWorks\Router; use FuzeWorks\EventPriority; /** * Class RouterRouteEventTest. */ class routerRouteEventTest extends CoreTestAbstract { /** * Check if the event is fired when it should be. */ public function test_basic() { $mock = $this->getMock('MockEvent', array('mockMethod')); $mock->expects($this->once())->method('mockMethod'); Events::addListener(array($mock, 'mockMethod'), 'routerRouteEvent', EventPriority::NORMAL); Router::setPath('a/b/c'); Router::route(false); } /** * Cancel events. */ public function test_cancel() { Router::setPath('x/y/z'); Events::addListener(array($this, 'listener_cancel'), 'routerRouteEvent', EventPriority::NORMAL); Router::route(false); $this->assertNotEquals('x', Router::getMatches()['controller']); $this->assertNotEquals('y', Router::getMatches()['function']); $this->assertNotEquals('z', Router::getMatches()['parameters']); } // Cancel all calls public function listener_cancel($event) { $event->setCancelled(true); } }