protected function getCubex() { $cubex = new Cubex(); $cubex->prepareCubex(); $cubex->processConfiguration($cubex->getConfiguration()); return $cubex; }
public function testAuthFacade() { $provider = new TestAuthProvider(); $authy = new AuthedUser('brooke', 1); $provider->setRetrieve($authy); $cubex = new Cubex(); $cubex->configure(new TestConfigProvider()); $cubex->processConfiguration($cubex->getConfiguration()); $cubex->instance('request', Request::createFromGlobals()); $cubex->instance('\\Cubex\\Auth\\IAuthProvider', $provider); $sm = new ServiceManager(); $sm->setCubex($cubex); $sm->boot(); Auth::setFacadeApplication($cubex); $username = '******'; $this->assertTrue(Auth::forgottenPassword($username)); $authUser = Auth::login($username, 'password'); $this->assertEquals("brooke", $authUser->getUsername()); $autho = Auth::getAuthedUser(); $this->assertEquals("brooke", $autho->getUsername()); Auth::updateAuthedUser($autho); $this->assertTrue(Auth::isLoggedIn()); $this->assertTrue(Auth::logout()); $this->assertFalse(Auth::isLoggedIn()); }
public function getKernel($defaultAction = 'abc') { $cubex = new Cubex(); $cubex->prepareCubex(); $cubex->processConfiguration($cubex->getConfiguration()); $kernel = new SubDomainTester(); $kernel->setDefaultResponse($defaultAction); $kernel->setCubex($cubex); return $kernel; }
public function testConfigure() { $config = new TestConfigProvider(); $config->addItem("kernel", "project", 'Project'); $cubex = new Cubex(); $cubex->configure($config); $this->assertSame($config, $cubex->getConfiguration()); }
/** * @param $uri * @param $route * * @dataProvider baseRoutesProvider * * @link https://github.com/cubex/framework/issues/2 */ public function testBaseRoutes($uri, $route) { $request = Request::createFromGlobals(); $request->server->set('REQUEST_URI', $uri); $cubex = new Cubex(); $cubex->prepareCubex(); $cubex->processConfiguration($cubex->getConfiguration()); /** * @var CubexKernel|\PHPUnit_Framework_MockObject_MockObject $kernel */ $kernel = $this->getMock('\\Cubex\\Kernel\\CubexKernel', ['getRoutes', 'resp']); $kernel->expects($this->any())->method("getRoutes")->will($this->returnValue([$route => 'resp'])); $kernel->expects($this->any())->method("resp")->will($this->returnValue("respdata")); $kernel->setCubex($cubex); $resp = $kernel->handle($request, Cubex::MASTER_REQUEST, false); $this->assertInstanceOf('\\Symfony\\Component\\HttpFoundation\\Response', $resp); $this->assertEquals("respdata", $resp->getContent()); }