Created
November 6, 2014 09:47
-
-
Save mockiemockiz/e7d6ed4b4c13aa72588d to your computer and use it in GitHub Desktop.
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
public function updateProfileAction() | |
{ | |
$authorize = $this->getServiceLocator()->get('BjyAuthorize\Provider\Identity\ProviderInterface'); | |
$roles = $authorize->getIdentityRoles(); | |
Debug::dump($this->ZfcUserAuthentication()->hasIdentity()); | |
// Debug::dump($roles); | |
die; | |
} |
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
<?php | |
namespace UserTest\Controller; | |
use test\Bootstrap; | |
use User\Controller\IndexController; | |
use Zend\Authentication\Adapter\Http; | |
use Zend\Debug\Debug; | |
use Zend\Http\Request; | |
use Zend\Mvc\MvcEvent; | |
use Zend\Mvc\Router\RouteMatch; | |
use Zend\Test\PHPUnit\Controller\AbstractHttpControllerTestCase; | |
use Zend\Mvc\Router\Http\TreeRouteStack as HttpRouter; | |
class IndexControllerTest extends AbstractHttpControllerTestCase | |
{ | |
protected $controller; | |
protected $event; | |
public function setUp() | |
{ | |
$this->setApplicationConfig( | |
include dirname(dirname(dirname(dirname(dirname(__DIR__))))) . '/config/application.config.php' | |
); | |
$this->controller = new IndexController(); | |
$ZfcUserMock = $this->getMock('ZfcUser\Entity\User'); | |
$ZfcUserMock->expects($this->any()) | |
->method('getId') | |
->will($this->returnValue('1')); | |
$authMock = $this->getMock('ZfcUser\Controller\Plugin\ZfcUserAuthentication'); | |
$authMock->expects($this->any()) | |
->method('hasIdentity') | |
-> will($this->returnValue(TRUE)); | |
$this->controller->getPluginManager() | |
->setService('zfcUserAuthentication', $authMock); | |
parent::setUp(); | |
} | |
public function testUpdateProfileActionCanBeAccessed() | |
{ | |
$this->dispatch('/user/index/updateProfile'); | |
$this->assertResponseStatusCode(200); | |
$this->assertModuleName('User'); | |
$this->assertControllerName('User\Controller\Index'); | |
$this->assertControllerClass('IndexController'); | |
$this->assertActionName('updateProfile'); | |
$this->assertMatchedRouteName('user/default/index/updateProfile'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment