Skip to content
This repository has been archived by the owner on May 25, 2023. It is now read-only.

Commit

Permalink
Add bootstrap.php to tests folder
Browse files Browse the repository at this point in the history
  • Loading branch information
ker0x committed Dec 26, 2015
1 parent 778a797 commit ba8182b
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tests/TestCase/Controller/Component/GcmComponentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public function setUp()
public function testSend()
{
$this->component->send();
$this->assertEquals('', $this->component->response());
$response = $this->component->response();
$this->assertEquals(1, $response['success']);
}

public function tearDown()
Expand Down
104 changes: 104 additions & 0 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<?php
use Cake\Cache\Cache;
use Cake\Core\Configure;
use Cake\Core\Plugin;
use Cake\Datasource\ConnectionManager;
use Cake\Log\Log;

require_once 'vendor/autoload.php';

// Path constants to a few helpful things.
define('ROOT', dirname(__DIR__) . DS);
define('CAKE_CORE_INCLUDE_PATH', ROOT . 'vendor' . DS . 'cakephp' . DS . 'cakephp');
define('CORE_PATH', ROOT . 'vendor' . DS . 'cakephp' . DS . 'cakephp' . DS);
define('CAKE', CORE_PATH . 'src' . DS);
define('APP', ROOT . 'tests' . DS . 'test_app' . DS);
define('APP_DIR', 'test_app');
define('WEBROOT_DIR', 'webroot');
define('WWW_ROOT', APP . 'webroot' . DS);
define('TMP', ROOT . 'tests' . DS . 'tmp' . DS);
define('CACHE', TMP);
define('LOGS', TMP);

$loader = new \Cake\Core\ClassLoader;
$loader->register();

$loader->addNamespace('Cake\Test\Fixture', ROOT . '/vendor/cakephp/cakephp/tests/Fixture');

require_once CORE_PATH . 'config' . DS . 'bootstrap.php';

date_default_timezone_set('UTC');
mb_internal_encoding('UTF-8');

Configure::write('debug', true);

Configure::write('App', [
'namespace' => 'App',
'encoding' => 'UTF-8',
'base' => false,
'baseUrl' => false,
'dir' => 'src',
'webroot' => 'webroot',
'wwwRoot' => APP . 'webroot',
'fullBaseUrl' => 'http://localhost',
'imageBaseUrl' => 'img/',
'jsBaseUrl' => 'js/',
'cssBaseUrl' => 'css/',
'paths' => [
'plugins' => [APP . 'Plugin' . DS],
'templates' => [APP . 'Template' . DS]
]
]);

Configure::write('Session', [
'defaults' => 'php'
]);

Cache::config([
'_cake_core_' => [
'engine' => 'File',
'prefix' => 'cake_core_',
'serialize' => true
],
'_cake_model_' => [
'engine' => 'File',
'prefix' => 'cake_model_',
'serialize' => true
],
'default' => [
'engine' => 'File',
'prefix' => 'default_',
'serialize' => true
]
]);

// Ensure default test connection is defined
if (!getenv('db_class')) {
putenv('db_class=Cake\Database\Driver\Sqlite');
putenv('db_dsn=sqlite::memory:');
}

ConnectionManager::config('test', [
'className' => 'Cake\Database\Connection',
'driver' => getenv('db_class'),
'dsn' => getenv('db_dsn'),
'database' => getenv('db_database'),
'username' => getenv('db_login'),
'password' => getenv('db_password'),
'timezone' => 'UTC'
]);

Log::config([
'debug' => [
'engine' => 'Cake\Log\Engine\FileLog',
'levels' => ['notice', 'info', 'debug'],
'file' => 'debug',
],
'error' => [
'engine' => 'Cake\Log\Engine\FileLog',
'levels' => ['warning', 'error', 'critical', 'alert', 'emergency'],
'file' => 'error',
]
]);

Plugin::load('CakeGcm', ['path' => ROOT]);

0 comments on commit ba8182b

Please sign in to comment.