public function testUpdate() { $this->allowLogin($this->getApp()); $checkResponse = new SchemaCheck(); $check = $this->getMockSchemaManager(['update']); $check->expects($this->any())->method('update')->will($this->returnValue($checkResponse)); $this->setService('schema', $check); ResourceManager::$theApp = $this->getApp(); $this->setRequest(Request::create('/bolt/dbupdate', 'POST')); $response = $this->controller()->update($this->getRequest()); $this->assertEquals(Response::HTTP_FOUND, $response->getStatusCode()); $this->assertEquals('/bolt/dbupdate_result', $response->getTargetUrl()); }
public function testCheckDir() { $fakeLocation = "/path/to/nowhere"; $config = new Composer(TEST_ROOT); $verifier = new ComposerChecks($config); $app['resources'] = $config; ResourceManager::$theApp = $app; // Check we get an exception if the directory isn't writable $this->php->expects($this->at(0))->method('is_dir')->will($this->returnValue(true)); $this->php->expects($this->at(1))->method('is_dir')->will($this->returnValue(true)); $this->php->expects($this->any())->method('is_writable')->will($this->returnValue(false)); $this->setExpectedException('Bolt\\Exception\\LowlevelException'); $this->expectOutputRegex("/Bolt - Fatal Error/"); $verifier->checkDir($fakeLocation); }
public function testCheckDir() { $fakeLocation = '/path/to/nowhere'; $config = new Composer(TEST_ROOT); $verifier = new ComposerChecks($config); $app['resources'] = $config; ResourceManager::$theApp = $app; // Check we get an exception if the directory isn't writable $this->php->expects($this->at(0))->method('is_dir')->will($this->returnValue(true)); $this->php->expects($this->at(1))->method('is_dir')->will($this->returnValue(true)); $this->php->expects($this->any())->method('is_writable')->will($this->returnValue(false)); try { $verifier->checkDir($fakeLocation); $this->fail('Bolt\\Exception\\LowlevelException not thrown'); } catch (LowlevelException $e) { $this->assertRegExp("/The default folder \\/path\\/to\\/nowhere isn't writable. Make sure it's writable to the user that the webserver is using/", $e->getMessage()); $this->assertRegExp('/When using Bolt as a Composer package it will need to have access to the following folders/', $e->getMessage()); $this->assertRegExp('/Bolt - Fatal Error/', $e::$screen); } }
public function testUpdate() { $this->allowLogin($this->getApp()); $checkResponse = new \Bolt\Storage\Database\Schema\CheckResponse(); $check = $this->getMock('Bolt\\Storage\\Database\\Schema\\Manager', ['repairTables'], [$this->getApp()]); $check->expects($this->any())->method('repairTables')->will($this->returnValue($checkResponse)); $this->setService('schema', $check); ResourceManager::$theApp = $this->getApp(); $this->setRequest(Request::create('/bolt/dbupdate', 'POST', ['return' => 'edit'])); $response = $this->controller()->update($this->getRequest()); $this->assertEquals(Response::HTTP_FOUND, $response->getStatusCode()); $this->assertEquals('/bolt/file/edit/config/contenttypes.yml', $response->getTargetUrl()); $this->assertNotEmpty($this->getFlashBag()->get('success')); $this->setRequest(Request::create('/bolt/dbupdate', 'POST', ['return' => 'edit'])); $response = $this->controller()->update($this->getRequest()); $this->assertEquals(Response::HTTP_FOUND, $response->getStatusCode()); $this->assertEquals('/bolt/file/edit/config/contenttypes.yml', $response->getTargetUrl()); $this->assertNotEmpty($this->getFlashBag()->get('success')); $this->setRequest(Request::create('/bolt/dbupdate', 'POST')); $response = $this->controller()->update($this->getRequest()); $this->assertEquals(Response::HTTP_FOUND, $response->getStatusCode()); $this->assertEquals('/bolt/dbupdate_result', $response->getTargetUrl()); }
/** * @deprecated Don't use! Will probably refactored out soon * * @param Application $app */ public function setApp(Application $app) { $this->app = $app; ResourceManager::$theApp = $app; }
public function testGeneralFatalErrorCatch() { $app = ['resources' => new Standard(TEST_ROOT)]; ResourceManager::$theApp = $app; $this->php2->expects($this->once())->method('error_get_last')->will($this->returnValue($this->errorResponses['unknown'])); $this->expectOutputRegex('/PHP Fatal error: Bolt generic/'); LowlevelException::catchFatalErrors($this->getApp(), false); }
public function testSystemLog() { $app = $this->getApp(); $this->allowLogin($app); $log = $this->getMock('Bolt\\Logger\\Manager', array('clear', 'trim'), array($app)); $log->expects($this->once())->method('clear')->will($this->returnValue(true)); $log->expects($this->once())->method('trim')->will($this->returnValue(true)); $app['logger.manager'] = $log; ResourceManager::$theApp = $app; $request = Request::create('/bolt/systemlog', 'GET', array('action' => 'trim')); $response = $app->handle($request); $this->assertNotEmpty($app['session']->getFlashBag()->get('success')); $request = Request::create('/bolt/systemlog', 'GET', array('action' => 'clear')); $response = $app->handle($request); $this->assertNotEmpty($app['session']->getFlashBag()->get('success')); $this->assertEquals('/bolt/systemlog', $response->getTargetUrl()); $request = Request::create('/bolt/systemlog'); $this->checkTwigForTemplate($app, 'activity/systemlog.twig'); $app->run($request); }