/** * tearDown method * * @return void */ public function tearDown() { Configure::delete('TestMailerConfig'); unset($this->Mailer); ClassRegistry::flush(); parent::tearDown(); }
/** * SetUp method * * @return void */ public function setUp() { parent::setUp(); Configure::delete('Typography.locale'); Configure::write('App.language', 'eng'); $this->Typography = new TypographyHelper(new View(null)); }
public function setUp() { parent::setUp(); Configure::delete('Localization'); $this->Model = ClassRegistry::init('PaymentMethod'); $this->Model->Behaviors->load('Tools.DecimalInput', ['fields' => ['rel_rate', 'set_rate'], 'output' => true]); }
public function setUp() { parent::setUp(); Configure::delete('Localization'); $this->Model = ClassRegistry::init('PaymentMethod'); $this->Model->Behaviors->load('Tools.NumberFormat', array('fields' => array('rel_rate', 'set_rate'), 'output' => true)); }
public function setUp() { parent::setUp(); Configure::delete('Ajax'); $this->Controller = new AjaxComponentTestController(new CakeRequest(), new CakeResponse()); $this->Controller->constructClasses(); }
/** * SetUp method * * @return void */ public function setUp() { parent::setUp(); Configure::write('Config.language', 'deu'); Configure::delete('Passwordable'); Configure::write('Passwordable.auth', 'AuthTest'); $this->User = ClassRegistry::init('Tools.ToolsUser'); if (isset($this->User->validate['pwd'])) { unset($this->User->validate['pwd']); } if (isset($this->User->validate['pwd_repeat'])) { unset($this->User->validate['pwd_repeat']); } if (isset($this->User->validate['pwd_current'])) { unset($this->User->validate['pwd_current']); } if (isset($this->User->order)) { unset($this->User->order); } $this->User->create(); $data = ['id' => '5', 'name' => 'admin', 'password' => Security::hash('somepwd', null, true), 'role_id' => '1']; $this->User->set($data); $result = $this->User->save(); $this->assertTrue((bool) $result); Router::setRequestInfo(new CakeRequest(null, false)); }
public function endCase() { if (Configure::read('TestConfig')) { Configure::delete('TestConfig'); } parent::endCase(); }
function tearDown() { ConnectionManager::drop('testapi'); ConnectionManager::drop('testapiToken'); Configure::delete('Copula.testapi.Auth'); unset($this->controller, $this->Oauth); parent::tearDown(); }
/** * setUp * * @retun void * @access public */ public function setUp() { parent::setUp(); Configure::delete('PagSeguro'); $this->Controller = new Controller(null); $this->Checkout = new CheckoutComponent($this->Controller->Components); $this->Checkout->startup($this->Controller); }
public function endTest($method = null) { Configure::delete(TestDisableActionsComponent::$testConfigName); if ($this->_configBackup !== false) { Configure::write(TestDisableActionsComponent::$testConfigName, $this->_configBackup); } parent::endTest($method); }
/** * Returns whether the local MTA is qmail or not. * This refers to the Configure to skip the auto-detection. * * @override * @return boolean */ function isQmail() { $is_qmail = Configure::read('Qdmailer.is_qmail'); if (!is_null($is_qmail)) { $this->is_qmail = $is_qmail; } Configure::delete('Qdmailer.is_qmail'); return parent::isQmail(); }
public function setUp() { parent::setUp(); Configure::delete('Auth'); $this->Controller = new AuthExtTestController(new CakeRequest(), new CakeResponse()); $this->Controller->constructClasses(); $this->Controller->startupProcess(); $this->Controller->User->belongsTo = ['Role' => ['className' => 'Tools.Role']]; }
public function setUp() { parent::setUp(); Configure::delete('Logable'); Configure::write('Config.language', 'eng'); $this->LogableBook = ClassRegistry::init('LogableBook'); $this->Log = ClassRegistry::init('LogableLog'); $this->LogableUser = ClassRegistry::init('LogableUser'); $this->LogableComment = ClassRegistry::init('LogableComment'); }
/** * setUp method * * @return void */ public function setUp() { parent::setUp(); @($View = new View()); $this->Facebook = new FacebookHelper($View); $this->Facebook->Html = new HtmlHelper($View); $this->Facebook->Html->request = new CakeRequest(null, false); $this->Facebook->Html->request->webroot = ''; Configure::delete('Facebook.appId'); Configure::write('Facebook.appId', '12345'); }
/** * Test the seedability check on init * * @return void * @covers ::initialize * @covers ::_checkSeedable */ public function testNotSeedable() { Configure::delete('FakeSeeder.seedable'); $this->_shell->expects($this->at(0))->method('_stop')->with($this->equalTo('Seeding is not activated in configuration in "FakeSeeder.seedable"!')); $this->_shell->initialize(); $debug = Configure::read('debug'); Configure::write('debug', 0); $this->_shell->expects($this->at(1))->method('_stop')->with($this->equalTo('Seeding is allowed only in debug mode!')); $this->_shell->initialize(); Configure::write('debug', $debug); }
/** * setUp method * * @return void */ public function setUp() { parent::setUp(); Configure::write('Config.language', 'jp'); Configure::write('App.base', ''); Configure::delete('Asset'); $this->_View = new BcAppView(); $this->_View->request = $this->_getRequest('/contacts/add'); $this->BcForm = new BcFormHelper($this->_View); $this->BcTime = new BcTimeHelper($this->_View); }
public function endTest($method) { unset($this->Geocodable); unset($this->Address); unset($this->TestGeocodable); Configure::delete('Geocode'); ClassRegistry::flush(); if (!empty($this->configuredGeocode)) { Configure::write('Geocode', $this->configuredGeocode); } }
/** * SetUp method * * @return void */ public function setUp() { parent::setUp(); $this->Controller = new MobileComponentTestController(new CakeRequest(null, false), new CakeResponse()); $this->Controller->constructClasses(); $this->Controller->Mobile->Controller = $this->Controller; CakeSession::write('User', ''); CakeSession::delete('User'); CakeSession::write('Session', ''); CakeSession::delete('Session'); Configure::delete('User'); }
/** * setUp method * * @return void */ public function setUp() { parent::setUp(); Configure::write('Config.language', 'jp'); Configure::write('App.base', ''); Configure::delete('Asset'); $this->BcFreeze = new BcFreezeHelper(new View()); $this->BcFreeze->request = new CakeRequest('contacts/add', false); $this->BcFreeze->request->here = '/contacts/add'; $this->BcFreeze->request['action'] = 'add'; $this->BcFreeze->request->webroot = ''; $this->BcFreeze->request->base = ''; }
public function testRead() { $this->_configTestFile('yaml_reader'); Configure::load('i18n', 'I18nYamlTestConfig'); $expected = 'パスが指定されていないか不正です。'; $result = Configure::read('i18n.hoge.fuga'); $this->assertEqual($expected, $result); $result = Configure::delete('i18n'); $this->_configTestFile(array('path' => App::pluginPath('YamlReader') . 'Test' . DS . 'files' . DS, 'domain' => 'yaml_reader')); Configure::load('i18n', 'I18nYamlTestConfig'); $expected = 'パスが指定されていないか不正です。'; $result = Configure::read('i18n.hoge.fuga'); $this->assertEqual($expected, $result); }
public function testRead() { $this->_configTestFile(); Configure::load('spyc', 'YamlTestConfig'); $expected = array(array('name' => 'spartan', 'notes' => array('Needs to be backed up', 'Needs to be normalized'), 'type' => 'mysql')); $this->assertIdentical(Configure::read('spyc.databases'), $expected); Configure::drop('YamlTestConfig'); Configure::delete('spyc'); $this->_configTestFile(array('path' => App::pluginPath('YamlReader') . 'Test' . DS . 'files' . DS)); Configure::load('spyc', 'YamlTestConfig'); $this->assertIdentical(Configure::read('spyc.databases'), $expected); $this->_configTestFile(null, false); Configure::load('spyc', 'YamlTestConfig'); $this->assertIdentical(Configure::read('databases'), $expected); }
/** * Start Test * * @return void */ public function setUp() { parent::setUp(); $menu = array(array('title' => 'Item 1', 'url' => '/item-1'), array('title' => 'Item 2', 'url' => '/item-2')); $guest = array('User' => array('group' => '')); $user = array('User' => array('group' => 'user')); $admin = array('User' => array('group' => 'admin')); Configure::delete('Routing.prefixes'); $this->Controller = new Controller(); $this->Controller->set(compact('menu')); $this->Controller->set(compact('guest')); $this->Controller->set(compact('user')); $this->Controller->set(compact('admin')); $this->View = new View($this->Controller); $this->View->request = new CakeRequest(null, false); $this->MenuBuilder = new MenuBuilderHelper($this->View); }
public function testSetCurrentUser() { Configure::delete('CurrentUser'); $this->assertFalse($this->Model->setCurrentUser()); Configure::write('CurrentUser.id', 1); $this->assertTrue($this->Model->setCurrentUser()); $this->assertEqual($this->Model->data['CurrentUserBehaviorMockModel']['user_id'], 1); $this->Model->data = array(); $data = array($this->Model->alias => array('hoge' => 'piyo')); $this->Model->set($data); $this->Model->setCurrentUser(); $this->assertEqual($this->Model->data['CurrentUserBehaviorMockModel']['user_id'], 1); $data[$this->Model->alias]['user_id'] = 2; $this->Model->data = array(); $this->Model->set($data); $this->Model->setCurrentUser(); $this->assertEqual($this->Model->data['CurrentUserBehaviorMockModel']['user_id'], 1); }
/** * __construct * @param array $config * @param string $path */ public function __construct($config = array(), $path = null) { if (!$path) { $path = APP . 'Config' . DS; } Configure::delete('Oven'); if (empty($config)) { $try = array($path . 'oven.json', $path . 'oven.php'); foreach ($try as $cfg) { if (file_exists($cfg)) { $this->path = $cfg; $ext = strrchr($cfg, '.'); switch ($ext) { case '.json': App::uses('File', 'Utility'); $cfg = new File($cfg); $this->config = json_decode($cfg->read(), true); break; case '.yaml': App::import('Vendor', 'Oven.spyc/spyc'); $this->config = Spyc::YAMLLoad($cfg); break; default: App::uses('PhpReader', 'Configure'); Configure::config('oven', new PhpReader(dirname($cfg) . DS)); Configure::load('oven', 'oven'); $this->config = Configure::read('Oven'); break; } break; } } // IF NO CONFIG COPY OVER SAMPLE if (empty($this->config)) { if (copy(CakePlugin::path('Oven') . 'Config' . DS . 'config.json', $path . 'oven.json')) { $this->__construct(); } } } else { $this->config = $config; } $this->config = $this->_default($this->config); Configure::write('Oven', $this->config); }
/** * 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 flash(array $types = array()) { // Get the messages from the session $messages = (array) $this->Session->read('messages'); $cMessages = (array) Configure::read('messages'); if (!empty($cMessages)) { $messages = (array) Hash::merge($messages, $cMessages); } $html = ''; if (!empty($messages)) { $html = '<div class="flash-messages flashMessages">'; 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) { CakeSession::delete('messages.' . $type); Configure::delete('messages.' . $type); } } else { CakeSession::delete('messages'); Configure::delete('messages'); } } return $html; }
/** * setUp method * * @return void */ public function setUp() { parent::setUp(); Configure::write('Config.language', 'eng'); Configure::write('App.base', ''); Configure::delete('Asset'); $this->Controller = new ContactTestController(); $this->View = new View($this->Controller); CakePlugin::load('Bs3Helpers', array('bootstrap' => true)); $this->Form = new Bs3FormHelper($this->View); $this->Form->request = new CakeRequest('contacts/add', false); $this->Form->request->here = '/contacts/add'; $this->Form->request['action'] = 'add'; $this->Form->request->webroot = ''; $this->Form->request->base = ''; ClassRegistry::addObject('Contact', new Contact()); $this->Contact = ClassRegistry::init('Contact'); $this->oldSalt = Configure::read('Security.salt'); Configure::write('Security.salt', 'foo!'); }
/** * tearDown method * * @return void */ public function tearDown() { parent::tearDown(); Configure::delete('Asset'); CakePlugin::unload(); unset($this->Helper, $this->View); }
/** * setUp method * * @return void */ public function setUp() { parent::setUp(); Configure::delete('Config.language'); }
/** * testFilteringAndTimestamping method * * @access public * @return void */ function testFilteringAndTimestamping() { if ($this->skipIf(!is_writable(JS), 'JavaScript directory not writable, skipping JS asset timestamp tests. %s')) { return; } cache(str_replace(WWW_ROOT, '', JS) . '__cake_js_test.js', 'alert("test")', '+999 days', 'public'); $timestamp = substr(strtotime('now'), 0, 8); Configure::write('Asset.timestamp', true); $result = $this->Javascript->link('__cake_js_test'); $this->assertPattern('/^<script[^<>]+src=".*js\\/__cake_js_test\\.js\\?' . $timestamp . '[0-9]{2}"[^<>]*>/', $result); $debug = Configure::read('debug'); Configure::write('debug', 0); $result = $this->Javascript->link('__cake_js_test'); $expected = '<script type="text/javascript" src="js/__cake_js_test.js"></script>'; $this->assertEqual($result, $expected); Configure::write('Asset.timestamp', 'force'); $result = $this->Javascript->link('__cake_js_test'); $this->assertPattern('/^<script[^<>]+src=".*js\\/__cake_js_test.js\\?' . $timestamp . '[0-9]{2}"[^<>]*>/', $result); Configure::write('debug', $debug); Configure::write('Asset.timestamp', false); $old = Configure::read('Asset.filter.js'); Configure::write('Asset.filter.js', 'js.php'); $result = $this->Javascript->link('__cake_js_test'); $this->assertPattern('/^<script[^<>]+src=".*cjs\\/__cake_js_test\\.js"[^<>]*>/', $result); Configure::write('Asset.filter.js', true); $result = $this->Javascript->link('jquery-1.1.2'); $expected = '<script type="text/javascript" src="cjs/jquery-1.1.2.js"></script>'; $this->assertEqual($result, $expected); $result = $this->Javascript->link('folderjs/jquery-1.1.2'); $expected = '<script type="text/javascript" src="cjs/folderjs/jquery-1.1.2.js"></script>'; $this->assertEqual($result, $expected); if ($old === null) { Configure::delete('Asset.filter.js'); } $debug = Configure::read('debug'); $webroot = $this->Javascript->webroot; Configure::write('debug', 0); Configure::write('Asset.timestamp', 'force'); $this->Javascript->webroot = '/testing/'; $result = $this->Javascript->link('__cake_js_test'); $this->assertPattern('/^<script[^<>]+src="\\/testing\\/js\\/__cake_js_test\\.js\\?\\d+"[^<>]*>/', $result); $this->Javascript->webroot = '/testing/longer/'; $result = $this->Javascript->link('__cake_js_test'); $this->assertPattern('/^<script[^<>]+src="\\/testing\\/longer\\/js\\/__cake_js_test\\.js\\?\\d+"[^<>]*>/', $result); $this->Javascript->webroot = $webroot; Configure::write('debug', $debug); unlink(JS . '__cake_js_test.js'); }
/** * setUp method * * @return void */ public function setUp() { parent::setUp(); Configure::write('Config.language', 'eng'); Configure::write('App.base', ''); Configure::delete('Asset'); $this->Controller = new ContactTestController(); $this->View = new View($this->Controller); $this->Form = new FormHelper($this->View); $this->Form->Html = new HtmlHelper($this->View); $this->Form->request = new CakeRequest('contacts/add', false); $this->Form->request->here = '/contacts/add'; $this->Form->request['action'] = 'add'; $this->Form->request->webroot = ''; $this->Form->request->base = ''; ClassRegistry::addObject('Contact', new Contact()); ClassRegistry::addObject('ContactNonStandardPk', new ContactNonStandardPk()); ClassRegistry::addObject('OpenidUrl', new OpenidUrl()); ClassRegistry::addObject('User', new UserForm()); ClassRegistry::addObject('ValidateItem', new ValidateItem()); ClassRegistry::addObject('ValidateUser', new ValidateUser()); ClassRegistry::addObject('ValidateProfile', new ValidateProfile()); $this->oldSalt = Configure::read('Security.salt'); $this->dateRegex = array('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]*)*/'); Configure::write('Security.salt', 'foo!'); }