Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions tests/TestCase/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
namespace App\Test\TestCase;

use App\Application;
use Cake\Core\Configure;
use Cake\Error\Middleware\ErrorHandlerMiddleware;
use Cake\Http\MiddlewareQueue;
use Cake\Routing\Middleware\AssetMiddleware;
Expand All @@ -33,19 +34,35 @@ class ApplicationTest extends TestCase
use IntegrationTestTrait;

/**
* testBootstrap
* Test bootstrap in production.
*
* @return void
*/
public function testBootstrap()
{
Configure::write('debug', false);
$app = new Application(dirname(dirname(__DIR__)) . '/config');
$app->bootstrap();
$plugins = $app->getPlugins();

$this->assertTrue($plugins->has('Bake'), 'plugins has Bake');
$this->assertTrue($plugins->has('DebugKit'), 'plugins has DebugKit');
$this->assertTrue($plugins->has('Migrations'), 'plugins has Migrations');
$this->assertTrue($plugins->has('Bake'), 'plugins has Bake?');
$this->assertFalse($plugins->has('DebugKit'), 'plugins has DebugKit?');
$this->assertTrue($plugins->has('Migrations'), 'plugins has Migrations?');
}

/**
* Test bootstrap add DebugKit plugin in debug mode.
*
* @return void
*/
public function testBootstrapInDebug()
{
Configure::write('debug', true);
$app = new Application(dirname(dirname(__DIR__)) . '/config');
$app->bootstrap();
$plugins = $app->getPlugins();

$this->assertTrue($plugins->has('DebugKit'), 'plugins has DebugKit?');
}

/**
Expand Down
19 changes: 4 additions & 15 deletions tests/TestCase/Controller/PagesControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
namespace App\Test\TestCase\Controller;

use Cake\Core\Configure;
use Cake\TestSuite\Constraint\Response\StatusCode;
use Cake\TestSuite\IntegrationTestTrait;
use Cake\TestSuite\TestCase;

Expand All @@ -29,26 +30,14 @@ class PagesControllerTest extends TestCase
{
use IntegrationTestTrait;

/**
* testMultipleGet method
*
* @return void
*/
public function testMultipleGet()
{
$this->get('/');
$this->assertResponseOk();
$this->get('/');
$this->assertResponseOk();
}

/**
* testDisplay method
*
* @return void
*/
public function testDisplay()
{
Configure::write('debug', true);
$this->get('/pages/home');
$this->assertResponseOk();
$this->assertResponseContains('CakePHP');
Expand Down Expand Up @@ -120,7 +109,7 @@ public function testCsrfAppliedOk()
$this->enableCsrfToken();
$this->post('/pages/home', ['hello' => 'world']);

$this->assertResponseCode(200);
$this->assertResponseContains('CakePHP');
$this->assertThat(403, $this->logicalNot(new StatusCode($this->_response)));
$this->assertResponseNotContains('CSRF');
}
}
2 changes: 0 additions & 2 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@

require dirname(__DIR__) . '/config/bootstrap.php';

$_SERVER['PHP_SELF'] = '/';

if (empty($_SERVER['HTTP_HOST'])) {
Configure::write('App.fullBaseUrl', 'http://localhost');
}
Expand Down