diff --git a/tests/TestCase/Controller/Component/GcmComponentTest.php b/tests/TestCase/Controller/Component/GcmComponentTest.php index 6668dac..3965594 100644 --- a/tests/TestCase/Controller/Component/GcmComponentTest.php +++ b/tests/TestCase/Controller/Component/GcmComponentTest.php @@ -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() diff --git a/tests/bootstrap.php b/tests/bootstrap.php new file mode 100644 index 0000000..28dae6c --- /dev/null +++ b/tests/bootstrap.php @@ -0,0 +1,104 @@ +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]);