Skip to content

Commit

Permalink
Merge pull request #486 from CakeDC/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
steinkel authored Jan 23, 2017
2 parents a523bf2 + a5ae419 commit ba91f74
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ before_script:
- sh -c "if [ '$COVERALLS' = '1' ]; then mkdir -p build/logs; fi"

script:
- sh -c "if [ '$DEFAULT' = '1' ]; then phpunit --stderr; fi"
- sh -c "if [ '$DEFAULT' = '1' ]; then ./vendor/bin/phpunit --stderr; fi"
- sh -c "if [ '$PHPCS' = '1' ]; then ./vendor/bin/phpcs -p -n --extensions=php --standard=vendor/cakephp/cakephp-codesniffer/CakePHP ./src ./tests; fi"
- sh -c "if [ '$COVERALLS' = '1' ]; then phpunit --stderr --coverage-clover build/logs/clover.xml; fi"
- sh -c "if [ '$COVERALLS' = '1' ]; then ./vendor/bin/phpunit --stderr --coverage-clover build/logs/clover.xml; fi"
- sh -c "if [ '$COVERALLS' = '1' ]; then php vendor/bin/coveralls -c .coveralls.yml -v; fi"

notifications:
Expand Down
3 changes: 2 additions & 1 deletion src/Controller/Component/UsersAuthComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Cake\Controller\Component;
use Cake\Core\Configure;
use Cake\Event\Event;
use Cake\Event\EventManager;
use Cake\Network\Request;
use Cake\Routing\Exception\MissingRouteException;
use Cake\Routing\Router;
Expand Down Expand Up @@ -98,7 +99,7 @@ protected function _loadRememberMe()
*/
protected function _attachPermissionChecker()
{
$this->_registry->getController()->eventManager()->on(self::EVENT_IS_AUTHORIZED, [], [$this, 'isUrlAuthorized']);
EventManager::instance()->on(self::EVENT_IS_AUTHORIZED, [], [$this, 'isUrlAuthorized']);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/View/Helper/AuthLinkHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use CakeDC\Users\Controller\Component\UsersAuthComponent;
use Cake\Event\Event;
use Cake\Event\EventManager;
use Cake\Utility\Hash;
use Cake\View\Helper;
use Cake\View\Helper\HtmlHelper;
Expand Down Expand Up @@ -48,7 +49,7 @@ public function link($title, $url = null, array $options = [])
public function isAuthorized($url = null)
{
$event = new Event(UsersAuthComponent::EVENT_IS_AUTHORIZED, $this, ['url' => $url]);
$result = $this->_View->eventManager()->dispatch($event);
$result = EventManager::instance()->dispatch($event);

return $result->result;
}
Expand Down
7 changes: 4 additions & 3 deletions tests/TestCase/View/Helper/AuthLinkHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use CakeDC\Users\View\Helper\AuthLinkHelper;
use CakeDC\Users\View\Helper\UserHelper;
use Cake\Event\Event;
use Cake\Event\EventManager;
use Cake\TestSuite\TestCase;
use Cake\View\View;

Expand Down Expand Up @@ -66,7 +67,7 @@ public function testLinkAuthorized()
$eventManagerMock = $this->getMockBuilder('Cake\Event\EventManager')
->setMethods(['dispatch'])
->getMock();
$view->eventManager($eventManagerMock);
EventManager::instance($eventManagerMock);
$this->AuthLink = new AuthLinkHelper($view);
$result = new Event('dispatch-result');
$result->result = true;
Expand All @@ -89,7 +90,7 @@ public function testLinkAuthorizedAllowedTrue()
$eventManagerMock = $this->getMockBuilder('Cake\Event\EventManager')
->setMethods(['dispatch'])
->getMock();
$view->eventManager($eventManagerMock);
EventManager::instance($eventManagerMock);
$this->AuthLink = new AuthLinkHelper($view);
$result = new Event('dispatch-result');
$result->result = true;
Expand Down Expand Up @@ -131,7 +132,7 @@ public function testIsAuthorized()
$eventManagerMock = $this->getMockBuilder('Cake\Event\EventManager')
->setMethods(['dispatch'])
->getMock();
$view->eventManager($eventManagerMock);
EventManager::instance($eventManagerMock);
$this->AuthLink = new AuthLinkHelper($view);
$result = new Event('dispatch-result');
$result->result = true;
Expand Down

0 comments on commit ba91f74

Please sign in to comment.