code
stringlengths
31
1.39M
docstring
stringlengths
23
16.8k
func_name
stringlengths
1
126
language
stringclasses
1 value
repo
stringlengths
7
63
path
stringlengths
7
166
url
stringlengths
50
220
license
stringclasses
7 values
function startCase() { $this->_aclDb = Configure::read('Acl.database'); $this->_aclClass = Configure::read('Acl.classname'); Configure::write('Acl.database', 'test_suite'); Configure::write('Acl.classname', 'DbAcl'); }
configure Configure for testcase @return void @access public
startCase
php
Datawalke/Coordino
cake/tests/cases/console/libs/acl.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/acl.test.php
MIT
function endCase() { Configure::write('Acl.database', $this->_aclDb); Configure::write('Acl.classname', $this->_aclClass); }
restore Environment settings @return void @access public
endCase
php
Datawalke/Coordino
cake/tests/cases/console/libs/acl.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/acl.test.php
MIT
function startTest() { $this->Dispatcher =& new TestAclShellMockShellDispatcher(); $this->Task =& new MockAclShell($this->Dispatcher); $this->Task->Dispatch =& $this->Dispatcher; $this->Task->params['datasource'] = 'test_suite'; $this->Task->Acl =& new AclComponent(); $controller = null; $this->Task->Acl->startup($controller); }
startTest method @return void @access public
startTest
php
Datawalke/Coordino
cake/tests/cases/console/libs/acl.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/acl.test.php
MIT
function testViewWithModelForeignKeyOutput() { $this->Task->command = 'view'; $this->Task->startup(); $data = array( 'parent_id' => null, 'model' => 'MyModel', 'foreign_key' => 2, ); $this->Task->Acl->Aro->create($data); $this->Task->Acl->Aro->save(); $this->Task->args[0] = 'aro'; $this->Task->expectAt(0, 'out', array('Aro tree:')); $this->Task->expectAt(1, 'out', array(new PatternExpectation('/\[1\] ROOT/'))); $this->Task->expectAt(3, 'out', array(new PatternExpectation('/\[3\] Gandalf/'))); $this->Task->expectAt(5, 'out', array(new PatternExpectation('/\[5\] MyModel.2/'))); $this->Task->view(); }
test that model.foreign_key output works when looking at acl rows @return void @access public
testViewWithModelForeignKeyOutput
php
Datawalke/Coordino
cake/tests/cases/console/libs/acl.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/acl.test.php
MIT
function testViewWithArgument() { $this->Task->args = array('aro', 'admins'); $this->Task->expectAt(0, 'out', array('Aro tree:')); $this->Task->expectAt(1, 'out', array(' [2] admins')); $this->Task->expectAt(2, 'out', array(' [3] Gandalf')); $this->Task->expectAt(3, 'out', array(' [4] Elrond')); $this->Task->view(); }
test view with an argument @return void @access public
testViewWithArgument
php
Datawalke/Coordino
cake/tests/cases/console/libs/acl.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/acl.test.php
MIT
function testParsingModelAndForeignKey() { $result = $this->Task->parseIdentifier('Model.foreignKey'); $expected = array('model' => 'Model', 'foreign_key' => 'foreignKey'); $result = $this->Task->parseIdentifier('mySuperUser'); $this->assertEqual($result, 'mySuperUser'); $result = $this->Task->parseIdentifier('111234'); $this->assertEqual($result, '111234'); }
test the method that splits model.foreign key. and that it returns an array. @return void @access public
testParsingModelAndForeignKey
php
Datawalke/Coordino
cake/tests/cases/console/libs/acl.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/acl.test.php
MIT
function testCreate() { $this->Task->args = array('aro', 'root', 'User.1'); $this->Task->expectAt(0, 'out', array(new PatternExpectation('/created/'), '*')); $this->Task->create(); $Aro =& ClassRegistry::init('Aro'); $Aro->cacheQueries = false; $result = $Aro->read(); $this->assertEqual($result['Aro']['model'], 'User'); $this->assertEqual($result['Aro']['foreign_key'], 1); $this->assertEqual($result['Aro']['parent_id'], null); $id = $result['Aro']['id']; $this->Task->args = array('aro', 'User.1', 'User.3'); $this->Task->expectAt(1, 'out', array(new PatternExpectation('/created/'), '*')); $this->Task->create(); $Aro =& ClassRegistry::init('Aro'); $result = $Aro->read(); $this->assertEqual($result['Aro']['model'], 'User'); $this->assertEqual($result['Aro']['foreign_key'], 3); $this->assertEqual($result['Aro']['parent_id'], $id); $this->Task->args = array('aro', 'root', 'somealias'); $this->Task->expectAt(2, 'out', array(new PatternExpectation('/created/'), '*')); $this->Task->create(); $Aro =& ClassRegistry::init('Aro'); $result = $Aro->read(); $this->assertEqual($result['Aro']['alias'], 'somealias'); $this->assertEqual($result['Aro']['model'], null); $this->assertEqual($result['Aro']['foreign_key'], null); $this->assertEqual($result['Aro']['parent_id'], null); }
test creating aro/aco nodes @return void @access public
testCreate
php
Datawalke/Coordino
cake/tests/cases/console/libs/acl.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/acl.test.php
MIT
function testDelete() { $this->Task->args = array('aro', 'AuthUser.1'); $this->Task->expectAt(0, 'out', array(new NoPatternExpectation('/not/'), true)); $this->Task->delete(); $Aro =& ClassRegistry::init('Aro'); $result = $Aro->read(null, 3); $this->assertFalse($result); }
test the delete method with different node types. @return void @access public
testDelete
php
Datawalke/Coordino
cake/tests/cases/console/libs/acl.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/acl.test.php
MIT
function testSetParent() { $this->Task->args = array('aro', 'AuthUser.2', 'root'); $this->Task->setParent(); $Aro =& ClassRegistry::init('Aro'); $result = $Aro->read(null, 4); $this->assertEqual($result['Aro']['parent_id'], null); }
test setParent method. @return void @access public
testSetParent
php
Datawalke/Coordino
cake/tests/cases/console/libs/acl.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/acl.test.php
MIT
function testGrant() { $this->Task->args = array('AuthUser.2', 'ROOT/Controller1', 'create'); $this->Task->expectAt(0, 'out', array(new PatternExpectation('/Permission granted/'), true)); $this->Task->grant(); $node = $this->Task->Acl->Aro->read(null, 4); $this->assertFalse(empty($node['Aco'][0])); $this->assertEqual($node['Aco'][0]['Permission']['_create'], 1); }
test grant @return void @access public
testGrant
php
Datawalke/Coordino
cake/tests/cases/console/libs/acl.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/acl.test.php
MIT
function testDeny() { $this->Task->args = array('AuthUser.2', 'ROOT/Controller1', 'create'); $this->Task->expectAt(0, 'out', array(new PatternExpectation('/Permission denied/'), true)); $this->Task->deny(); $node = $this->Task->Acl->Aro->read(null, 4); $this->assertFalse(empty($node['Aco'][0])); $this->assertEqual($node['Aco'][0]['Permission']['_create'], -1); }
test deny @return void @access public
testDeny
php
Datawalke/Coordino
cake/tests/cases/console/libs/acl.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/acl.test.php
MIT
function testCheck() { $this->Task->args = array('AuthUser.2', 'ROOT/Controller1', '*'); $this->Task->expectAt(0, 'out', array(new PatternExpectation('/not allowed/'), true)); $this->Task->check(); $this->Task->args = array('AuthUser.2', 'ROOT/Controller1', 'create'); $this->Task->expectAt(1, 'out', array(new PatternExpectation('/Permission granted/'), true)); $this->Task->grant(); $this->Task->args = array('AuthUser.2', 'ROOT/Controller1', 'create'); $this->Task->expectAt(2, 'out', array(new PatternExpectation('/is allowed/'), true)); $this->Task->check(); $this->Task->args = array('AuthUser.2', 'ROOT/Controller1', '*'); $this->Task->expectAt(3, 'out', array(new PatternExpectation('/not allowed/'), true)); $this->Task->check(); }
test checking allowed and denied perms @return void @access public
testCheck
php
Datawalke/Coordino
cake/tests/cases/console/libs/acl.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/acl.test.php
MIT
function testInherit() { $this->Task->args = array('AuthUser.2', 'ROOT/Controller1', 'create'); $this->Task->expectAt(0, 'out', array(new PatternExpectation('/Permission granted/'), true)); $this->Task->grant(); $this->Task->args = array('AuthUser.2', 'ROOT/Controller1', 'all'); $this->Task->expectAt(1, 'out', array(new PatternExpectation('/permission inherited/i'), true)); $this->Task->inherit(); $node = $this->Task->Acl->Aro->read(null, 4); $this->assertFalse(empty($node['Aco'][0])); $this->assertEqual($node['Aco'][0]['Permission']['_create'], 0); }
test inherit and that it 0's the permission fields. @return void @access public
testInherit
php
Datawalke/Coordino
cake/tests/cases/console/libs/acl.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/acl.test.php
MIT
function testGetPath() { $this->Task->args = array('aro', 'AuthUser.2'); $this->Task->expectAt(1, 'out', array('[1] ROOT')); $this->Task->expectAt(2, 'out', array(' [2] admins')); $this->Task->expectAt(3, 'out', array(' [4] Elrond')); $this->Task->getPath(); }
test getting the path for an aro/aco @return void @access public
testGetPath
php
Datawalke/Coordino
cake/tests/cases/console/libs/acl.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/acl.test.php
MIT
function testInitDb() { $this->Task->Dispatch->expectOnce('dispatch'); $this->Task->initdb(); $this->assertEqual($this->Task->Dispatch->args, array('schema', 'create', 'DbAcl')); }
test that initdb makes the correct call. @return void
testInitDb
php
Datawalke/Coordino
cake/tests/cases/console/libs/acl.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/acl.test.php
MIT
function startTest() { $this->Dispatcher =& new ApiShellMockShellDispatcher(); $this->Shell =& new MockApiShell($this->Dispatcher); $this->Shell->Dispatch =& $this->Dispatcher; }
setUp method @return void @access public
startTest
php
Datawalke/Coordino
cake/tests/cases/console/libs/api.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/api.test.php
MIT
function testMethodNameDetection () { $this->Shell->setReturnValueAt(0, 'in', 'q'); $this->Shell->expectAt(0, 'out', array('Controller')); $expected = array( array( '1. afterFilter()', '2. beforeFilter()', '3. beforeRender()', '4. constructClasses()', '5. disableCache()', '6. flash($message, $url, $pause = 1, $layout = \'flash\')', '7. header($status)', '8. httpCodes($code = null)', '9. isAuthorized()', '10. loadModel($modelClass = null, $id = null)', '11. paginate($object = null, $scope = array(), $whitelist = array())', '12. postConditions($data = array(), $op = null, $bool = \'AND\', $exclusive = false)', '13. redirect($url, $status = null, $exit = true)', '14. referer($default = null, $local = false)', '15. render($action = null, $layout = null, $file = null)', '16. set($one, $two = null)', '17. setAction($action)', '18. shutdownProcess()', '19. startupProcess()', '20. validate()', '21. validateErrors()' ) ); $this->Shell->expectAt(1, 'out', $expected); $this->Shell->args = array('controller'); $this->Shell->paths['controller'] = CAKE_CORE_INCLUDE_PATH . DS . LIBS . 'controller' . DS; $this->Shell->main(); }
Test that method names are detected properly including those with no arguments. @return void @access public
testMethodNameDetection
php
Datawalke/Coordino
cake/tests/cases/console/libs/api.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/api.test.php
MIT
function startTest() { $this->Dispatch =& new BakeShellMockShellDispatcher(); $this->Shell =& new MockBakeShell(); $this->Shell->Dispatch =& $this->Dispatch; $this->Shell->Dispatch->shellPaths = App::path('shells'); }
start test @return void @access public
startTest
php
Datawalke/Coordino
cake/tests/cases/console/libs/bake.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/bake.test.php
MIT
function endTest() { unset($this->Dispatch, $this->Shell); }
endTest method @return void @access public
endTest
php
Datawalke/Coordino
cake/tests/cases/console/libs/bake.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/bake.test.php
MIT
function testAllWithModelName() { App::import('Model', 'User'); $userExists = class_exists('User'); if ($this->skipIf($userExists, 'User class exists, cannot test `bake all [param]`. %s')) { return; } $this->Shell->Model =& new BakeShellMockModelTask(); $this->Shell->Controller =& new BakeShellMockControllerTask(); $this->Shell->View =& new BakeShellMockModelTask(); $this->Shell->DbConfig =& new BakeShellMockDbConfigTask(); $this->Shell->DbConfig->expectOnce('getConfig'); $this->Shell->DbConfig->setReturnValue('getConfig', 'test_suite'); $this->Shell->Model->setReturnValue('bake', true); $this->Shell->Model->expectNever('getName'); $this->Shell->Model->expectOnce('bake'); $this->Shell->Controller->expectOnce('bake'); $this->Shell->Controller->setReturnValue('bake', true); $this->Shell->View->expectOnce('execute'); $this->Shell->expectAt(0, 'out', array('Bake All')); $this->Shell->expectAt(1, 'out', array('User Model was baked.')); $this->Shell->expectAt(2, 'out', array('User Controller was baked.')); $this->Shell->expectAt(3, 'out', array('User Views were baked.')); $this->Shell->expectAt(4, 'out', array('Bake All complete')); $this->Shell->params = array(); $this->Shell->args = array('User'); $this->Shell->all(); }
test bake all @return void @access public
testAllWithModelName
php
Datawalke/Coordino
cake/tests/cases/console/libs/bake.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/bake.test.php
MIT
function startTest() { $this->Dispatcher =& new TestSchemaShellMockShellDispatcher(); $this->Shell =& new MockSchemaShell($this->Dispatcher); $this->Shell->Dispatch =& $this->Dispatcher; }
startTest method @return void @access public
startTest
php
Datawalke/Coordino
cake/tests/cases/console/libs/schema.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/schema.test.php
MIT
function testStartup() { $this->Shell->startup(); $this->assertTrue(isset($this->Shell->Schema)); $this->assertTrue(is_a($this->Shell->Schema, 'CakeSchema')); $this->assertEqual(strtolower($this->Shell->Schema->name), strtolower(APP_DIR)); $this->assertEqual($this->Shell->Schema->file, 'schema.php'); unset($this->Shell->Schema); $this->Shell->params = array( 'name' => 'TestSchema' ); $this->Shell->startup(); $this->assertEqual($this->Shell->Schema->name, 'TestSchema'); $this->assertEqual($this->Shell->Schema->file, 'test_schema.php'); $this->assertEqual($this->Shell->Schema->connection, 'default'); $this->assertEqual($this->Shell->Schema->path, APP . 'config' . DS . 'schema'); unset($this->Shell->Schema); $this->Shell->params = array( 'file' => 'other_file.php', 'connection' => 'test_suite', 'path' => '/test/path' ); $this->Shell->startup(); $this->assertEqual(strtolower($this->Shell->Schema->name), strtolower(APP_DIR)); $this->assertEqual($this->Shell->Schema->file, 'other_file.php'); $this->assertEqual($this->Shell->Schema->connection, 'test_suite'); $this->assertEqual($this->Shell->Schema->path, '/test/path'); }
test startup method @return void @access public
testStartup
php
Datawalke/Coordino
cake/tests/cases/console/libs/schema.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/schema.test.php
MIT
function testView() { $this->Shell->startup(); $this->Shell->Schema->path = APP . 'config' . DS . 'schema'; $this->Shell->params['file'] = 'i18n.php'; $this->Shell->expectOnce('_stop'); $this->Shell->expectOnce('out'); $this->Shell->view(); }
Test View - and that it dumps the schema file to stdout @return void @access public
testView
php
Datawalke/Coordino
cake/tests/cases/console/libs/schema.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/schema.test.php
MIT
function testViewWithPlugins() { App::build(array( 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS) )); $this->Shell->args = array('TestPlugin.schema'); $this->Shell->startup(); $this->Shell->expectCallCount('_stop', 2); $this->Shell->expectCallCount('out', 2); $this->Shell->view(); $this->Shell->args = array(); $this->Shell->params = array('plugin' => 'TestPlugin'); $this->Shell->startup(); $this->Shell->view(); App::build(); }
test that view() can find plugin schema files. @return void @access public
testViewWithPlugins
php
Datawalke/Coordino
cake/tests/cases/console/libs/schema.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/schema.test.php
MIT
function testDumpWithFileWriting() { $this->Shell->params = array( 'name' => 'i18n', 'write' => TMP . 'tests' . DS . 'i18n.sql' ); $this->Shell->expectOnce('_stop'); $this->Shell->startup(); $this->Shell->dump(); $sql =& new File(TMP . 'tests' . DS . 'i18n.sql'); $contents = $sql->read(); $this->assertPattern('/DROP TABLE/', $contents); $this->assertPattern('/CREATE TABLE `i18n`/', $contents); $this->assertPattern('/id/', $contents); $this->assertPattern('/model/', $contents); $this->assertPattern('/field/', $contents); $this->assertPattern('/locale/', $contents); $this->assertPattern('/foreign_key/', $contents); $this->assertPattern('/content/', $contents); $sql->delete(); }
test dump() with sql file generation @return void @access public
testDumpWithFileWriting
php
Datawalke/Coordino
cake/tests/cases/console/libs/schema.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/schema.test.php
MIT
function testDumpFileWritingWithPlugins() { App::build(array( 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS) )); $this->Shell->args = array('TestPlugin.TestPluginApp'); $this->Shell->params = array( 'connection' => 'test_suite', 'write' => TMP . 'tests' . DS . 'dump_test.sql' ); $this->Shell->startup(); $this->Shell->expectOnce('_stop'); $this->Shell->dump(); $file =& new File(TMP . 'tests' . DS . 'dump_test.sql'); $contents = $file->read(); $this->assertPattern('/CREATE TABLE `acos`/', $contents); $this->assertPattern('/id/', $contents); $this->assertPattern('/model/', $contents); $file->delete(); App::build(); }
test that dump() can find and work with plugin schema files. @return void @access public
testDumpFileWritingWithPlugins
php
Datawalke/Coordino
cake/tests/cases/console/libs/schema.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/schema.test.php
MIT
function testGenerateSnaphot() { $this->Shell->path = TMP; $this->Shell->params['file'] = 'schema.php'; $this->Shell->args = array('snapshot'); $this->Shell->Schema =& new MockSchemaCakeSchema(); $this->Shell->Schema->setReturnValue('read', array('schema data')); $this->Shell->Schema->setReturnValue('write', true); $this->Shell->Schema->expectOnce('read'); $this->Shell->Schema->expectOnce('write', array(array('schema data', 'file' => 'schema_1.php'))); $this->Shell->generate(); }
test generate with snapshot generation @return void @access public
testGenerateSnaphot
php
Datawalke/Coordino
cake/tests/cases/console/libs/schema.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/schema.test.php
MIT
function testGenerateNoOverwrite() { touch(TMP . 'schema.php'); $this->Shell->params['file'] = 'schema.php'; $this->Shell->args = array(); $this->Shell->setReturnValue('in', 'q'); $this->Shell->Schema =& new MockSchemaCakeSchema(); $this->Shell->Schema->path = TMP; $this->Shell->Schema->expectNever('read'); $result = $this->Shell->generate(); unlink(TMP . 'schema.php'); }
test generate without a snapshot. @return void @access public
testGenerateNoOverwrite
php
Datawalke/Coordino
cake/tests/cases/console/libs/schema.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/schema.test.php
MIT
function testGenerateOverwrite() { touch(TMP . 'schema.php'); $this->Shell->params['file'] = 'schema.php'; $this->Shell->args = array(); $this->Shell->setReturnValue('in', 'o'); $this->Shell->expectAt(1, 'out', array(new PatternExpectation('/Schema file:\s[a-z\.]+\sgenerated/'))); $this->Shell->Schema =& new MockSchemaCakeSchema(); $this->Shell->Schema->path = TMP; $this->Shell->Schema->setReturnValue('read', array('schema data')); $this->Shell->Schema->setReturnValue('write', true); $this->Shell->Schema->expectOnce('read'); $this->Shell->Schema->expectOnce('write', array(array('schema data', 'file' => 'schema.php'))); $this->Shell->generate(); unlink(TMP . 'schema.php'); }
test generate with overwriting of the schema files. @return void @access public
testGenerateOverwrite
php
Datawalke/Coordino
cake/tests/cases/console/libs/schema.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/schema.test.php
MIT
function testGenerateWithPlugins() { App::build(array( 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS) )); $this->Shell->params = array( 'plugin' => 'TestPlugin', 'connection' => 'test_suite' ); $this->Shell->startup(); $this->Shell->Schema->path = TMP . 'tests' . DS; $this->Shell->generate(); $file =& new File(TMP . 'tests' . DS . 'schema.php'); $contents = $file->read(); $this->assertPattern('/class TestPluginSchema/', $contents); $this->assertPattern('/var \$posts/', $contents); $this->assertPattern('/var \$auth_users/', $contents); $this->assertPattern('/var \$authors/', $contents); $this->assertPattern('/var \$test_plugin_comments/', $contents); $this->assertNoPattern('/var \$users/', $contents); $this->assertNoPattern('/var \$articles/', $contents); $file->delete(); App::build(); }
test that generate() can read plugin dirs and generate schema files for the models in a plugin. @return void @access public
testGenerateWithPlugins
php
Datawalke/Coordino
cake/tests/cases/console/libs/schema.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/schema.test.php
MIT
function testCreateNoArgs() { $this->Shell->params = array( 'connection' => 'test_suite', 'path' => APP . 'config' . DS . 'sql' ); $this->Shell->args = array('i18n'); $this->Shell->startup(); $this->Shell->setReturnValue('in', 'y'); $this->Shell->create(); $db =& ConnectionManager::getDataSource('test_suite'); $sources = $db->listSources(); $this->assertTrue(in_array($db->config['prefix'] . 'i18n', $sources)); $schema =& new i18nSchema(); $db->execute($db->dropSchema($schema)); }
Test schema run create with no table args. @return void @access public
testCreateNoArgs
php
Datawalke/Coordino
cake/tests/cases/console/libs/schema.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/schema.test.php
MIT
function testCreateWithTableArgs() { $this->Shell->params = array( 'connection' => 'test_suite', 'name' => 'DbAcl', 'path' => APP . 'config' . DS . 'schema' ); $this->Shell->args = array('DbAcl', 'acos'); $this->Shell->startup(); $this->Shell->setReturnValue('in', 'y'); $this->Shell->create(); $db =& ConnectionManager::getDataSource('test_suite'); $sources = $db->listSources(); $this->assertTrue(in_array($db->config['prefix'] . 'acos', $sources)); $this->assertFalse(in_array($db->config['prefix'] . 'aros', $sources)); $this->assertFalse(in_array('aros_acos', $sources)); $db->execute('DROP TABLE ' . $db->config['prefix'] . 'acos'); }
Test schema run create with no table args. @return void @access public
testCreateWithTableArgs
php
Datawalke/Coordino
cake/tests/cases/console/libs/schema.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/schema.test.php
MIT
function testUpdateWithTable() { $this->Shell->params = array( 'connection' => 'test_suite', 'f' => true ); $this->Shell->args = array('SchemaShellTest', 'articles'); $this->Shell->startup(); $this->Shell->setReturnValue('in', 'y'); $this->Shell->update(); $article =& new Model(array('name' => 'Article', 'ds' => 'test_suite')); $fields = $article->schema(); $this->assertTrue(isset($fields['summary'])); $this->_fixtures['core.article']->drop($this->db); $this->_fixtures['core.article']->create($this->db); }
test run update with a table arg. @return void @access public
testUpdateWithTable
php
Datawalke/Coordino
cake/tests/cases/console/libs/schema.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/schema.test.php
MIT
function testPluginParam() { App::build(array( 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS) )); $this->Shell->params = array( 'plugin' => 'TestPlugin', 'connection' => 'test_suite' ); $this->Shell->startup(); $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS . 'config' . DS . 'schema'; $this->assertEqual($this->Shell->Schema->path, $expected); App::build(); }
test that the plugin param creates the correct path in the schema object. @return void @access public
testPluginParam
php
Datawalke/Coordino
cake/tests/cases/console/libs/schema.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/schema.test.php
MIT
function testPluginDotSyntaxWithCreate() { App::build(array( 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS) )); $this->Shell->params = array( 'connection' => 'test_suite' ); $this->Shell->args = array('TestPlugin.TestPluginApp'); $this->Shell->startup(); $this->Shell->setReturnValue('in', 'y'); $this->Shell->create(); $db =& ConnectionManager::getDataSource('test_suite'); $sources = $db->listSources(); $this->assertTrue(in_array($db->config['prefix'] . 'acos', $sources)); $db->execute('DROP TABLE ' . $db->config['prefix'] . 'acos'); App::build(); }
test that using Plugin.name with write. @return void @access public
testPluginDotSyntaxWithCreate
php
Datawalke/Coordino
cake/tests/cases/console/libs/schema.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/schema.test.php
MIT
function _stop($status = 0) { $this->stopped = $status; }
stop method @param integer $status @return void @access protected
_stop
php
Datawalke/Coordino
cake/tests/cases/console/libs/shell.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/shell.test.php
MIT
function setUp() { $this->Dispatcher =& new TestShellMockShellDispatcher(); $this->Shell =& new TestShell($this->Dispatcher); }
setUp method @return void @access public
setUp
php
Datawalke/Coordino
cake/tests/cases/console/libs/shell.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/shell.test.php
MIT
function testConstruct() { $this->assertIsA($this->Shell->Dispatch, 'TestShellMockShellDispatcher'); $this->assertEqual($this->Shell->name, 'TestShell'); $this->assertEqual($this->Shell->alias, 'TestShell'); }
testConstruct method @return void @access public
testConstruct
php
Datawalke/Coordino
cake/tests/cases/console/libs/shell.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/shell.test.php
MIT
function testInitialize() { App::build(array( 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS), 'models' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'models' . DS) ), true); $this->Shell->uses = array('TestPlugin.TestPluginPost'); $this->Shell->initialize(); $this->assertTrue(isset($this->Shell->TestPluginPost)); $this->assertIsA($this->Shell->TestPluginPost, 'TestPluginPost'); $this->assertEqual($this->Shell->modelClass, 'TestPluginPost'); $this->Shell->uses = array('Comment'); $this->Shell->initialize(); $this->assertTrue(isset($this->Shell->Comment)); $this->assertIsA($this->Shell->Comment, 'Comment'); $this->assertEqual($this->Shell->modelClass, 'Comment'); $this->Shell->uses = true; $this->Shell->initialize(); $this->assertTrue(isset($this->Shell->AppModel)); $this->assertIsA($this->Shell->AppModel, 'AppModel'); App::build(); }
testInitialize method @return void @access public
testInitialize
php
Datawalke/Coordino
cake/tests/cases/console/libs/shell.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/shell.test.php
MIT
function testIn() { $this->Shell->Dispatch->setReturnValueAt(0, 'getInput', 'n'); $this->Shell->Dispatch->expectAt(0, 'getInput', array('Just a test?', array('y', 'n'), 'n')); $result = $this->Shell->in('Just a test?', array('y', 'n'), 'n'); $this->assertEqual($result, 'n'); $this->Shell->Dispatch->setReturnValueAt(1, 'getInput', 'Y'); $this->Shell->Dispatch->expectAt(1, 'getInput', array('Just a test?', array('y', 'n'), 'n')); $result = $this->Shell->in('Just a test?', array('y', 'n'), 'n'); $this->assertEqual($result, 'Y'); $this->Shell->Dispatch->setReturnValueAt(2, 'getInput', 'y'); $this->Shell->Dispatch->expectAt(2, 'getInput', array('Just a test?', 'y,n', 'n')); $result = $this->Shell->in('Just a test?', 'y,n', 'n'); $this->assertEqual($result, 'y'); $this->Shell->Dispatch->setReturnValueAt(3, 'getInput', 'y'); $this->Shell->Dispatch->expectAt(3, 'getInput', array('Just a test?', 'y/n', 'n')); $result = $this->Shell->in('Just a test?', 'y/n', 'n'); $this->assertEqual($result, 'y'); $this->Shell->Dispatch->setReturnValueAt(4, 'getInput', 'y'); $this->Shell->Dispatch->expectAt(4, 'getInput', array('Just a test?', 'y', 'y')); $result = $this->Shell->in('Just a test?', 'y', 'y'); $this->assertEqual($result, 'y'); $this->Shell->Dispatch->setReturnValueAt(5, 'getInput', 'y'); $this->Shell->Dispatch->expectAt(5, 'getInput', array('Just a test?', array(0, 1, 2), 0)); $result = $this->Shell->in('Just a test?', array(0, 1, 2), 0); $this->assertEqual($result, 0); }
testIn method @return void @access public
testIn
php
Datawalke/Coordino
cake/tests/cases/console/libs/shell.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/shell.test.php
MIT
function testInNonInteractive() { $this->Shell->interactive = false; $result = $this->Shell->in('Just a test?', 'y/n', 'n'); $this->assertEqual($result, 'n'); }
Test in() when not interactive @return void
testInNonInteractive
php
Datawalke/Coordino
cake/tests/cases/console/libs/shell.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/shell.test.php
MIT
function testOut() { $this->Shell->Dispatch->expectAt(0, 'stdout', array("Just a test\n", false)); $this->Shell->out('Just a test'); $this->Shell->Dispatch->expectAt(1, 'stdout', array("Just\na\ntest\n", false)); $this->Shell->out(array('Just', 'a', 'test')); $this->Shell->Dispatch->expectAt(2, 'stdout', array("Just\na\ntest\n\n", false)); $this->Shell->out(array('Just', 'a', 'test'), 2); $this->Shell->Dispatch->expectAt(3, 'stdout', array("\n", false)); $this->Shell->out(); }
testOut method @return void @access public
testOut
php
Datawalke/Coordino
cake/tests/cases/console/libs/shell.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/shell.test.php
MIT
function testErr() { $this->Shell->Dispatch->expectAt(0, 'stderr', array("Just a test\n")); $this->Shell->err('Just a test'); $this->Shell->Dispatch->expectAt(1, 'stderr', array("Just\na\ntest\n")); $this->Shell->err(array('Just', 'a', 'test')); $this->Shell->Dispatch->expectAt(2, 'stderr', array("Just\na\ntest\n\n")); $this->Shell->err(array('Just', 'a', 'test'), 2); $this->Shell->Dispatch->expectAt(3, 'stderr', array("\n")); $this->Shell->err(); }
testErr method @return void @access public
testErr
php
Datawalke/Coordino
cake/tests/cases/console/libs/shell.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/shell.test.php
MIT
function testLoadTasks() { $this->assertTrue($this->Shell->loadTasks()); $this->Shell->tasks = null; $this->assertTrue($this->Shell->loadTasks()); $this->Shell->tasks = false; $this->assertTrue($this->Shell->loadTasks()); $this->Shell->tasks = true; $this->assertTrue($this->Shell->loadTasks()); $this->Shell->tasks = array(); $this->assertTrue($this->Shell->loadTasks()); // Fatal Error // $this->Shell->tasks = 'TestIDontExist'; // $this->assertFalse($this->Shell->loadTasks()); // $this->assertFalse(isset($this->Shell->TestIDontExist)); $this->Shell->tasks = 'TestApple'; $this->assertTrue($this->Shell->loadTasks()); $this->assertIsA($this->Shell->TestApple, 'TestAppleTask'); $this->Shell->tasks = 'TestBanana'; $this->assertTrue($this->Shell->loadTasks()); $this->assertIsA($this->Shell->TestApple, 'TestAppleTask'); $this->assertIsA($this->Shell->TestBanana, 'TestBananaTask'); unset($this->Shell->ShellTestApple, $this->Shell->TestBanana); $this->Shell->tasks = array('TestApple', 'TestBanana'); $this->assertTrue($this->Shell->loadTasks()); $this->assertIsA($this->Shell->TestApple, 'TestAppleTask'); $this->assertIsA($this->Shell->TestBanana, 'TestBananaTask'); }
testLoadTasks method @return void @access public
testLoadTasks
php
Datawalke/Coordino
cake/tests/cases/console/libs/shell.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/shell.test.php
MIT
function testShortPath() { $path = $expected = DS . 'tmp' . DS . 'ab' . DS . 'cd'; $this->assertEqual($this->Shell->shortPath($path), $expected); $path = $expected = DS . 'tmp' . DS . 'ab' . DS . 'cd' . DS ; $this->assertEqual($this->Shell->shortPath($path), $expected); $path = $expected = DS . 'tmp' . DS . 'ab' . DS . 'index.php'; $this->assertEqual($this->Shell->shortPath($path), $expected); // Shell::shortPath needs Folder::realpath // $path = DS . 'tmp' . DS . 'ab' . DS . '..' . DS . 'cd'; // $expected = DS . 'tmp' . DS . 'cd'; // $this->assertEqual($this->Shell->shortPath($path), $expected); $path = DS . 'tmp' . DS . 'ab' . DS . DS . 'cd'; $expected = DS . 'tmp' . DS . 'ab' . DS . 'cd'; $this->assertEqual($this->Shell->shortPath($path), $expected); $path = 'tmp' . DS . 'ab'; $expected = 'tmp' . DS . 'ab'; $this->assertEqual($this->Shell->shortPath($path), $expected); $path = 'tmp' . DS . 'ab'; $expected = 'tmp' . DS . 'ab'; $this->assertEqual($this->Shell->shortPath($path), $expected); $path = APP; $expected = DS . basename(APP) . DS; $this->assertEqual($this->Shell->shortPath($path), $expected); $path = APP . 'index.php'; $expected = DS . basename(APP) . DS . 'index.php'; $this->assertEqual($this->Shell->shortPath($path), $expected); }
testShortPath method @return void @access public
testShortPath
php
Datawalke/Coordino
cake/tests/cases/console/libs/shell.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/shell.test.php
MIT
function testCreateFile() { $this->skipIf(DIRECTORY_SEPARATOR === '\\', '%s Not supported on Windows'); $path = TMP . 'shell_test'; $file = $path . DS . 'file1.php'; new Folder($path, true); $this->Shell->interactive = false; $contents = "<?php\necho 'test';\n\$te = 'st';\n?>"; $result = $this->Shell->createFile($file, $contents); $this->assertTrue($result); $this->assertTrue(file_exists($file)); $this->assertEqual(file_get_contents($file), $contents); $contents = "<?php\necho 'another test';\n\$te = 'st';\n?>"; $result = $this->Shell->createFile($file, $contents); $this->assertTrue($result); $this->assertTrue(file_exists($file)); $this->assertEqual(file_get_contents($file), $contents); $this->Shell->interactive = true; $this->Shell->Dispatch->setReturnValueAt(0, 'getInput', 'n'); $this->Shell->Dispatch->expectAt(1, 'stdout', array('File exists, overwrite?', '*')); $contents = "<?php\necho 'yet another test';\n\$te = 'st';\n?>"; $result = $this->Shell->createFile($file, $contents); $this->assertFalse($result); $this->assertTrue(file_exists($file)); $this->assertNotEqual(file_get_contents($file), $contents); $this->Shell->Dispatch->setReturnValueAt(1, 'getInput', 'y'); $this->Shell->Dispatch->expectAt(3, 'stdout', array('File exists, overwrite?', '*')); $result = $this->Shell->createFile($file, $contents); $this->assertTrue($result); $this->assertTrue(file_exists($file)); $this->assertEqual(file_get_contents($file), $contents); $Folder = new Folder($path); $Folder->delete(); }
testCreateFile method @return void @access public
testCreateFile
php
Datawalke/Coordino
cake/tests/cases/console/libs/shell.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/shell.test.php
MIT
function testCreateFileWindows() { $this->skipUnless(DIRECTORY_SEPARATOR === '\\', 'testCreateFileWindows supported on Windows only'); $path = TMP . 'shell_test'; $file = $path . DS . 'file1.php'; new Folder($path, true); $this->Shell->interactive = false; $contents = "<?php\necho 'test';\r\n\$te = 'st';\r\n?>"; $result = $this->Shell->createFile($file, $contents); $this->assertTrue($result); $this->assertTrue(file_exists($file)); $this->assertEqual(file_get_contents($file), $contents); $contents = "<?php\necho 'another test';\r\n\$te = 'st';\r\n?>"; $result = $this->Shell->createFile($file, $contents); $this->assertTrue($result); $this->assertTrue(file_exists($file)); $this->assertEqual(file_get_contents($file), $contents); $this->Shell->interactive = true; $this->Shell->Dispatch->setReturnValueAt(0, 'getInput', 'n'); $this->Shell->Dispatch->expectAt(1, 'stdout', array('File exists, overwrite?')); $contents = "<?php\necho 'yet another test';\r\n\$te = 'st';\r\n?>"; $result = $this->Shell->createFile($file, $contents); $this->assertFalse($result); $this->assertTrue(file_exists($file)); $this->assertNotEqual(file_get_contents($file), $contents); $this->Shell->Dispatch->setReturnValueAt(1, 'getInput', 'y'); $this->Shell->Dispatch->expectAt(3, 'stdout', array('File exists, overwrite?')); $result = $this->Shell->createFile($file, $contents); $this->assertTrue($result); $this->assertTrue(file_exists($file)); $this->assertEqual(file_get_contents($file), $contents); $Folder = new Folder($path); $Folder->delete(); }
testCreateFileWindows method @return void @access public
testCreateFileWindows
php
Datawalke/Coordino
cake/tests/cases/console/libs/shell.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/shell.test.php
MIT
function startTest() { $this->Dispatcher =& new TestControllerTaskMockShellDispatcher(); $this->Task =& new MockControllerTask($this->Dispatcher); $this->Task->name = 'ControllerTask'; $this->Task->Dispatch =& $this->Dispatcher; $this->Task->Dispatch->shellPaths = App::path('shells'); $this->Task->Template =& new TemplateTask($this->Task->Dispatch); $this->Task->Template->params['theme'] = 'default'; $this->Task->Model =& new ControllerMockModelTask($this->Task->Dispatch); $this->Task->Project =& new ControllerMockProjectTask($this->Task->Dispatch); $this->Task->Test =& new ControllerMockTestTask(); }
startTest method @return void @access public
startTest
php
Datawalke/Coordino
cake/tests/cases/console/libs/tasks/controller.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/controller.test.php
MIT
function endTest() { unset($this->Task, $this->Dispatcher); ClassRegistry::flush(); }
endTest method @return void @access public
endTest
php
Datawalke/Coordino
cake/tests/cases/console/libs/tasks/controller.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/controller.test.php
MIT
function testListAll() { $this->Task->connection = 'test_suite'; $this->Task->interactive = true; $this->Task->expectAt(1, 'out', array('1. Articles')); $this->Task->expectAt(2, 'out', array('2. ArticlesTags')); $this->Task->expectAt(3, 'out', array('3. Comments')); $this->Task->expectAt(4, 'out', array('4. Tags')); $expected = array('Articles', 'ArticlesTags', 'Comments', 'Tags'); $result = $this->Task->listAll('test_suite'); $this->assertEqual($result, $expected); $this->Task->expectAt(6, 'out', array('1. Articles')); $this->Task->expectAt(7, 'out', array('2. ArticlesTags')); $this->Task->expectAt(8, 'out', array('4. Comments')); $this->Task->expectAt(9, 'out', array('5. Tags')); $this->Task->interactive = false; $result = $this->Task->listAll(); $expected = array('articles', 'articles_tags', 'comments', 'tags'); $this->assertEqual($result, $expected); }
test ListAll @return void @access public
testListAll
php
Datawalke/Coordino
cake/tests/cases/console/libs/tasks/controller.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/controller.test.php
MIT
function testGetName() { $this->Task->interactive = true; $this->Task->setReturnValue('in', 1); $this->Task->setReturnValueAt(0, 'in', 'q'); $this->Task->expectOnce('_stop'); $this->Task->getName('test_suite'); $this->Task->setReturnValueAt(1, 'in', 1); $result = $this->Task->getName('test_suite'); $expected = 'Articles'; $this->assertEqual($result, $expected); $this->Task->setReturnValueAt(2, 'in', 3); $result = $this->Task->getName('test_suite'); $expected = 'Comments'; $this->assertEqual($result, $expected); $this->Task->setReturnValueAt(3, 'in', 10); $result = $this->Task->getName('test_suite'); $this->Task->expectOnce('err'); }
Test that getName interacts with the user and returns the controller name. @return void @access public
testGetName
php
Datawalke/Coordino
cake/tests/cases/console/libs/tasks/controller.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/controller.test.php
MIT
function testDoHelpers() { $this->Task->setReturnValue('in', 'n'); $result = $this->Task->doHelpers(); $this->assertEqual($result, array()); $this->Task->setReturnValueAt(1, 'in', 'y'); $this->Task->setReturnValueAt(2, 'in', ' Javascript, Ajax, CustomOne '); $result = $this->Task->doHelpers(); $expected = array('Javascript', 'Ajax', 'CustomOne'); $this->assertEqual($result, $expected); $this->Task->setReturnValueAt(3, 'in', 'y'); $this->Task->setReturnValueAt(4, 'in', ' Javascript, Ajax, CustomOne, , '); $result = $this->Task->doHelpers(); $expected = array('Javascript', 'Ajax', 'CustomOne'); $this->assertEqual($result, $expected); }
test helper interactions @return void @access public
testDoHelpers
php
Datawalke/Coordino
cake/tests/cases/console/libs/tasks/controller.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/controller.test.php
MIT
function testDoComponents() { $this->Task->setReturnValue('in', 'n'); $result = $this->Task->doComponents(); $this->assertEqual($result, array()); $this->Task->setReturnValueAt(1, 'in', 'y'); $this->Task->setReturnValueAt(2, 'in', ' RequestHandler, Security '); $result = $this->Task->doComponents(); $expected = array('RequestHandler', 'Security'); $this->assertEqual($result, $expected); $this->Task->setReturnValueAt(3, 'in', 'y'); $this->Task->setReturnValueAt(4, 'in', ' RequestHandler, Security, , '); $result = $this->Task->doComponents(); $expected = array('RequestHandler', 'Security'); $this->assertEqual($result, $expected); }
test component interactions @return void @access public
testDoComponents
php
Datawalke/Coordino
cake/tests/cases/console/libs/tasks/controller.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/controller.test.php
MIT
function testConfirmController() { $controller = 'Posts'; $scaffold = false; $helpers = array('Ajax', 'Time'); $components = array('Acl', 'Auth'); $uses = array('Comment', 'User'); $this->Task->expectAt(2, 'out', array("Controller Name:\n\t$controller")); $this->Task->expectAt(3, 'out', array("Helpers:\n\tAjax, Time")); $this->Task->expectAt(4, 'out', array("Components:\n\tAcl, Auth")); $this->Task->confirmController($controller, $scaffold, $helpers, $components); }
test Confirming controller user interaction @return void @access public
testConfirmController
php
Datawalke/Coordino
cake/tests/cases/console/libs/tasks/controller.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/controller.test.php
MIT
function testBake() { $helpers = array('Ajax', 'Time'); $components = array('Acl', 'Auth'); $this->Task->setReturnValue('createFile', true); $result = $this->Task->bake('Articles', '--actions--', $helpers, $components); $this->assertPattern('/class ArticlesController extends AppController/', $result); $this->assertPattern('/\$components \= array\(\'Acl\', \'Auth\'\)/', $result); $this->assertPattern('/\$helpers \= array\(\'Ajax\', \'Time\'\)/', $result); $this->assertPattern('/\-\-actions\-\-/', $result); $result = $this->Task->bake('Articles', 'scaffold', $helpers, $components); $this->assertPattern('/class ArticlesController extends AppController/', $result); $this->assertPattern('/var \$scaffold/', $result); $this->assertNoPattern('/helpers/', $result); $this->assertNoPattern('/components/', $result); $result = $this->Task->bake('Articles', '--actions--', array(), array()); $this->assertPattern('/class ArticlesController extends AppController/', $result); $this->assertNoPattern('/components/', $result); $this->assertNoPattern('/helpers/', $result); $this->assertPattern('/\-\-actions\-\-/', $result); }
test the bake method @return void @access public
testBake
php
Datawalke/Coordino
cake/tests/cases/console/libs/tasks/controller.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/controller.test.php
MIT
function testBakeWithPlugin() { $this->Task->plugin = 'ControllerTest'; $helpers = array('Ajax', 'Time'); $components = array('Acl', 'Auth'); $uses = array('Comment', 'User'); $path = APP . 'plugins' . DS . 'controller_test' . DS . 'controllers' . DS . 'articles_controller.php'; $this->Task->expectAt(0, 'createFile', array($path, '*')); $this->Task->bake('Articles', '--actions--', array(), array(), array()); $this->Task->plugin = 'controllerTest'; $path = APP . 'plugins' . DS . 'controller_test' . DS . 'controllers' . DS . 'articles_controller.php'; $this->Task->expectAt(1, 'createFile', array( $path, new PatternExpectation('/ArticlesController extends ControllerTestAppController/'))); $this->Task->bake('Articles', '--actions--', array(), array(), array()); $this->assertEqual($this->Task->Template->templateVars['plugin'], 'ControllerTest'); }
test bake() with a -plugin param @return void @access public
testBakeWithPlugin
php
Datawalke/Coordino
cake/tests/cases/console/libs/tasks/controller.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/controller.test.php
MIT
function testBakeActionsUsingSessions() { $skip = $this->skipIf(!defined('ARTICLE_MODEL_CREATED'), 'Testing bakeActions requires Article, Comment & Tag Model to be undefined. %s'); if ($skip) { return; } $result = $this->Task->bakeActions('Articles', null, true); $this->assertTrue(strpos($result, 'function index() {') !== false); $this->assertTrue(strpos($result, '$this->Article->recursive = 0;') !== false); $this->assertTrue(strpos($result, "\$this->set('articles', \$this->paginate());") !== false); $this->assertTrue(strpos($result, 'function view($id = null)') !== false); $this->assertTrue(strpos($result, "\$this->Session->setFlash(__('Invalid article', true));") !== false); $this->assertTrue(strpos($result, "\$this->set('article', \$this->Article->read(null, \$id)") !== false); $this->assertTrue(strpos($result, 'function add()') !== false); $this->assertTrue(strpos($result, 'if (!empty($this->data))') !== false); $this->assertTrue(strpos($result, 'if ($this->Article->save($this->data))') !== false); $this->assertTrue(strpos($result, "\$this->Session->setFlash(__('The article has been saved', true));") !== false); $this->assertTrue(strpos($result, 'function edit($id = null)') !== false); $this->assertTrue(strpos($result, "\$this->Session->setFlash(__('The article could not be saved. Please, try again.', true));") !== false); $this->assertTrue(strpos($result, 'function delete($id = null)') !== false); $this->assertTrue(strpos($result, 'if ($this->Article->delete($id))') !== false); $this->assertTrue(strpos($result, "\$this->Session->setFlash(__('Article deleted', true));") !== false); $result = $this->Task->bakeActions('Articles', 'admin_', true); $this->assertTrue(strpos($result, 'function admin_index() {') !== false); $this->assertTrue(strpos($result, 'function admin_add()') !== false); $this->assertTrue(strpos($result, 'function admin_view($id = null)') !== false); $this->assertTrue(strpos($result, 'function admin_edit($id = null)') !== false); $this->assertTrue(strpos($result, 'function admin_delete($id = null)') !== false); }
test that bakeActions is creating the correct controller Code. (Using sessions) @return void @access public
testBakeActionsUsingSessions
php
Datawalke/Coordino
cake/tests/cases/console/libs/tasks/controller.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/controller.test.php
MIT
function testBakeActionsWithNoSessions() { $skip = $this->skipIf(!defined('ARTICLE_MODEL_CREATED'), 'Testing bakeActions requires Article, Tag, Comment Models to be undefined. %s'); if ($skip) { return; } $result = $this->Task->bakeActions('Articles', null, false); $this->assertTrue(strpos($result, 'function index() {') !== false); $this->assertTrue(strpos($result, '$this->Article->recursive = 0;') !== false); $this->assertTrue(strpos($result, "\$this->set('articles', \$this->paginate());") !== false); $this->assertTrue(strpos($result, 'function view($id = null)') !== false); $this->assertTrue(strpos($result, "\$this->flash(__('Invalid article', true), array('action' => 'index'))") !== false); $this->assertTrue(strpos($result, "\$this->set('article', \$this->Article->read(null, \$id)") !== false); $this->assertTrue(strpos($result, 'function add()') !== false); $this->assertTrue(strpos($result, 'if (!empty($this->data))') !== false); $this->assertTrue(strpos($result, 'if ($this->Article->save($this->data))') !== false); $this->assertTrue(strpos($result, "\$this->flash(__('The article has been saved.', true), array('action' => 'index'))") !== false); $this->assertTrue(strpos($result, 'function edit($id = null)') !== false); $this->assertTrue(strpos($result, "\$this->Article->Tag->find('list')") !== false); $this->assertTrue(strpos($result, "\$this->set(compact('tags'))") !== false); $this->assertTrue(strpos($result, 'function delete($id = null)') !== false); $this->assertTrue(strpos($result, 'if ($this->Article->delete($id))') !== false); $this->assertTrue(strpos($result, "\$this->flash(__('Article deleted', true), array('action' => 'index'))") !== false); }
Test baking with Controller::flash() or no sessions. @return void @access public
testBakeActionsWithNoSessions
php
Datawalke/Coordino
cake/tests/cases/console/libs/tasks/controller.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/controller.test.php
MIT
function testBakeTest() { $this->Task->plugin = 'ControllerTest'; $this->Task->connection = 'test_suite'; $this->Task->interactive = false; $this->Task->Test->expectOnce('bake', array('Controller', 'Articles')); $this->Task->bakeTest('Articles'); $this->assertEqual($this->Task->plugin, $this->Task->Test->plugin); $this->assertEqual($this->Task->connection, $this->Task->Test->connection); $this->assertEqual($this->Task->interactive, $this->Task->Test->interactive); }
test baking a test @return void @access public
testBakeTest
php
Datawalke/Coordino
cake/tests/cases/console/libs/tasks/controller.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/controller.test.php
MIT
function testInteractive() { $this->Task->connection = 'test_suite'; $this->Task->path = '/my/path'; $this->Task->setReturnValue('in', '1'); $this->Task->setReturnValueAt(1, 'in', 'y'); // build interactive $this->Task->setReturnValueAt(2, 'in', 'n'); // build no scaffolds $this->Task->setReturnValueAt(3, 'in', 'y'); // build normal methods $this->Task->setReturnValueAt(4, 'in', 'n'); // build admin methods $this->Task->setReturnValueAt(5, 'in', 'n'); // helpers? $this->Task->setReturnValueAt(6, 'in', 'n'); // components? $this->Task->setReturnValueAt(7, 'in', 'y'); // use sessions $this->Task->setReturnValueAt(8, 'in', 'y'); // looks good $this->Task->execute(); $filename = '/my/path/articles_controller.php'; $this->Task->expectAt(0, 'createFile', array($filename, new PatternExpectation('/class ArticlesController/'))); }
test Interactive mode. @return void @access public
testInteractive
php
Datawalke/Coordino
cake/tests/cases/console/libs/tasks/controller.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/controller.test.php
MIT
function testInteractiveAdminMethodsNotInteractive() { $this->Task->connection = 'test_suite'; $this->Task->interactive = true; $this->Task->path = '/my/path'; $this->Task->setReturnValue('in', '1'); $this->Task->setReturnValueAt(1, 'in', 'y'); // build interactive $this->Task->setReturnValueAt(2, 'in', 'n'); // build no scaffolds $this->Task->setReturnValueAt(3, 'in', 'y'); // build normal methods $this->Task->setReturnValueAt(4, 'in', 'y'); // build admin methods $this->Task->setReturnValueAt(5, 'in', 'n'); // helpers? $this->Task->setReturnValueAt(6, 'in', 'n'); // components? $this->Task->setReturnValueAt(7, 'in', 'y'); // use sessions $this->Task->setReturnValueAt(8, 'in', 'y'); // looks good $this->Task->setReturnValue('createFile', true); $this->Task->Project->setReturnValue('getPrefix', 'admin_'); $result = $this->Task->execute(); $this->assertPattern('/admin_index/', $result); $filename = '/my/path/articles_controller.php'; $this->Task->expectAt(0, 'createFile', array($filename, new PatternExpectation('/class ArticlesController/'))); }
test Interactive mode. @return void @access public
testInteractiveAdminMethodsNotInteractive
php
Datawalke/Coordino
cake/tests/cases/console/libs/tasks/controller.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/controller.test.php
MIT
function testExecuteIntoAll() { $skip = $this->skipIf(!defined('ARTICLE_MODEL_CREATED'), 'Execute into all could not be run as an Article, Tag or Comment model was already loaded. %s'); if ($skip) { return; } $this->Task->connection = 'test_suite'; $this->Task->path = '/my/path/'; $this->Task->args = array('all'); $this->Task->setReturnValue('createFile', true); $this->Task->setReturnValue('_checkUnitTest', true); $this->Task->Test->expectCallCount('bake', 1); $filename = '/my/path/articles_controller.php'; $this->Task->expectAt(0, 'createFile', array($filename, new PatternExpectation('/class ArticlesController/'))); $this->Task->execute(); }
test that execute runs all when the first arg == all @return void @access public
testExecuteIntoAll
php
Datawalke/Coordino
cake/tests/cases/console/libs/tasks/controller.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/controller.test.php
MIT
function testExecuteWithController() { $skip = $this->skipIf(!defined('ARTICLE_MODEL_CREATED'), 'Execute with scaffold param requires no Article, Tag or Comment model to be defined. %s'); if ($skip) { return; } $this->Task->connection = 'test_suite'; $this->Task->path = '/my/path/'; $this->Task->args = array('Articles'); $filename = '/my/path/articles_controller.php'; $this->Task->expectAt(0, 'createFile', array( $filename, new PatternExpectation('/\$scaffold/') )); $this->Task->execute(); }
test that `cake bake controller foos` works. @return void @access public
testExecuteWithController
php
Datawalke/Coordino
cake/tests/cases/console/libs/tasks/controller.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/controller.test.php
MIT
function testExecuteWithControllerNameVariations() { $skip = $this->skipIf(!defined('ARTICLE_MODEL_CREATED'), 'Execute with scaffold param requires no Article, Tag or Comment model to be defined. %s'); if ($skip) { return; } $this->Task->connection = 'test_suite'; $this->Task->path = '/my/path/'; $this->Task->args = array('Articles'); $filename = '/my/path/articles_controller.php'; $this->Task->expectAt(0, 'createFile', array( $filename, new PatternExpectation('/\$scaffold/') )); $this->Task->execute(); $this->Task->args = array('Article'); $filename = '/my/path/articles_controller.php'; $this->Task->expectAt(1, 'createFile', array( $filename, new PatternExpectation('/class ArticlesController/') )); $this->Task->execute(); $this->Task->args = array('article'); $filename = '/my/path/articles_controller.php'; $this->Task->expectAt(2, 'createFile', array( $filename, new PatternExpectation('/class ArticlesController/') )); $this->Task->args = array('articles'); $filename = '/my/path/articles_controller.php'; $this->Task->expectAt(3, 'createFile', array( $filename, new PatternExpectation('/class ArticlesController/') )); $this->Task->execute(); $this->Task->args = array('Articles'); $filename = '/my/path/articles_controller.php'; $this->Task->expectAt(4, 'createFile', array( $filename, new PatternExpectation('/class ArticlesController/') )); $this->Task->execute(); $this->Task->execute(); }
test that both plural and singular forms work for controller baking. @return void @access public
testExecuteWithControllerNameVariations
php
Datawalke/Coordino
cake/tests/cases/console/libs/tasks/controller.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/controller.test.php
MIT
function testExecuteWithPublicParam() { $skip = $this->skipIf(!defined('ARTICLE_MODEL_CREATED'), 'Execute with scaffold param requires no Article, Tag or Comment model to be defined. %s'); if ($skip) { return; } $this->Task->connection = 'test_suite'; $this->Task->path = '/my/path/'; $this->Task->args = array('Articles', 'public'); $filename = '/my/path/articles_controller.php'; $this->Task->expectAt(0, 'createFile', array( $filename, new NoPatternExpectation('/var \$scaffold/') )); $this->Task->execute(); }
test that `cake bake controller foo scaffold` works. @return void @access public
testExecuteWithPublicParam
php
Datawalke/Coordino
cake/tests/cases/console/libs/tasks/controller.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/controller.test.php
MIT
function testExecuteWithControllerAndBoth() { $skip = $this->skipIf(!defined('ARTICLE_MODEL_CREATED'), 'Execute with scaffold param requires no Article, Tag or Comment model to be defined. %s'); if ($skip) { return; } $this->Task->Project->setReturnValue('getPrefix', 'admin_'); $this->Task->connection = 'test_suite'; $this->Task->path = '/my/path/'; $this->Task->args = array('Articles', 'public', 'admin'); $filename = '/my/path/articles_controller.php'; $this->Task->expectAt(0, 'createFile', array( $filename, new PatternExpectation('/admin_index/') )); $this->Task->execute(); }
test that `cake bake controller foos both` works. @return void @access public
testExecuteWithControllerAndBoth
php
Datawalke/Coordino
cake/tests/cases/console/libs/tasks/controller.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/controller.test.php
MIT
function testExecuteWithControllerAndAdmin() { $skip = $this->skipIf(!defined('ARTICLE_MODEL_CREATED'), 'Execute with scaffold param requires no Article, Tag or Comment model to be defined. %s'); if ($skip) { return; } $this->Task->Project->setReturnValue('getPrefix', 'admin_'); $this->Task->connection = 'test_suite'; $this->Task->path = '/my/path/'; $this->Task->args = array('Articles', 'admin'); $filename = '/my/path/articles_controller.php'; $this->Task->expectAt(0, 'createFile', array( $filename, new PatternExpectation('/admin_index/') )); $this->Task->execute(); }
test that `cake bake controller foos admin` works. @return void @access public
testExecuteWithControllerAndAdmin
php
Datawalke/Coordino
cake/tests/cases/console/libs/tasks/controller.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/controller.test.php
MIT
function startTest() { $this->Dispatcher =& new TestDbConfigTaskMockShellDispatcher(); $this->Task =& new MockDbConfigTask($this->Dispatcher); $this->Task->Dispatch =& $this->Dispatcher; $this->Task->Dispatch->shellPaths = App::path('shells'); $this->Task->params['working'] = rtrim(APP, DS); $this->Task->databaseClassName = 'TEST_DATABASE_CONFIG'; }
startTest method @return void @access public
startTest
php
Datawalke/Coordino
cake/tests/cases/console/libs/tasks/db_config.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/db_config.test.php
MIT
function endTest() { unset($this->Task, $this->Dispatcher); ClassRegistry::flush(); }
endTest method @return void @access public
endTest
php
Datawalke/Coordino
cake/tests/cases/console/libs/tasks/db_config.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/db_config.test.php
MIT
function testGetConfig() { $this->Task->setReturnValueAt(0, 'in', 'otherOne'); $result = $this->Task->getConfig(); $this->assertEqual($result, 'otherOne'); }
Test the getConfig method. @return void @access public
testGetConfig
php
Datawalke/Coordino
cake/tests/cases/console/libs/tasks/db_config.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/db_config.test.php
MIT
function testInitialize() { $this->assertTrue(empty($this->Task->path)); $this->Task->initialize(); $this->assertFalse(empty($this->Task->path)); $this->assertEqual($this->Task->path, APP . 'config' . DS); }
test that initialize sets the path up. @return void @access public
testInitialize
php
Datawalke/Coordino
cake/tests/cases/console/libs/tasks/db_config.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/db_config.test.php
MIT
function testExecuteIntoInteractive() { $this->Task->initialize(); $this->Task->expectOnce('_stop'); $this->Task->setReturnValue('in', 'y'); $this->Task->setReturnValueAt(0, 'in', 'default'); $this->Task->setReturnValueAt(1, 'in', 'n'); $this->Task->setReturnValueAt(2, 'in', 'localhost'); $this->Task->setReturnValueAt(3, 'in', 'n'); $this->Task->setReturnValueAt(4, 'in', 'root'); $this->Task->setReturnValueAt(5, 'in', 'password'); $this->Task->setReturnValueAt(6, 'in', 'cake_test'); $this->Task->setReturnValueAt(7, 'in', 'n'); $this->Task->setReturnValueAt(8, 'in', 'y'); $this->Task->setReturnValueAt(9, 'in', 'y'); $this->Task->setReturnValueAt(10, 'in', 'y'); $this->Task->setReturnValueAt(11, 'in', 'n'); $result = $this->Task->execute(); }
test execute and by extension __interactive @return void @access public
testExecuteIntoInteractive
php
Datawalke/Coordino
cake/tests/cases/console/libs/tasks/db_config.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/db_config.test.php
MIT
function setUp() { $this->Dispatcher =& new TestExtractTaskMockShellDispatcher(); $this->Task =& new ExtractTask($this->Dispatcher); }
setUp method @return void @access public
setUp
php
Datawalke/Coordino
cake/tests/cases/console/libs/tasks/extract.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/extract.test.php
MIT
function testExecute() { $path = TMP . 'tests' . DS . 'extract_task_test'; new Folder($path . DS . 'locale', true); $this->Task->interactive = false; $this->Task->params['paths'] = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'pages'; $this->Task->params['output'] = $path . DS; $this->Task->Dispatch->expectNever('stderr'); $this->Task->Dispatch->expectNever('_stop'); $this->Task->execute(); $this->assertTrue(file_exists($path . DS . 'default.pot')); $result = file_get_contents($path . DS . 'default.pot'); $pattern = '/"Content-Type\: text\/plain; charset\=utf-8/'; $this->assertPattern($pattern, $result); $pattern = '/"Content-Transfer-Encoding\: 8bit/'; $this->assertPattern($pattern, $result); $pattern = '/"Plural-Forms\: nplurals\=INTEGER; plural\=EXPRESSION;/'; $this->assertPattern($pattern, $result); // home.ctp $pattern = '/msgid "Your tmp directory is writable."\nmsgstr ""\n/'; $this->assertPattern($pattern, $result); $pattern = '/msgid "Your tmp directory is NOT writable."\nmsgstr ""\n/'; $this->assertPattern($pattern, $result); $pattern = '/msgid "The %s is being used for caching. To change the config edit '; $pattern .= 'APP\/config\/core.php "\nmsgstr ""\n/'; $this->assertPattern($pattern, $result); $pattern = '/msgid "Your cache is NOT working. Please check '; $pattern .= 'the settings in APP\/config\/core.php"\nmsgstr ""\n/'; $this->assertPattern($pattern, $result); $pattern = '/msgid "Your database configuration file is present."\nmsgstr ""\n/'; $this->assertPattern($pattern, $result); $pattern = '/msgid "Your database configuration file is NOT present."\nmsgstr ""\n/'; $this->assertPattern($pattern, $result); $pattern = '/msgid "Rename config\/database.php.default to '; $pattern .= 'config\/database.php"\nmsgstr ""\n/'; $this->assertPattern($pattern, $result); $pattern = '/msgid "Cake is able to connect to the database."\nmsgstr ""\n/'; $this->assertPattern($pattern, $result); $pattern = '/msgid "Cake is NOT able to connect to the database."\nmsgstr ""\n/'; $this->assertPattern($pattern, $result); $pattern = '/msgid "Editing this Page"\nmsgstr ""\n/'; $this->assertPattern($pattern, $result); $pattern = '/msgid "To change the content of this page, edit: %s.*To change its layout, '; $pattern .= 'edit: %s.*You can also add some CSS styles for your pages at: %s"\nmsgstr ""/s'; $this->assertPattern($pattern, $result); // extract.ctp $pattern = '/\#: (\\\\|\/)extract\.ctp:6\n'; $pattern .= 'msgid "You have %d new message."\nmsgid_plural "You have %d new messages."/'; $this->assertPattern($pattern, $result); $pattern = '/\#: (\\\\|\/)extract\.ctp:7\n'; $pattern .= 'msgid "You deleted %d message."\nmsgid_plural "You deleted %d messages."/'; $this->assertPattern($pattern, $result); $pattern = '/\#: (\\\\|\/)extract\.ctp:14\n'; $pattern .= '\#: (\\\\|\/)home\.ctp:77\n'; $pattern .= 'msgid "Editing this Page"\nmsgstr ""/'; $this->assertPattern($pattern, $result); $pattern = '/\#: (\\\\|\/)extract\.ctp:17\nmsgid "'; $pattern .= 'Hot features!'; $pattern .= '\\\n - No Configuration: Set-up the database and let the magic begin'; $pattern .= '\\\n - Extremely Simple: Just look at the name...It\'s Cake'; $pattern .= '\\\n - Active, Friendly Community: Join us #cakephp on IRC. We\'d love to help you get started'; $pattern .= '"\nmsgstr ""/'; $this->assertPattern($pattern, $result); $pattern = '/\#: (\\\\|\/)extract\.ctp:26\n'; $pattern .= 'msgid "Found "/'; $this->assertNoPattern($pattern, $result); // extract.ctp - reading the domain.pot $result = file_get_contents($path . DS . 'domain.pot'); $pattern = '/msgid "You have %d new message."\nmsgid_plural "You have %d new messages."/'; $this->assertNoPattern($pattern, $result); $pattern = '/msgid "You deleted %d message."\nmsgid_plural "You deleted %d messages."/'; $this->assertNoPattern($pattern, $result); $pattern = '/msgid "You have %d new message \(domain\)."\nmsgid_plural "You have %d new messages \(domain\)."/'; $this->assertPattern($pattern, $result); $pattern = '/msgid "You deleted %d message \(domain\)."\nmsgid_plural "You deleted %d messages \(domain\)."/'; $this->assertPattern($pattern, $result); $Folder = new Folder($path); $Folder->delete(); }
testExecute method @return void @access public
testExecute
php
Datawalke/Coordino
cake/tests/cases/console/libs/tasks/extract.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/extract.test.php
MIT
function testExtractMultiplePaths() { $path = TMP . 'tests' . DS . 'extract_task_test'; new Folder($path . DS . 'locale', true); $this->Task->interactive = false; $this->Task->params['paths'] = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'pages,' . TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'posts'; $this->Task->params['output'] = $path . DS; $this->Task->Dispatch->expectNever('stderr'); $this->Task->Dispatch->expectNever('_stop'); $this->Task->execute(); $result = file_get_contents($path . DS . 'default.pot'); $pattern = '/msgid "Add User"/'; $this->assertPattern($pattern, $result); }
test extract can read more than one path. @return void
testExtractMultiplePaths
php
Datawalke/Coordino
cake/tests/cases/console/libs/tasks/extract.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/extract.test.php
MIT
function startTest() { $this->Dispatcher =& new TestFixtureTaskMockShellDispatcher(); $this->Task =& new MockFixtureTask(); $this->Task->Model =& new MockFixtureModelTask(); $this->Task->DbConfig =& new MockFixtureModelTask(); $this->Task->Dispatch =& $this->Dispatcher; $this->Task->Template =& new TemplateTask($this->Task->Dispatch); $this->Task->Dispatch->shellPaths = App::path('shells'); $this->Task->Template->initialize(); }
startTest method @return void @access public
startTest
php
Datawalke/Coordino
cake/tests/cases/console/libs/tasks/fixture.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/fixture.test.php
MIT
function endTest() { unset($this->Task, $this->Dispatcher); ClassRegistry::flush(); }
endTest method @return void @access public
endTest
php
Datawalke/Coordino
cake/tests/cases/console/libs/tasks/fixture.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/fixture.test.php
MIT
function testConstruct() { $this->Dispatch->params['working'] = DS . 'my' . DS . 'path'; $Task =& new FixtureTask($this->Dispatch); $expected = DS . 'my' . DS . 'path' . DS . 'tests' . DS . 'fixtures' . DS; $this->assertEqual($Task->path, $expected); }
test that initialize sets the path @return void @access public
testConstruct
php
Datawalke/Coordino
cake/tests/cases/console/libs/tasks/fixture.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/fixture.test.php
MIT
function testImportOptions() { $this->Task->setReturnValueAt(0, 'in', 'y'); $this->Task->setReturnValueAt(1, 'in', 'y'); $result = $this->Task->importOptions('Article'); $expected = array('schema' => 'Article', 'records' => true); $this->assertEqual($result, $expected); $this->Task->setReturnValueAt(2, 'in', 'n'); $this->Task->setReturnValueAt(3, 'in', 'n'); $this->Task->setReturnValueAt(4, 'in', 'n'); $result = $this->Task->importOptions('Article'); $expected = array(); $this->assertEqual($result, $expected); $this->Task->setReturnValueAt(5, 'in', 'n'); $this->Task->setReturnValueAt(6, 'in', 'n'); $this->Task->setReturnValueAt(7, 'in', 'y'); $result = $this->Task->importOptions('Article'); $expected = array('fromTable' => true); $this->assertEqual($result, $expected); }
test import option array generation @return void @access public
testImportOptions
php
Datawalke/Coordino
cake/tests/cases/console/libs/tasks/fixture.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/fixture.test.php
MIT
function testImportOptionsAlternateConnection() { $this->Task->connection = 'test_suite'; $result = $this->Task->bake('Article', false, array('schema' => 'Article')); $this->assertPattern("/'connection' => 'test_suite'/", $result); }
test that connection gets set to the import options when a different connection is used. @return void
testImportOptionsAlternateConnection
php
Datawalke/Coordino
cake/tests/cases/console/libs/tasks/fixture.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/fixture.test.php
MIT
function testImportRecordsFromDatabaseWithConditions() { $this->Task->interactive = true; $this->Task->setReturnValueAt(0, 'in', 'WHERE 1=1 LIMIT 10'); $this->Task->connection = 'test_suite'; $this->Task->path = '/my/path/'; $result = $this->Task->bake('Article', false, array('fromTable' => true, 'schema' => 'Article', 'records' => false)); $this->assertPattern('/class ArticleFixture extends CakeTestFixture/', $result); $this->assertPattern('/var \$records/', $result); $this->assertPattern('/var \$import/', $result); $this->assertPattern("/'title' => 'First Article'/", $result, 'Missing import data %s'); $this->assertPattern('/Second Article/', $result, 'Missing import data %s'); $this->assertPattern('/Third Article/', $result, 'Missing import data %s'); }
test generating a fixture with database conditions. @return void @access public
testImportRecordsFromDatabaseWithConditions
php
Datawalke/Coordino
cake/tests/cases/console/libs/tasks/fixture.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/fixture.test.php
MIT
function testImportRecordsNoEscaping() { $Article = ClassRegistry::init('Article'); $Article->updateAll(array('body' => "'Body \"value\"'")); $this->Task->interactive = true; $this->Task->setReturnValueAt(0, 'in', 'WHERE 1=1 LIMIT 10'); $this->Task->connection = 'test_suite'; $this->Task->path = '/my/path/'; $result = $this->Task->bake('Article', false, array( 'fromTable' => true, 'schema' => 'Article', 'records' => false )); $this->assertPattern("/'body' => 'Body \"value\"'/", $result, 'Data has escaping %s'); }
Ensure that fixture data doesn't get overly escaped. @return void
testImportRecordsNoEscaping
php
Datawalke/Coordino
cake/tests/cases/console/libs/tasks/fixture.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/fixture.test.php
MIT
function testExecuteWithNamedModel() { $this->Task->connection = 'test_suite'; $this->Task->path = '/my/path/'; $this->Task->args = array('article'); $filename = '/my/path/article_fixture.php'; $this->Task->expectAt(0, 'createFile', array($filename, new PatternExpectation('/class ArticleFixture/'))); $this->Task->execute(); }
test that execute passes runs bake depending with named model. @return void @access public
testExecuteWithNamedModel
php
Datawalke/Coordino
cake/tests/cases/console/libs/tasks/fixture.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/fixture.test.php
MIT
function testExecuteWithNamedModelVariations() { $this->Task->connection = 'test_suite'; $this->Task->path = '/my/path/'; $this->Task->args = array('article'); $filename = '/my/path/article_fixture.php'; $this->Task->expectAt(0, 'createFile', array($filename, new PatternExpectation('/class ArticleFixture/'))); $this->Task->execute(); $this->Task->args = array('articles'); $filename = '/my/path/article_fixture.php'; $this->Task->expectAt(1, 'createFile', array($filename, new PatternExpectation('/class ArticleFixture/'))); $this->Task->execute(); $this->Task->args = array('Articles'); $filename = '/my/path/article_fixture.php'; $this->Task->expectAt(2, 'createFile', array($filename, new PatternExpectation('/class ArticleFixture/'))); $this->Task->execute(); $this->Task->args = array('Article'); $filename = '/my/path/article_fixture.php'; $this->Task->expectAt(3, 'createFile', array($filename, new PatternExpectation('/class ArticleFixture/'))); $this->Task->execute(); }
test that execute passes runs bake depending with named model. @return void @access public
testExecuteWithNamedModelVariations
php
Datawalke/Coordino
cake/tests/cases/console/libs/tasks/fixture.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/fixture.test.php
MIT
function testExecuteIntoAll() { $this->Task->connection = 'test_suite'; $this->Task->path = '/my/path/'; $this->Task->args = array('all'); $this->Task->Model->setReturnValue('listAll', array('articles', 'comments')); $filename = '/my/path/article_fixture.php'; $this->Task->expectAt(0, 'createFile', array($filename, new PatternExpectation('/class ArticleFixture/'))); $this->Task->execute(); $filename = '/my/path/comment_fixture.php'; $this->Task->expectAt(1, 'createFile', array($filename, new PatternExpectation('/class CommentFixture/'))); $this->Task->execute(); }
test that execute runs all() when args[0] = all @return void @access public
testExecuteIntoAll
php
Datawalke/Coordino
cake/tests/cases/console/libs/tasks/fixture.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/fixture.test.php
MIT
function testAllWithCountAndRecordsFlags() { $this->Task->connection = 'test_suite'; $this->Task->path = '/my/path/'; $this->Task->args = array('all'); $this->Task->params = array('count' => 10, 'records' => true); $this->Task->Model->setReturnValue('listAll', array('articles', 'comments')); $filename = '/my/path/article_fixture.php'; $this->Task->expectAt(0, 'createFile', array($filename, new PatternExpectation('/title\' => \'Third Article\'/'))); $filename = '/my/path/comment_fixture.php'; $this->Task->expectAt(1, 'createFile', array($filename, new PatternExpectation('/comment\' => \'First Comment for First Article/'))); $this->Task->expectCallCount('createFile', 2); $this->Task->all(); }
test using all() with -count and -records @return void @access public
testAllWithCountAndRecordsFlags
php
Datawalke/Coordino
cake/tests/cases/console/libs/tasks/fixture.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/fixture.test.php
MIT
function testExecuteInteractive() { $this->Task->connection = 'test_suite'; $this->Task->path = '/my/path/'; $this->Task->setReturnValue('in', 'y'); $this->Task->Model->setReturnValue('getName', 'Article'); $this->Task->Model->setReturnValue('getTable', 'articles', array('Article')); $filename = '/my/path/article_fixture.php'; $this->Task->expectAt(0, 'createFile', array($filename, new PatternExpectation('/class ArticleFixture/'))); $this->Task->execute(); }
test interactive mode of execute @return void @access public
testExecuteInteractive
php
Datawalke/Coordino
cake/tests/cases/console/libs/tasks/fixture.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/fixture.test.php
MIT
function testBake() { $this->Task->connection = 'test_suite'; $this->Task->path = '/my/path/'; $result = $this->Task->bake('Article'); $this->assertPattern('/class ArticleFixture extends CakeTestFixture/', $result); $this->assertPattern('/var \$fields/', $result); $this->assertPattern('/var \$records/', $result); $this->assertNoPattern('/var \$import/', $result); $result = $this->Task->bake('Article', 'comments'); $this->assertPattern('/class ArticleFixture extends CakeTestFixture/', $result); $this->assertPattern('/var \$name \= \'Article\';/', $result); $this->assertPattern('/var \$table \= \'comments\';/', $result); $this->assertPattern('/var \$fields = array\(/', $result); $result = $this->Task->bake('Article', 'comments', array('records' => true)); $this->assertPattern( "/var \\\$import \= array\('records' \=\> true, 'connection' => 'test_suite'\);/", $result ); $this->assertNoPattern('/var \$records/', $result); $result = $this->Task->bake('Article', 'comments', array('schema' => 'Article')); $this->assertPattern( "/var \\\$import \= array\('model' \=\> 'Article', 'connection' => 'test_suite'\);/", $result ); $this->assertNoPattern('/var \$fields/', $result); $result = $this->Task->bake('Article', 'comments', array('schema' => 'Article', 'records' => true)); $this->assertPattern( "/var \\\$import \= array\('model' \=\> 'Article'\, 'records' \=\> true, 'connection' => 'test_suite'\);/", $result ); $this->assertNoPattern('/var \$fields/', $result); $this->assertNoPattern('/var \$records/', $result); }
Test that bake works @return void @access public
testBake
php
Datawalke/Coordino
cake/tests/cases/console/libs/tasks/fixture.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/fixture.test.php
MIT
function testRecordGenerationForBinaryAndFloat() { $this->Task->connection = 'test_suite'; $this->Task->path = '/my/path/'; $result = $this->Task->bake('Article', 'datatypes'); $this->assertPattern("/'float_field' => 1/", $result); $this->assertPattern("/'bool' => 1/", $result); $result = $this->Task->bake('Article', 'binary_tests'); $this->assertPattern("/'data' => 'Lorem ipsum dolor sit amet'/", $result); }
test record generation with float and binary types @return void @access public
testRecordGenerationForBinaryAndFloat
php
Datawalke/Coordino
cake/tests/cases/console/libs/tasks/fixture.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/fixture.test.php
MIT
function testGenerateFixtureFile() { $this->Task->connection = 'test_suite'; $this->Task->path = '/my/path/'; $filename = '/my/path/article_fixture.php'; $this->Task->expectAt(0, 'createFile', array($filename, new PatternExpectation('/Article/'))); $result = $this->Task->generateFixtureFile('Article', array()); $this->Task->expectAt(1, 'createFile', array($filename, new PatternExpectation('/\<\?php(.*)$/ms'))); $result = $this->Task->generateFixtureFile('Article', array()); }
Test that file generation includes headers and correct path for plugins. @return void @access public
testGenerateFixtureFile
php
Datawalke/Coordino
cake/tests/cases/console/libs/tasks/fixture.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/fixture.test.php
MIT
function testGeneratePluginFixtureFile() { $this->Task->connection = 'test_suite'; $this->Task->path = '/my/path/'; $this->Task->plugin = 'TestFixture'; $filename = APP . 'plugins' . DS . 'test_fixture' . DS . 'tests' . DS . 'fixtures' . DS . 'article_fixture.php'; $this->Task->expectAt(0, 'createFile', array($filename, new PatternExpectation('/Article/'))); $result = $this->Task->generateFixtureFile('Article', array()); }
test generating files into plugins. @return void @access public
testGeneratePluginFixtureFile
php
Datawalke/Coordino
cake/tests/cases/console/libs/tasks/fixture.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/fixture.test.php
MIT
function startTest() { $this->Dispatcher =& new TestModelTaskMockShellDispatcher(); $this->Task =& new MockModelTask($this->Dispatcher); $this->Task->name = 'ModelTask'; $this->Task->interactive = true; $this->Task->Dispatch =& $this->Dispatcher; $this->Task->Dispatch->shellPaths = App::path('shells'); $this->Task->Template =& new TemplateTask($this->Task->Dispatch); $this->Task->Fixture =& new MockModelTaskFixtureTask(); $this->Task->Test =& new MockModelTaskFixtureTask(); }
starTest method @return void @access public
startTest
php
Datawalke/Coordino
cake/tests/cases/console/libs/tasks/model.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/model.test.php
MIT
function endTest() { unset($this->Task, $this->Dispatcher); ClassRegistry::flush(); }
endTest method @return void @access public
endTest
php
Datawalke/Coordino
cake/tests/cases/console/libs/tasks/model.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/model.test.php
MIT
function testListAll() { $this->Task->expectAt(1, 'out', array('1. Article')); $this->Task->expectAt(2, 'out', array('2. ArticlesTag')); $this->Task->expectAt(3, 'out', array('3. CategoryThread')); $this->Task->expectAt(4, 'out', array('4. Comment')); $this->Task->expectAt(5, 'out', array('5. Tag')); $result = $this->Task->listAll('test_suite'); $expected = array('articles', 'articles_tags', 'category_threads', 'comments', 'tags'); $this->assertEqual($result, $expected); $this->Task->expectAt(7, 'out', array('1. Article')); $this->Task->expectAt(8, 'out', array('2. ArticlesTag')); $this->Task->expectAt(9, 'out', array('3. CategoryThread')); $this->Task->expectAt(10, 'out', array('4. Comment')); $this->Task->expectAt(11, 'out', array('5. Tag')); $this->Task->connection = 'test_suite'; $result = $this->Task->listAll(); $expected = array('articles', 'articles_tags', 'category_threads', 'comments', 'tags'); $this->assertEqual($result, $expected); }
Test that listAll scans the database connection and lists all the tables in it.s @return void @access public
testListAll
php
Datawalke/Coordino
cake/tests/cases/console/libs/tasks/model.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/model.test.php
MIT
function testGetName() { $this->Task->setReturnValue('in', 1); $this->Task->setReturnValueAt(0, 'in', 'q'); $this->Task->expectOnce('_stop'); $this->Task->getName('test_suite'); $this->Task->setReturnValueAt(1, 'in', 1); $result = $this->Task->getName('test_suite'); $expected = 'Article'; $this->assertEqual($result, $expected); $this->Task->setReturnValueAt(2, 'in', 4); $result = $this->Task->getName('test_suite'); $expected = 'Comment'; $this->assertEqual($result, $expected); $this->Task->setReturnValueAt(3, 'in', 10); $result = $this->Task->getName('test_suite'); $this->Task->expectOnce('err'); }
Test that getName interacts with the user and returns the model name. @return void @access public
testGetName
php
Datawalke/Coordino
cake/tests/cases/console/libs/tasks/model.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/model.test.php
MIT
function testGetTableName() { $this->Task->setReturnValueAt(0, 'in', 'y'); $result = $this->Task->getTable('Article', 'test_suite'); $expected = 'articles'; $this->assertEqual($result, $expected); $this->Task->setReturnValueAt(1, 'in', 'n'); $this->Task->setReturnValueAt(2, 'in', 'my_table'); $result = $this->Task->getTable('Article', 'test_suite'); $expected = 'my_table'; $this->assertEqual($result, $expected); }
Test table name interactions @return void @access public
testGetTableName
php
Datawalke/Coordino
cake/tests/cases/console/libs/tasks/model.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/model.test.php
MIT
function testInitValidations() { $result = $this->Task->initValidations(); $this->assertTrue(in_array('notempty', $result)); }
test that initializing the validations works. @return void @access public
testInitValidations
php
Datawalke/Coordino
cake/tests/cases/console/libs/tasks/model.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/model.test.php
MIT
function testFieldValidationGuessing() { $this->Task->interactive = false; $this->Task->initValidations(); $result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false)); $expected = array('notempty' => 'notempty'); $this->assertEqual($expected, $result); $result = $this->Task->fieldValidation('text', array('type' => 'date', 'length' => 10, 'null' => false)); $expected = array('date' => 'date'); $this->assertEqual($expected, $result); $result = $this->Task->fieldValidation('text', array('type' => 'time', 'length' => 10, 'null' => false)); $expected = array('time' => 'time'); $this->assertEqual($expected, $result); $result = $this->Task->fieldValidation('email', array('type' => 'string', 'length' => 10, 'null' => false)); $expected = array('email' => 'email'); $this->assertEqual($expected, $result); $result = $this->Task->fieldValidation('test', array('type' => 'integer', 'length' => 10, 'null' => false)); $expected = array('numeric' => 'numeric'); $this->assertEqual($expected, $result); $result = $this->Task->fieldValidation('test', array('type' => 'boolean', 'length' => 10, 'null' => false)); $expected = array('boolean' => 'boolean'); $this->assertEqual($expected, $result); $result = $this->Task->fieldValidation('test', array('type' => 'string', 'length' => 36, 'null' => false)); $expected = array('uuid' => 'uuid'); $this->assertEqual($expected, $result); }
test that individual field validation works, with interactive = false tests the guessing features of validation @return void @access public
testFieldValidationGuessing
php
Datawalke/Coordino
cake/tests/cases/console/libs/tasks/model.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/model.test.php
MIT
function testInteractiveFieldValidation() { $this->Task->initValidations(); $this->Task->interactive = true; $this->Task->setReturnValueAt(0, 'in', '19'); $this->Task->setReturnValueAt(1, 'in', 'y'); $this->Task->setReturnValueAt(2, 'in', '15'); $this->Task->setReturnValueAt(3, 'in', 'n'); $result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false)); $expected = array('notempty' => 'notempty', 'maxlength' => 'maxlength'); $this->assertEqual($result, $expected); }
test that interactive field validation works and returns multiple validators. @return void @access public
testInteractiveFieldValidation
php
Datawalke/Coordino
cake/tests/cases/console/libs/tasks/model.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/model.test.php
MIT
function testInteractiveFieldValidationWithBogusResponse() { $this->Task->initValidations(); $this->Task->interactive = true; $this->Task->setReturnValueAt(0, 'in', '999999'); $this->Task->setReturnValueAt(1, 'in', '19'); $this->Task->setReturnValueAt(2, 'in', 'n'); $this->Task->expectAt(4, 'out', array(new PatternExpectation('/make a valid/'))); $result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false)); $expected = array('notempty' => 'notempty'); $this->assertEqual($result, $expected); }
test that a bogus response doesn't cause errors to bubble up. @return void
testInteractiveFieldValidationWithBogusResponse
php
Datawalke/Coordino
cake/tests/cases/console/libs/tasks/model.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/model.test.php
MIT