/** * @return void */ public function setUp() { parent::setUp(); Configure::delete('FormConfig'); $this->View = new View(null); $this->Form = new FormHelper($this->View); }
/** * tearDown method * * @return void */ public function tearDown() { parent::tearDown(); Configure::delete('Asset'); Plugin::unload(); unset($this->Helper, $this->View); }
public function setUp() { parent::setUp(); Configure::delete('GoogleMap'); $this->View = new View(null); $this->GoogleMap = new GoogleMapHelper($this->View); }
/** * @return void */ public function setUp() { parent::setUp(); Configure::write('App.namespace', 'TestApp'); Configure::write('Ajax'); Configure::delete('Flash'); $this->Controller = new AjaxComponentTestController(new Request(), new Response()); }
/** * setup * * @return void */ public function setUp() { parent::setUp(); //$this->connection = ConnectionManager::get('test'); $options = ['alias' => 'Articles']; $this->articles = TableRegistry::get('SluggedArticles', $options); Configure::delete('Slugged'); $this->articles->addBehavior('Tools.Slugged'); }
/** * SetUp method * * @return void */ public function setUp() { parent::setUp(); Configure::write('App.namespace', 'TestApp'); Configure::delete('Passwordable'); Configure::write('Passwordable.auth', 'AuthTest'); $this->Users = TableRegistry::get('ToolsUsers'); $this->hasher = PasswordHasherFactory::build('Default'); Router::setRequestInfo(new Request()); }
/** * setUp method * * @return void */ public function setUp() { parent::setUp(); Configure::delete('DatabaseLog.limit'); Configure::delete('DatabaseLog.maxLength'); $this->out = new ConsoleOutput(); $this->err = new ConsoleOutput(); $io = new ConsoleIo($this->out, $this->err); $this->Shell = $this->getMockBuilder(DatabaseLogShell::class)->setMethods(['in', '_stop'])->setConstructorArgs([$io])->getMock(); }
public function setUp() { parent::setUp(); Router::reload(); if ($this->defaultLocale === null) { $this->defaultLocale = ini_get('intl.default_locale'); } ini_set('intl.default_locale', 'de_DE'); Configure::delete('Meta'); $request = new Request(); $request->params['controller'] = 'ControllerName'; $request->params['action'] = 'actionName'; $View = new View($request); $this->Meta = new MetaHelper($View); }
/** * SetUp method * * @return void */ public function setUp() { parent::setUp(); Configure::write('App.namespace', 'TestApp'); Configure::delete('Passwordable'); Configure::write('Passwordable.auth', 'AuthTest'); $this->Users = TableRegistry::get('ToolsUsers'); $this->hasher = PasswordHasherFactory::build('Default'); $user = $this->Users->newEntity(); $data = ['id' => '5', 'name' => 'admin', 'password' => $this->hasher->hash('somepwd'), 'role_id' => '1']; $this->Users->patchEntity($user, $data); $result = $this->Users->save($user); $this->assertTrue((bool) $result); Router::setRequestInfo(new Request()); }
/** * SetUp method * * @return void */ public function setUp() { parent::setUp(); Request::addDetector('mobile', function ($request) { $detector = new MobileDetect(); return $detector->isMobile(); }); Request::addDetector('tablet', function ($request) { $detector = new MobileDetect(); return $detector->isTablet(); }); $this->event = new Event('Controller.beforeFilter'); $this->Controller = new MobileComponentTestController(new Request()); $this->Controller->request->session()->delete('User'); Configure::delete('User'); }
/** * Display all flash messages. * * TODO: export div wrapping method (for static messaging on a page) * * @param array $types Types to output. Defaults to all if none are specified. * @return string HTML */ public function render(array $types = []) { // Get the messages from the session $messages = (array) $this->request->session()->read('FlashMessage'); $cMessages = (array) Configure::read('FlashMessage'); if (!empty($cMessages)) { $messages = (array) Hash::merge($messages, $cMessages); } $html = ''; if (!empty($messages)) { $html = '<div class="flash-messages">'; if ($types) { foreach ($types as $type) { // Add a div for each message using the type as the class. foreach ($messages as $messageType => $msgs) { if ($messageType !== $type) { continue; } foreach ((array) $msgs as $msg) { $html .= $this->_message($msg, $messageType); } } } } else { foreach ($messages as $messageType => $msgs) { foreach ((array) $msgs as $msg) { $html .= $this->_message($msg, $messageType); } } } $html .= '</div>'; if ($types) { foreach ($types as $type) { $this->request->session()->delete('FlashMessage.' . $type); Configure::delete('FlashMessage.' . $type); } } else { $this->request->session()->delete('FlashMessage'); Configure::delete('FlashMessage'); } } return $html; }
public function setUp() { parent::setUp(); Configure::write('Config.language', 'eng'); Configure::write('App.base', ''); Configure::write('App.namespace', 'BootstrapUI\\Test\\TestCase\\View\\Helper'); Configure::delete('Asset'); $this->View = new View(); $this->Form = new FormHelper($this->View); $request = new Request('articles/add'); $request->here = '/articles/add'; $request['controller'] = 'articles'; $request['action'] = 'add'; $request->webroot = ''; $request->base = ''; $this->Form->Url->request = $this->Form->request = $request; $this->article = ['schema' => ['id' => ['type' => 'integer'], 'author_id' => ['type' => 'integer', 'null' => true], 'title' => ['type' => 'string', 'null' => true], 'body' => 'text', 'published' => ['type' => 'boolean', 'length' => 1, 'default' => 0], '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]]], 'required' => ['author_id' => true, 'title' => true]]; Security::salt('foo!'); Router::connect('/:controller', ['action' => 'index']); Router::connect('/:controller/:action/*'); }
/** * test that default profile is used by constructor if available. * * @return void */ public function testDefaultProfile() { $config = ['test' => 'ok', 'test2' => true]; Configure::write('Email.default', $config); Email::config(Configure::consume('Email')); $Email = new Email(); $this->assertSame($Email->profile(), $config); Configure::delete('Email'); Email::drop('default'); }
/** * Additional bootstrapping and configuration for CLI environments should * be put here. */ try { Plugin::load('Bake'); } catch (MissingPluginException $e) { // Do not halt if the plugin is missing } /** * Cakebox: use Monolog to create a combined log (with all log levels) to enable * Logstash > Elasticsearch forwarding. This logger is different from the one in * bootstrap.php in that is uses the 'cli' prefix tag instead of 'app'. */ Log::config('default', function () { if (is_writable('/var/log/cakephp')) { $handler = new StreamHandler('/var/log/cakephp/cakebox.cli.log'); } else { $handler = new StreamHandler(LOGS . DS . 'cakebox.cli.log'); } $formatter = new LogstashFormatter('cakephp'); $handler->setFormatter($formatter); $log = new Logger('cli.cakebox', array($handler)); return $log; }); /** * Stop using the now redundant default CakePHP file loggers. */ Configure::delete('Log.debug'); Configure::delete('Log.error');
/** * setUp method * * @return void */ public function setUp() { parent::setUp(); Configure::write('Config.language', 'eng'); Configure::write('App.base', ''); Configure::write('App.namespace', 'Cake\\Test\\TestCase\\View\\Helper'); Configure::delete('Asset'); $this->View = new View(); $this->Form = new FormHelper($this->View); $request = new Request('articles/add'); $request->here = '/articles/add'; $request['controller'] = 'articles'; $request['action'] = 'add'; $request->webroot = ''; $request->base = ''; $this->Form->Url->request = $this->Form->request = $request; $this->dateRegex = ['daysRegex' => 'preg:/(?:<option value="0?([\\d]+)">\\1<\\/option>[\\r\\n]*)*/', 'monthsRegex' => 'preg:/(?:<option value="[\\d]+">[\\w]+<\\/option>[\\r\\n]*)*/', 'yearsRegex' => 'preg:/(?:<option value="([\\d]+)">\\1<\\/option>[\\r\\n]*)*/', 'hoursRegex' => 'preg:/(?:<option value="0?([\\d]+)">\\1<\\/option>[\\r\\n]*)*/', 'minutesRegex' => 'preg:/(?:<option value="([\\d]+)">0?\\1<\\/option>[\\r\\n]*)*/', 'meridianRegex' => 'preg:/(?:<option value="(am|pm)">\\1<\\/option>[\\r\\n]*)*/']; $this->article = ['schema' => ['id' => ['type' => 'integer'], 'author_id' => ['type' => 'integer', 'null' => true], 'title' => ['type' => 'string', 'null' => true], 'body' => 'text', 'published' => ['type' => 'string', 'length' => 1, 'default' => 'N'], '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]]], 'required' => ['author_id' => true, 'title' => true]]; Security::salt('foo!'); Router::connect('/:controller', ['action' => 'index']); Router::connect('/:controller/:action/*'); }
/** * test that store and restore only store/restore the provided data. * * @return void */ public function testStoreAndRestoreWithData() { Cache::enable(); Cache::config('configure', ['className' => 'File', 'path' => TMP . 'tests']); Configure::write('testing', 'value'); Configure::store('store_test', 'configure', ['store_test' => 'one']); Configure::delete('testing'); $this->assertNull(Configure::read('store_test'), 'Calling store with data shouldn\'t modify runtime.'); Configure::restore('store_test', 'configure'); $this->assertEquals('one', Configure::read('store_test')); $this->assertNull(Configure::read('testing'), 'Values that were not stored are not restored.'); Cache::delete('store_test', 'configure'); Cache::drop('configure'); }
/** * test that default profile is used by constructor if available. * * @return void */ public function testDefaultProfile() { $config = ['test' => 'ok', 'test2' => true]; Configure::write('Notification.default', $config); Notification::config(Configure::consume('Notification')); $Notification = new Notification(); $this->assertSame($Notification->profile(), $config); Configure::delete('Notification'); Notification::drop('default'); }
public function testNoAddressFormat() { Configure::delete('Contact.addressFormat'); $result = $this->Entity->setAddressFormat(); $this->assertFalse($result); }
/** * @return void */ public function tearDown() { Configure::delete('Shim'); parent::tearDown(); }
/** * setUp method * * @return void */ public function setUp() { parent::setUp(); Configure::delete('Config.language'); $this->request = new Request(); }
public function setUp() { parent::setUp(); Configure::delete('Pdf'); }
public function setUp() { parent::setUp(); Configure::delete('Google'); $this->GoogleMapV3 = new GoogleMapV3Helper(new View(null)); }
/** * Start Test callback * * @param string $method * @return void */ public function setUp() { Configure::delete('Ratings'); parent::setUp(); $this->Ratings = TableRegistry::get('Ratings.Ratings'); }
<?php /** * test_app routes.php. Remove configuration settings from any previous tests * before loading plugin routes.php file. */ use Cake\Core\Configure; Configure::delete('Swagger'); require ROOT . 'config/routes.php';
/** * Tests fetching available Roles from Configure and database * * @return void */ public function testAvailableRoles() { $object = new TestTinyAuthorize($this->collection, ['rolesTable' => 'Roles']); // Make protected function available $reflection = new ReflectionClass(get_class($object)); $method = $reflection->getMethod('_getAvailableRoles'); $method->setAccessible(true); // Test against roles array in Configure $expected = ['user' => 1, 'moderator' => 2, 'admin' => 3]; $res = $method->invoke($object); $this->assertEquals($expected, $res); // Test against roles from database Configure::delete('Roles'); $object = new TestTinyAuthorize($this->collection, ['rolesTable' => 'DatabaseRoles']); $expected = ['user' => 11, 'moderator' => 12, 'admin' => 13]; $res = $method->invoke($object); $this->assertEquals($expected, $res); }
/** * Make sure missing library in the configuration throws an exception * when running the shell `makedocs` command. * * @expectedException \InvalidArgumentException * @expectedExceptionMessage Swagger configuration file does not contain a library section */ public function testMakeDocsWithMissingLibrary() { $reflection = self::getReflection($this->lib); Configure::delete('Swagger.library'); $reflection->methods->makeDocs->invokeArgs($this->lib, ['www.test.app']); }
/** * BugsnagLogTest::tearDown() * * @return void */ public function tearDown() { Configure::delete('Bugsnag.apiKey'); unset($this->client); parent::tearDown(); }