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 testInteractiveFieldValidationWithRegexp() {
$this->Task->initValidations();
$this->Task->interactive = true;
$this->Task->setReturnValueAt(0, 'in', '/^[a-z]{0,9}$/');
$this->Task->setReturnValueAt(1, 'in', 'n');
$result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false));
$expected = array('a_z_0_9' => '/^[a-z]{0,9}$/');
$this->assertEqual($result, $expected);
} | test that a regular expression can be used for validation.
@return void | testInteractiveFieldValidationWithRegexp | 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 testNonInteractiveDoValidation() {
$Model =& new MockModelTaskModel();
$Model->primaryKey = 'id';
$Model->setReturnValue('schema', array(
'id' => array(
'type' => 'integer',
'length' => 11,
'null' => false,
'key' => 'primary',
),
'name' => array(
'type' => 'string',
'length' => 20,
'null' => false,
),
'email' => array(
'type' => 'string',
'length' => 255,
'null' => false,
),
'some_date' => array(
'type' => 'date',
'length' => '',
'null' => false,
),
'some_time' => array(
'type' => 'time',
'length' => '',
'null' => false,
),
'created' => array(
'type' => 'datetime',
'length' => '',
'null' => false,
)
));
$this->Task->interactive = false;
$result = $this->Task->doValidation($Model);
$expected = array(
'name' => array(
'notempty' => 'notempty'
),
'email' => array(
'email' => 'email',
),
'some_date' => array(
'date' => 'date'
),
'some_time' => array(
'time' => 'time'
),
);
$this->assertEqual($result, $expected);
} | test the validation Generation routine
@return void
@access public | testNonInteractiveDoValidation | 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 testFindPrimaryKey() {
$fields = array(
'one' => array(),
'two' => array(),
'key' => array('key' => 'primary')
);
$this->Task->expectAt(0, 'in', array('*', null, 'key'));
$this->Task->setReturnValue('in', 'my_field');
$result = $this->Task->findPrimaryKey($fields);
$expected = 'my_field';
$this->assertEqual($result, $expected);
} | test that finding primary key works
@return void
@access public | testFindPrimaryKey | 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 testFindDisplayField() {
$fields = array('id' => array(), 'tagname' => array(), 'body' => array(),
'created' => array(), 'modified' => array());
$this->Task->setReturnValue('in', 'n');
$this->Task->setReturnValueAt(0, 'in', 'n');
$result = $this->Task->findDisplayField($fields);
$this->assertFalse($result);
$this->Task->setReturnValueAt(1, 'in', 'y');
$this->Task->setReturnValueAt(2, 'in', 2);
$result = $this->Task->findDisplayField($fields);
$this->assertEqual($result, 'tagname');
} | test finding Display field
@return void
@access public | testFindDisplayField | 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 testBelongsToGeneration() {
$model = new Model(array('ds' => 'test_suite', 'name' => 'Comment'));
$result = $this->Task->findBelongsTo($model, array());
$expected = array(
'belongsTo' => array(
array(
'alias' => 'Article',
'className' => 'Article',
'foreignKey' => 'article_id',
),
array(
'alias' => 'User',
'className' => 'User',
'foreignKey' => 'user_id',
),
)
);
$this->assertEqual($result, $expected);
$model = new Model(array('ds' => 'test_suite', 'name' => 'CategoryThread'));
$result = $this->Task->findBelongsTo($model, array());
$expected = array(
'belongsTo' => array(
array(
'alias' => 'ParentCategoryThread',
'className' => 'CategoryThread',
'foreignKey' => 'parent_id',
),
)
);
$this->assertEqual($result, $expected);
} | test that belongsTo generation works.
@return void
@access public | testBelongsToGeneration | 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 testHasManyHasOneGeneration() {
$model = new Model(array('ds' => 'test_suite', 'name' => 'Article'));
$this->Task->connection = 'test_suite';
$this->Task->listAll();
$result = $this->Task->findHasOneAndMany($model, array());
$expected = array(
'hasMany' => array(
array(
'alias' => 'Comment',
'className' => 'Comment',
'foreignKey' => 'article_id',
),
),
'hasOne' => array(
array(
'alias' => 'Comment',
'className' => 'Comment',
'foreignKey' => 'article_id',
),
),
);
$this->assertEqual($result, $expected);
$model = new Model(array('ds' => 'test_suite', 'name' => 'CategoryThread'));
$result = $this->Task->findHasOneAndMany($model, array());
$expected = array(
'hasOne' => array(
array(
'alias' => 'ChildCategoryThread',
'className' => 'CategoryThread',
'foreignKey' => 'parent_id',
),
),
'hasMany' => array(
array(
'alias' => 'ChildCategoryThread',
'className' => 'CategoryThread',
'foreignKey' => 'parent_id',
),
)
);
$this->assertEqual($result, $expected);
} | test that hasOne and/or hasMany relations are generated properly.
@return void
@access public | testHasManyHasOneGeneration | 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 testHasAndBelongsToManyGeneration() {
$model = new Model(array('ds' => 'test_suite', 'name' => 'Article'));
$this->Task->connection = 'test_suite';
$this->Task->listAll();
$result = $this->Task->findHasAndBelongsToMany($model, array());
$expected = array(
'hasAndBelongsToMany' => array(
array(
'alias' => 'Tag',
'className' => 'Tag',
'foreignKey' => 'article_id',
'joinTable' => 'articles_tags',
'associationForeignKey' => 'tag_id',
),
),
);
$this->assertEqual($result, $expected);
} | Test that HABTM generation works
@return void
@access public | testHasAndBelongsToManyGeneration | 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 testDoAssociationsNonInteractive() {
$this->Task->connection = 'test_suite';
$this->Task->interactive = false;
$model = new Model(array('ds' => 'test_suite', 'name' => 'Article'));
$result = $this->Task->doAssociations($model);
$expected = array(
'hasMany' => array(
array(
'alias' => 'Comment',
'className' => 'Comment',
'foreignKey' => 'article_id',
),
),
'hasAndBelongsToMany' => array(
array(
'alias' => 'Tag',
'className' => 'Tag',
'foreignKey' => 'article_id',
'joinTable' => 'articles_tags',
'associationForeignKey' => 'tag_id',
),
),
);
} | test non interactive doAssociations
@return void
@access public | testDoAssociationsNonInteractive | 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 testBakeFixture() {
$this->Task->plugin = 'test_plugin';
$this->Task->interactive = true;
$this->Task->Fixture->expectAt(0, 'bake', array('Article', 'articles'));
$this->Task->bakeFixture('Article', 'articles');
$this->assertEqual($this->Task->plugin, $this->Task->Fixture->plugin);
$this->assertEqual($this->Task->connection, $this->Task->Fixture->connection);
$this->assertEqual($this->Task->interactive, $this->Task->Fixture->interactive);
} | Ensure that the fixutre object is correctly called.
@return void
@access public | testBakeFixture | 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 testBakeTest() {
$this->Task->plugin = 'test_plugin';
$this->Task->interactive = true;
$this->Task->Test->expectAt(0, 'bake', array('Model', 'Article'));
$this->Task->bakeTest('Article');
$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);
} | Ensure that the test object is correctly called.
@return void
@access public | testBakeTest | 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 testConfirmAssociations() {
$associations = array(
'hasOne' => array(
array(
'alias' => 'ChildCategoryThread',
'className' => 'CategoryThread',
'foreignKey' => 'parent_id',
),
),
'hasMany' => array(
array(
'alias' => 'ChildCategoryThread',
'className' => 'CategoryThread',
'foreignKey' => 'parent_id',
),
),
'belongsTo' => array(
array(
'alias' => 'User',
'className' => 'User',
'foreignKey' => 'user_id',
),
)
);
$model = new Model(array('ds' => 'test_suite', 'name' => 'CategoryThread'));
$this->Task->setReturnValueAt(0, 'in', 'y');
$result = $this->Task->confirmAssociations($model, $associations);
$this->assertTrue(empty($result['hasOne']));
$this->Task->setReturnValue('in', 'n');
$result = $this->Task->confirmAssociations($model, $associations);
$this->assertTrue(empty($result['hasMany']));
$this->assertTrue(empty($result['hasOne']));
} | test confirming of associations, and that when an association is hasMany
a question for the hasOne is also not asked.
@return void
@access public | testConfirmAssociations | 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 testInOptions() {
$options = array('one', 'two', 'three');
$this->Task->expectAt(0, 'out', array('1. one'));
$this->Task->expectAt(1, 'out', array('2. two'));
$this->Task->expectAt(2, 'out', array('3. three'));
$this->Task->setReturnValueAt(0, 'in', 10);
$this->Task->expectAt(3, 'out', array('1. one'));
$this->Task->expectAt(4, 'out', array('2. two'));
$this->Task->expectAt(5, 'out', array('3. three'));
$this->Task->setReturnValueAt(1, 'in', 2);
$result = $this->Task->inOptions($options, 'Pick a number');
$this->assertEqual($result, 1);
} | test that inOptions generates questions and only accepts a valid answer
@return void
@access public | testInOptions | 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 testBakeValidation() {
$validate = array(
'name' => array(
'notempty' => 'notempty'
),
'email' => array(
'email' => 'email',
),
'some_date' => array(
'date' => 'date'
),
'some_time' => array(
'time' => 'time'
)
);
$result = $this->Task->bake('Article', compact('validate'));
$this->assertPattern('/class Article extends AppModel \{/', $result);
$this->assertPattern('/\$name \= \'Article\'/', $result);
$this->assertPattern('/\$validate \= array\(/', $result);
$expected = <<< STRINGEND
array(
'notempty' => array(
'rule' => array('notempty'),
//'message' => 'Your custom message here',
//'allowEmpty' => false,
//'required' => false,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
STRINGEND;
$this->assertPattern('/' . preg_quote(str_replace("\r\n", "\n", $expected), '/') . '/', $result);
} | test baking validation
@return void
@access public | testBakeValidation | 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 testBakeRelations() {
$associations = array(
'belongsTo' => array(
array(
'alias' => 'SomethingElse',
'className' => 'SomethingElse',
'foreignKey' => 'something_else_id',
),
array(
'alias' => 'User',
'className' => 'User',
'foreignKey' => 'user_id',
),
),
'hasOne' => array(
array(
'alias' => 'OtherModel',
'className' => 'OtherModel',
'foreignKey' => 'other_model_id',
),
),
'hasMany' => array(
array(
'alias' => 'Comment',
'className' => 'Comment',
'foreignKey' => 'parent_id',
),
),
'hasAndBelongsToMany' => array(
array(
'alias' => 'Tag',
'className' => 'Tag',
'foreignKey' => 'article_id',
'joinTable' => 'articles_tags',
'associationForeignKey' => 'tag_id',
),
)
);
$result = $this->Task->bake('Article', compact('associations'));
$this->assertPattern('/\$hasAndBelongsToMany \= array\(/', $result);
$this->assertPattern('/\$hasMany \= array\(/', $result);
$this->assertPattern('/\$belongsTo \= array\(/', $result);
$this->assertPattern('/\$hasOne \= array\(/', $result);
$this->assertPattern('/Tag/', $result);
$this->assertPattern('/OtherModel/', $result);
$this->assertPattern('/SomethingElse/', $result);
$this->assertPattern('/Comment/', $result);
} | test baking relations
@return void
@access public | testBakeRelations | 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 testBakeWithPlugin() {
$this->Task->plugin = 'ControllerTest';
$path = APP . 'plugins' . DS . 'controller_test' . DS . 'models' . DS . 'article.php';
$this->Task->expectAt(0, 'createFile', array($path, '*'));
$this->Task->bake('Article', array(), array());
$this->Task->plugin = 'controllerTest';
$path = APP . 'plugins' . DS . 'controller_test' . DS . 'models' . DS . 'article.php';
$this->Task->expectAt(1, 'createFile', array(
$path, new PatternExpectation('/Article extends ControllerTestAppModel/')));
$this->Task->bake('Article', array(), array());
$this->assertEqual(count(ClassRegistry::keys()), 0);
$this->assertEqual(count(ClassRegistry::mapKeys()), 0);
} | test bake() with a -plugin param
@return void
@access public | testBakeWithPlugin | 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 testExecuteWithNamedModel() {
$this->Task->connection = 'test_suite';
$this->Task->path = '/my/path/';
$this->Task->args = array('article');
$filename = '/my/path/article.php';
$this->Task->setReturnValue('_checkUnitTest', 1);
$this->Task->expectAt(0, 'createFile', array($filename, new PatternExpectation('/class Article extends AppModel/')));
$this->Task->execute();
$this->assertEqual(count(ClassRegistry::keys()), 0);
$this->assertEqual(count(ClassRegistry::mapKeys()), 0);
} | test that execute passes runs bake depending with named model.
@return void
@access public | testExecuteWithNamedModel | 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 testExecuteWithNamedModelVariations() {
$this->Task->connection = 'test_suite';
$this->Task->path = '/my/path/';
$this->Task->setReturnValue('_checkUnitTest', 1);
$this->Task->args = array('article');
$filename = '/my/path/article.php';
$this->Task->expectAt(0, 'createFile', array($filename, new PatternExpectation('/class Article extends AppModel/')));
$this->Task->execute();
$this->Task->args = array('Articles');
$this->Task->expectAt(1, 'createFile', array($filename, new PatternExpectation('/class Article extends AppModel/')));
$this->Task->execute();
$this->Task->args = array('articles');
$this->Task->expectAt(2, 'createFile', array($filename, new PatternExpectation('/class Article extends AppModel/')));
$this->Task->execute();
} | test that execute passes with different inflections of the same name.
@return void
@access public | testExecuteWithNamedModelVariations | 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 testExecuteWithNamedModelHasManyCreated() {
$this->Task->connection = 'test_suite';
$this->Task->path = '/my/path/';
$this->Task->args = array('article');
$filename = '/my/path/article.php';
$this->Task->setReturnValue('_checkUnitTest', 1);
$this->Task->expectAt(0, 'createFile', array($filename, new PatternExpectation("/'Comment' \=\> array\(/")));
$this->Task->execute();
} | test that execute with a model name picks up hasMany associations.
@return void
@access public | testExecuteWithNamedModelHasManyCreated | 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 testExecuteIntoAll() {
$this->Task->connection = 'test_suite';
$this->Task->path = '/my/path/';
$this->Task->args = array('all');
$this->Task->setReturnValue('_checkUnitTest', true);
$this->Task->Fixture->expectCallCount('bake', 5);
$this->Task->Test->expectCallCount('bake', 5);
$filename = '/my/path/article.php';
$this->Task->expectAt(0, 'createFile', array($filename, new PatternExpectation('/class Article/')));
$filename = '/my/path/articles_tag.php';
$this->Task->expectAt(1, 'createFile', array($filename, new PatternExpectation('/class ArticlesTag/')));
$filename = '/my/path/category_thread.php';
$this->Task->expectAt(2, 'createFile', array($filename, new PatternExpectation('/class CategoryThread/')));
$filename = '/my/path/comment.php';
$this->Task->expectAt(3, 'createFile', array($filename, new PatternExpectation('/class Comment/')));
$filename = '/my/path/tag.php';
$this->Task->expectAt(4, 'createFile', array($filename, new PatternExpectation('/class Tag/')));
$this->Task->execute();
$this->assertEqual(count(ClassRegistry::keys()), 0);
$this->assertEqual(count(ClassRegistry::mapKeys()), 0);
} | test that execute runs all() when args[0] = all
@return void
@access public | testExecuteIntoAll | 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 testSkipTablesAndAll() {
$this->Task->connection = 'test_suite';
$this->Task->path = '/my/path/';
$this->Task->args = array('all');
$this->Task->setReturnValue('_checkUnitTest', true);
$this->Task->skipTables = array('tags');
$this->Task->Fixture->expectCallCount('bake', 4);
$this->Task->Test->expectCallCount('bake', 4);
$filename = '/my/path/article.php';
$this->Task->expectAt(0, 'createFile', array($filename, new PatternExpectation('/class Article/')));
$filename = '/my/path/articles_tag.php';
$this->Task->expectAt(1, 'createFile', array($filename, new PatternExpectation('/class ArticlesTag/')));
$filename = '/my/path/category_thread.php';
$this->Task->expectAt(2, 'createFile', array($filename, new PatternExpectation('/class CategoryThread/')));
$filename = '/my/path/comment.php';
$this->Task->expectAt(3, 'createFile', array($filename, new PatternExpectation('/class Comment/')));
$this->Task->execute();
} | test that skipTables changes how all() works.
@return void | testSkipTablesAndAll | 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 testExecuteIntoInteractive() {
$this->Task->connection = 'test_suite';
$this->Task->path = '/my/path/';
$this->Task->interactive = true;
$this->Task->setReturnValueAt(0, 'in', '1'); //choose article
$this->Task->setReturnValueAt(1, 'in', 'n'); //no validation
$this->Task->setReturnValueAt(2, 'in', 'y'); //yes to associations
$this->Task->setReturnValueAt(3, 'in', 'y'); //yes to comment relation
$this->Task->setReturnValueAt(4, 'in', 'y'); //yes to user relation
$this->Task->setReturnValueAt(5, 'in', 'y'); //yes to tag relation
$this->Task->setReturnValueAt(6, 'in', 'n'); //no to additional assocs
$this->Task->setReturnValueAt(7, 'in', 'y'); //yes to looksGood?
$this->Task->setReturnValue('_checkUnitTest', true);
$this->Task->Test->expectOnce('bake');
$this->Task->Fixture->expectOnce('bake');
$filename = '/my/path/article.php';
$this->Task->expectOnce('createFile');
$this->Task->expectAt(0, 'createFile', array($filename, new PatternExpectation('/class Article/')));
$this->Task->execute();
$this->assertEqual(count(ClassRegistry::keys()), 0);
$this->assertEqual(count(ClassRegistry::mapKeys()), 0);
} | test the interactive side of bake.
@return void
@access public | testExecuteIntoInteractive | 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 testExecuteWithNonExistantTableName() {
$this->Task->connection = 'test_suite';
$this->Task->path = '/my/path/';
$this->Task->expectOnce('_stop');
$this->Task->expectOnce('err');
$this->Task->setReturnValueAt(0, 'in', 'Foobar');
$this->Task->setReturnValueAt(1, 'in', 'y');
$this->Task->execute();
} | test using bake interactively with a table that does not exist.
@return void
@access public | testExecuteWithNonExistantTableName | 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 startTest() {
$this->Dispatcher =& new TestPluginTaskMockShellDispatcher();
$this->Dispatcher->shellPaths = App::path('shells');
$this->Task =& new MockPluginTask($this->Dispatcher);
$this->Task->Dispatch =& $this->Dispatcher;
$this->Task->path = TMP . 'tests' . DS;
} | startTest method
@return void
@access public | startTest | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/plugin.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/plugin.test.php | MIT |
function startCase() {
$this->_paths = $paths = App::path('plugins');
$this->_testPath = array_push($paths, TMP . 'tests' . DS);
App::build(array('plugins' => $paths));
} | startCase methods
@return void
@access public | startCase | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/plugin.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/plugin.test.php | MIT |
function testBakeFoldersAndFiles() {
$this->Task->setReturnValueAt(0, 'in', $this->_testPath);
$this->Task->setReturnValueAt(1, 'in', 'y');
$this->Task->bake('BakeTestPlugin');
$path = $this->Task->path . 'bake_test_plugin';
$this->assertTrue(is_dir($path), 'No plugin dir %s');
$this->assertTrue(is_dir($path . DS . 'config'), 'No config dir %s');
$this->assertTrue(is_dir($path . DS . 'config' . DS . 'schema'), 'No schema dir %s');
$this->assertTrue(file_exists($path . DS . 'config' . DS . 'schema' . DS . 'empty'), 'No empty file %s');
$this->assertTrue(is_dir($path . DS . 'controllers'), 'No controllers dir %s');
$this->assertTrue(is_dir($path . DS . 'controllers' . DS .'components'), 'No components dir %s');
$this->assertTrue(file_exists($path . DS . 'controllers' . DS . 'components' . DS . 'empty'), 'No empty file %s');
$this->assertTrue(is_dir($path . DS . 'models'), 'No models dir %s');
$this->assertTrue(file_exists($path . DS . 'models' . DS . 'behaviors' . DS . 'empty'), 'No empty file %s');
$this->assertTrue(is_dir($path . DS . 'models' . DS . 'datasources'), 'No datasources dir %s');
$this->assertTrue(file_exists($path . DS . 'models' . DS . 'datasources' . DS . 'empty'), 'No empty file %s');
$this->assertTrue(is_dir($path . DS . 'views'), 'No views dir %s');
$this->assertTrue(is_dir($path . DS . 'views' . DS . 'helpers'), 'No helpers dir %s');
$this->assertTrue(file_exists($path . DS . 'views' . DS . 'helpers' . DS . 'empty'), 'No empty file %s');
$this->assertTrue(is_dir($path . DS . 'tests'), 'No tests dir %s');
$this->assertTrue(is_dir($path . DS . 'tests' . DS . 'cases'), 'No cases dir %s');
$this->assertTrue(
is_dir($path . DS . 'tests' . DS . 'cases' . DS . 'components'), 'No components cases dir %s'
);
$this->assertTrue(
file_exists($path . DS . 'tests' . DS . 'cases' . DS . 'components' . DS . 'empty'), 'No empty file %s'
);
$this->assertTrue(is_dir($path . DS . 'tests' . DS . 'cases' . DS . 'behaviors'), 'No behaviors cases dir %s');
$this->assertTrue(
file_exists($path . DS . 'tests' . DS . 'cases' . DS . 'behaviors' . DS . 'empty'), 'No empty file %s'
);
$this->assertTrue(is_dir($path . DS . 'tests' . DS . 'cases' . DS . 'helpers'), 'No helpers cases dir %s');
$this->assertTrue(
file_exists($path . DS . 'tests' . DS . 'cases' . DS . 'helpers' . DS . 'empty'), 'No empty file %s'
);
$this->assertTrue(is_dir($path . DS . 'tests' . DS . 'cases' . DS . 'models'), 'No models cases dir %s');
$this->assertTrue(
file_exists($path . DS . 'tests' . DS . 'cases' . DS . 'models' . DS . 'empty'), 'No empty file %s'
);
$this->assertTrue(
is_dir($path . DS . 'tests' . DS . 'cases' . DS . 'controllers'),
'No controllers cases dir %s'
);
$this->assertTrue(
file_exists($path . DS . 'tests' . DS . 'cases' . DS . 'controllers' . DS . 'empty'), 'No empty file %s'
);
$this->assertTrue(is_dir($path . DS . 'tests' . DS . 'groups'), 'No groups dir %s');
$this->assertTrue(file_exists($path . DS . 'tests' . DS . 'groups' . DS . 'empty'), 'No empty file %s');
$this->assertTrue(is_dir($path . DS . 'tests' . DS . 'fixtures'), 'No fixtures dir %s');
$this->assertTrue(file_exists($path . DS . 'tests' . DS . 'fixtures' . DS . 'empty'), 'No empty file %s');
$this->assertTrue(is_dir($path . DS . 'vendors'), 'No vendors dir %s');
$this->assertTrue(is_dir($path . DS . 'vendors' . DS . 'shells'), 'No vendors shells dir %s');
$this->assertTrue(is_dir($path . DS . 'vendors' . DS . 'shells' . DS . 'tasks'), 'No vendors shells tasks dir %s');
$this->assertTrue(file_exists($path . DS . 'vendors' . DS . 'shells' . DS . 'tasks' . DS . 'empty'), 'No empty file %s');
$this->assertTrue(is_dir($path . DS . 'libs'), 'No libs dir %s');
$this->assertTrue(is_dir($path . DS . 'webroot'), 'No webroot dir %s');
$file = $path . DS . 'bake_test_plugin_app_controller.php';
$this->Task->expectAt(0, 'createFile', array($file, '*'), 'No AppController %s');
$file = $path . DS . 'bake_test_plugin_app_model.php';
$this->Task->expectAt(1, 'createFile', array($file, '*'), 'No AppModel %s');
$Folder =& new Folder($this->Task->path . 'bake_test_plugin');
$Folder->delete();
} | test bake()
@return void
@access public | testBakeFoldersAndFiles | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/plugin.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/plugin.test.php | MIT |
function testExecuteWithNoArgs() {
$this->Task->setReturnValueAt(0, 'in', 'TestPlugin');
$this->Task->setReturnValueAt(1, 'in', '3');
$this->Task->setReturnValueAt(2, 'in', 'y');
$this->Task->setReturnValueAt(3, 'in', 'n');
$path = $this->Task->path . 'test_plugin';
$file = $path . DS . 'test_plugin_app_controller.php';
$this->Task->expectAt(0, 'createFile', array($file, '*'), 'No AppController %s');
$file = $path . DS . 'test_plugin_app_model.php';
$this->Task->expectAt(1, 'createFile', array($file, '*'), 'No AppModel %s');
$this->Task->args = array();
$this->Task->execute();
$Folder =& new Folder($path);
$Folder->delete();
} | test execute with no args, flowing into interactive,
@return void
@access public | testExecuteWithNoArgs | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/plugin.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/plugin.test.php | MIT |
function testExecuteWithOneArg() {
$this->Task->setReturnValueAt(0, 'in', $this->_testPath);
$this->Task->setReturnValueAt(1, 'in', 'y');
$this->Task->Dispatch->args = array('BakeTestPlugin');
$this->Task->args =& $this->Task->Dispatch->args;
$path = $this->Task->path . 'bake_test_plugin';
$file = $path . DS . 'bake_test_plugin_app_controller.php';
$this->Task->expectAt(0, 'createFile', array($file, '*'), 'No AppController %s');
$file = $path . DS . 'bake_test_plugin_app_model.php';
$this->Task->expectAt(1, 'createFile', array($file, '*'), 'No AppModel %s');
$this->Task->execute();
$Folder =& new Folder($this->Task->path . 'bake_test_plugin');
$Folder->delete();
} | Test Execute
@return void
@access public | testExecuteWithOneArg | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/plugin.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/plugin.test.php | MIT |
function testExecuteWithTwoArgs() {
$this->Task->Model =& new PluginTestMockModelTask();
$this->Task->setReturnValueAt(0, 'in', $this->_testPath);
$this->Task->setReturnValueAt(1, 'in', 'y');
$Folder =& new Folder($this->Task->path . 'bake_test_plugin', true);
$this->Task->Dispatch->args = array('BakeTestPlugin', 'model');
$this->Task->args =& $this->Task->Dispatch->args;
$this->Task->Model->expectOnce('loadTasks');
$this->Task->Model->expectOnce('execute');
$this->Task->execute();
$Folder->delete();
} | test execute chaining into MVC parts
@return void
@access public | testExecuteWithTwoArgs | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/plugin.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/plugin.test.php | MIT |
function startTest() {
$this->Dispatcher =& new TestProjectTaskMockShellDispatcher();
$this->Dispatcher->shellPaths = App::path('shells');
$this->Task =& new MockProjectTask($this->Dispatcher);
$this->Task->Dispatch =& $this->Dispatcher;
$this->Task->path = TMP . 'tests' . DS;
} | startTest method
@return void
@access public | startTest | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/project.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/project.test.php | MIT |
function endTest() {
ClassRegistry::flush();
$Folder =& new Folder($this->Task->path . 'bake_test_app');
$Folder->delete();
} | endTest method
@return void
@access public | endTest | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/project.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/project.test.php | MIT |
function _setupTestProject() {
$skel = CAKE_CORE_INCLUDE_PATH . DS . CAKE . 'console' . DS . 'templates' . DS . 'skel';
$this->Task->setReturnValueAt(0, 'in', 'y');
$this->Task->setReturnValueAt(1, 'in', 'n');
$this->Task->bake($this->Task->path . 'bake_test_app', $skel);
} | creates a test project that is used for testing project task.
@return void
@access protected | _setupTestProject | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/project.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/project.test.php | MIT |
function testBake() {
$this->_setupTestProject();
$path = $this->Task->path . 'bake_test_app';
$this->assertTrue(is_dir($path), 'No project dir %s');
$this->assertTrue(is_dir($path . DS . 'controllers'), 'No controllers dir %s');
$this->assertTrue(is_dir($path . DS . 'controllers' . DS .'components'), 'No components dir %s');
$this->assertTrue(is_dir($path . DS . 'models'), 'No models dir %s');
$this->assertTrue(is_dir($path . DS . 'views'), 'No views dir %s');
$this->assertTrue(is_dir($path . DS . 'views' . DS . 'helpers'), 'No helpers dir %s');
$this->assertTrue(is_dir($path . DS . 'tests'), 'No tests dir %s');
$this->assertTrue(is_dir($path . DS . 'tests' . DS . 'cases'), 'No cases dir %s');
$this->assertTrue(is_dir($path . DS . 'tests' . DS . 'groups'), 'No groups dir %s');
$this->assertTrue(is_dir($path . DS . 'tests' . DS . 'fixtures'), 'No fixtures dir %s');
} | test bake() method and directory creation.
@return void
@access public | testBake | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/project.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/project.test.php | MIT |
function testBakeEmptyFlag() {
$this->Task->params['empty'] = true;
$this->_setupTestProject();
$path = $this->Task->path . 'bake_test_app';
$this->assertTrue(is_dir($path), 'No project dir %s');
$this->assertTrue(is_dir($path . DS . 'controllers'), 'No controllers dir %s');
$this->assertTrue(is_dir($path . DS . 'controllers' . DS .'components'), 'No components dir %s');
$this->assertTrue(is_dir($path . DS . 'models'), 'No models dir %s');
$this->assertTrue(is_dir($path . DS . 'views'), 'No views dir %s');
$this->assertTrue(is_dir($path . DS . 'views' . DS . 'helpers'), 'No helpers dir %s');
$this->assertTrue(is_dir($path . DS . 'tests'), 'No tests dir %s');
$this->assertTrue(is_dir($path . DS . 'tests' . DS . 'cases'), 'No cases dir %s');
$this->assertTrue(is_dir($path . DS . 'tests' . DS . 'groups'), 'No groups dir %s');
$this->assertTrue(is_dir($path . DS . 'tests' . DS . 'fixtures'), 'No fixtures dir %s');
$this->assertTrue(is_file($path . DS . 'controllers' . DS .'components' . DS . 'empty'), 'No empty file in dir %s');
$this->assertTrue(is_file($path . DS . 'locale' . DS . 'eng' . DS . 'LC_MESSAGES' . DS . 'empty'), 'No empty file in dir %s');
$this->assertTrue(is_file($path . DS . 'models' . DS . 'behaviors' . DS . 'empty'), 'No empty file in dir %s');
$this->assertTrue(is_file($path . DS . 'models' . DS . 'datasources' . DS . 'empty'), 'No empty file in dir %s');
$this->assertTrue(is_file($path . DS . 'plugins' . DS . 'empty'), 'No empty file in dir %s');
$this->assertTrue(is_file($path . DS . 'tests' . DS . 'cases' . DS . 'behaviors' . DS . 'empty'), 'No empty file in dir %s');
$this->assertTrue(is_file($path . DS . 'tests' . DS . 'cases' . DS . 'components' . DS . 'empty'), 'No empty file in dir %s');
$this->assertTrue(is_file($path . DS . 'tests' . DS . 'cases' . DS . 'controllers' . DS . 'empty'), 'No empty file in dir %s');
$this->assertTrue(is_file($path . DS . 'tests' . DS . 'cases' . DS . 'datasources' . DS . 'empty'), 'No empty file in dir %s');
$this->assertTrue(is_file($path . DS . 'tests' . DS . 'cases' . DS . 'helpers' . DS . 'empty'), 'No empty file in dir %s');
$this->assertTrue(is_file($path . DS . 'tests' . DS . 'cases' . DS . 'models' . DS . 'empty'), 'No empty file in dir %s');
$this->assertTrue(is_file($path . DS . 'tests' . DS . 'cases' . DS . 'shells' . DS . 'empty'), 'No empty file in dir %s');
$this->assertTrue(is_file($path . DS . 'tests' . DS . 'fixtures' . DS . 'empty'), 'No empty file in dir %s');
$this->assertTrue(is_file($path . DS . 'tests' . DS . 'groups' . DS . 'empty'), 'No empty file in dir %s');
$this->assertTrue(is_file($path . DS . 'vendors' . DS . 'shells' . DS . 'tasks' . DS . 'empty'), 'No empty file in dir %s');
$this->assertTrue(is_file($path . DS . 'views' . DS . 'errors' . DS . 'empty'), 'No empty file in dir %s');
$this->assertTrue(is_file($path . DS . 'views' . DS . 'helpers' . DS . 'empty'), 'No empty file in dir %s');
$this->assertTrue(is_file($path . DS . 'views' . DS . 'scaffolds' . DS . 'empty'), 'No empty file in dir %s');
$this->assertTrue(is_file($path . DS . 'webroot' . DS . 'js' . DS . 'empty'), 'No empty file in dir %s');
} | test bake() method with -empty flag, directory creation and empty files.
@return void
@access public | testBakeEmptyFlag | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/project.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/project.test.php | MIT |
function testSecuritySaltGeneration() {
$this->_setupTestProject();
$path = $this->Task->path . 'bake_test_app' . DS;
$result = $this->Task->securitySalt($path);
$this->assertTrue($result);
$file =& new File($path . 'config' . DS . 'core.php');
$contents = $file->read();
$this->assertNoPattern('/DYhG93b0qyJfIxfs2guVoUubWwvniR2G0FgaC9mi/', $contents, 'Default Salt left behind. %s');
} | test generation of Security.salt
@return void
@access public | testSecuritySaltGeneration | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/project.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/project.test.php | MIT |
function testSecurityCipherSeedGeneration() {
$this->_setupTestProject();
$path = $this->Task->path . 'bake_test_app' . DS;
$result = $this->Task->securityCipherSeed($path);
$this->assertTrue($result);
$file =& new File($path . 'config' . DS . 'core.php');
$contents = $file->read();
$this->assertNoPattern('/76859309657453542496749683645/', $contents, 'Default CipherSeed left behind. %s');
} | test generation of Security.cipherSeed
@return void
@access public | testSecurityCipherSeedGeneration | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/project.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/project.test.php | MIT |
function testIndexPhpGeneration() {
$this->_setupTestProject();
$path = $this->Task->path . 'bake_test_app' . DS;
$this->Task->corePath($path);
$file =& new File($path . 'webroot' . DS . 'index.php');
$contents = $file->read();
$this->assertNoPattern('/define\(\'CAKE_CORE_INCLUDE_PATH\', \'ROOT/', $contents);
$file =& new File($path . 'webroot' . DS . 'test.php');
$contents = $file->read();
$this->assertNoPattern('/define\(\'CAKE_CORE_INCLUDE_PATH\', \'ROOT/', $contents);
} | Test that index.php is generated correctly.
@return void
@access public | testIndexPhpGeneration | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/project.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/project.test.php | MIT |
function testGetPrefix() {
Configure::write('Routing.prefixes', array('admin'));
$result = $this->Task->getPrefix();
$this->assertEqual($result, 'admin_');
Configure::write('Routing.prefixes', null);
$this->_setupTestProject();
$this->Task->configPath = $this->Task->path . 'bake_test_app' . DS . 'config' . DS;
$this->Task->setReturnValue('in', 'super_duper_admin');
$result = $this->Task->getPrefix();
$this->assertEqual($result, 'super_duper_admin_');
$file =& new File($this->Task->configPath . 'core.php');
$file->delete();
} | test getPrefix method, and that it returns Routing.prefix or writes to config file.
@return void
@access public | testGetPrefix | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/project.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/project.test.php | MIT |
function testCakeAdmin() {
$file =& new File(CONFIGS . 'core.php');
$contents = $file->read();;
$file =& new File(TMP . 'tests' . DS . 'core.php');
$file->write($contents);
Configure::write('Routing.prefixes', null);
$this->Task->configPath = TMP . 'tests' . DS;
$result = $this->Task->cakeAdmin('my_prefix');
$this->assertTrue($result);
$this->assertEqual(Configure::read('Routing.prefixes'), array('my_prefix'));
$file->delete();
} | test cakeAdmin() writing core.php
@return void
@access public | testCakeAdmin | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/project.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/project.test.php | MIT |
function testGetPrefixWithMultiplePrefixes() {
Configure::write('Routing.prefixes', array('admin', 'ninja', 'shinobi'));
$this->_setupTestProject();
$this->Task->configPath = $this->Task->path . 'bake_test_app' . DS . 'config' . DS;
$this->Task->setReturnValue('in', 2);
$result = $this->Task->getPrefix();
$this->assertEqual($result, 'ninja_');
} | test getting the prefix with more than one prefix setup
@return void
@access public | testGetPrefixWithMultiplePrefixes | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/project.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/project.test.php | MIT |
function testExecute() {
$this->Task->params['skel'] = CAKE_CORE_INCLUDE_PATH . DS . CAKE . DS . 'console' . DS. 'templates' . DS . 'skel';
$this->Task->params['working'] = TMP . 'tests' . DS;
$path = $this->Task->path . 'bake_test_app';
$this->Task->setReturnValue('in', 'y');
$this->Task->setReturnValueAt(0, 'in', $path);
$this->Task->execute();
$this->assertTrue(is_dir($path), 'No project dir %s');
$this->assertTrue(is_dir($path . DS . 'controllers'), 'No controllers dir %s');
$this->assertTrue(is_dir($path . DS . 'controllers' . DS .'components'), 'No components dir %s');
$this->assertTrue(is_dir($path . DS . 'models'), 'No models dir %s');
$this->assertTrue(is_dir($path . DS . 'views'), 'No views dir %s');
$this->assertTrue(is_dir($path . DS . 'views' . DS . 'helpers'), 'No helpers dir %s');
$this->assertTrue(is_dir($path . DS . 'tests'), 'No tests dir %s');
$this->assertTrue(is_dir($path . DS . 'tests' . DS . 'cases'), 'No cases dir %s');
$this->assertTrue(is_dir($path . DS . 'tests' . DS . 'groups'), 'No groups dir %s');
$this->assertTrue(is_dir($path . DS . 'tests' . DS . 'fixtures'), 'No fixtures dir %s');
} | Test execute method with one param to destination folder.
@return void
@access public | testExecute | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/project.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/project.test.php | MIT |
function startTest() {
$this->Dispatcher =& new TestTemplateTaskMockShellDispatcher();
$this->Task =& new MockTemplateTask($this->Dispatcher);
$this->Task->Dispatch =& $this->Dispatcher;
$this->Task->Dispatch->shellPaths = App::path('shells');
} | startTest method
@return void
@access public | startTest | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/template.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/template.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/template.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/template.test.php | MIT |
function testSet() {
$this->Task->set('one', 'two');
$this->assertTrue(isset($this->Task->templateVars['one']));
$this->assertEqual($this->Task->templateVars['one'], 'two');
$this->Task->set(array('one' => 'three', 'four' => 'five'));
$this->assertTrue(isset($this->Task->templateVars['one']));
$this->assertEqual($this->Task->templateVars['one'], 'three');
$this->assertTrue(isset($this->Task->templateVars['four']));
$this->assertEqual($this->Task->templateVars['four'], 'five');
$this->Task->templateVars = array();
$this->Task->set(array(3 => 'three', 4 => 'four'));
$this->Task->set(array(1 => 'one', 2 => 'two'));
$expected = array(3 => 'three', 4 => 'four', 1 => 'one', 2 => 'two');
$this->assertEqual($this->Task->templateVars, $expected);
} | test that set sets variables
@return void
@access public | testSet | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/template.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/template.test.php | MIT |
function testFindingInstalledThemesForBake() {
$consoleLibs = CAKE_CORE_INCLUDE_PATH . DS . CAKE . 'console' . DS;
$this->Task->Dispatch->shellPaths = array($consoleLibs);
$this->Task->initialize();
$this->assertEqual($this->Task->templatePaths, array('default' => $consoleLibs . 'templates' . DS . 'default' . DS));
} | test finding themes installed in
@return void
@access public | testFindingInstalledThemesForBake | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/template.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/template.test.php | MIT |
function testGetThemePath() {
$defaultTheme = CAKE_CORE_INCLUDE_PATH . DS . dirname(CONSOLE_LIBS) . 'templates' . DS . 'default' .DS;
$this->Task->templatePaths = array('default' => $defaultTheme);
$this->Task->expectCallCount('in', 1);
$result = $this->Task->getThemePath();
$this->assertEqual($result, $defaultTheme);
$this->Task->templatePaths = array('default' => $defaultTheme, 'other' => '/some/path');
$this->Task->params['theme'] = 'other';
$result = $this->Task->getThemePath();
$this->assertEqual($result, '/some/path');
$this->Task->params = array();
$this->Task->setReturnValueAt(0, 'in', '1');
$result = $this->Task->getThemePath();
$this->assertEqual($result, $defaultTheme);
$this->assertEqual($this->Dispatcher->params['theme'], 'default');
} | test getting the correct theme name. Ensure that with only one theme, or a theme param
that the user is not bugged. If there are more, find and return the correct theme name
@return void
@access public | testGetThemePath | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/template.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/template.test.php | MIT |
function testGenerate() {
App::build(array(
'shells' => array(
TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'vendors' . DS . 'shells' . DS
)
));
$this->Task->initialize();
$this->Task->setReturnValue('in', 1);
$result = $this->Task->generate('classes', 'test_object', array('test' => 'foo'));
$expected = "I got rendered\nfoo";
$this->assertEqual($result, $expected);
} | test generate
@return void
@access public | testGenerate | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/template.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/template.test.php | MIT |
function testGenerateWithTemplateFallbacks() {
App::build(array(
'shells' => array(
TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'vendors' . DS . 'shells' . DS,
CAKE_CORE_INCLUDE_PATH . DS . 'console' . DS
)
));
$this->Task->initialize();
$this->Task->params['theme'] = 'test';
$this->Task->set(array(
'model' => 'Article',
'table' => 'articles',
'import' => false,
'records' => false,
'schema' => ''
));
$result = $this->Task->generate('classes', 'fixture');
$this->assertPattern('/ArticleFixture extends CakeTestFixture/', $result);
} | test generate with a missing template in the chosen theme.
ensure fallback to default works.
@return void
@access public | testGenerateWithTemplateFallbacks | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/template.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/template.test.php | MIT |
function startTest() {
$this->Dispatcher =& new TestTestTaskMockShellDispatcher();
$this->Dispatcher->shellPaths = App::path('shells');
$this->Task =& new MockTestTask($this->Dispatcher);
$this->Task->name = 'TestTask';
$this->Task->Dispatch =& $this->Dispatcher;
$this->Task->Template =& new TemplateTask($this->Dispatcher);
} | startTest method
@return void
@access public | startTest | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/test.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/test.test.php | MIT |
function endTest() {
ClassRegistry::flush();
App::build();
} | endTest method
@return void
@access public | endTest | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/test.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/test.test.php | MIT |
function testFilePathGeneration() {
$file = TESTS . 'cases' . DS . 'models' . DS . 'my_class.test.php';
$this->Task->Dispatch->expectNever('stderr');
$this->Task->Dispatch->expectNever('_stop');
$this->Task->setReturnValue('in', 'y');
$this->Task->expectAt(0, 'createFile', array($file, '*'));
$this->Task->bake('Model', 'MyClass');
$this->Task->expectAt(1, 'createFile', array($file, '*'));
$this->Task->bake('Model', 'MyClass');
$file = TESTS . 'cases' . DS . 'controllers' . DS . 'comments_controller.test.php';
$this->Task->expectAt(2, 'createFile', array($file, '*'));
$this->Task->bake('Controller', 'Comments');
} | Test that file path generation doesn't continuously append paths.
@return void
@access public | testFilePathGeneration | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/test.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/test.test.php | MIT |
function testMethodIntrospection() {
$result = $this->Task->getTestableMethods('TestTaskArticle');
$expected = array('dosomething', 'dosomethingelse');
$this->assertEqual(array_map('strtolower', $result), $expected);
} | Test that method introspection pulls all relevant non parent class
methods into the test case.
@return void | testMethodIntrospection | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/test.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/test.test.php | MIT |
function testFixtureArrayGenerationFromModel() {
$subject = ClassRegistry::init('TestTaskArticle');
$result = $this->Task->generateFixtureList($subject);
$expected = array('plugin.test_task.test_task_comment', 'app.articles_tags',
'app.test_task_article', 'app.test_task_tag');
$this->assertEqual(sort($result), sort($expected));
} | test that the generation of fixtures works correctly.
@return void
@access public | testFixtureArrayGenerationFromModel | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/test.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/test.test.php | MIT |
function testFixtureArrayGenerationFromController() {
$subject = new TestTaskCommentsController();
$result = $this->Task->generateFixtureList($subject);
$expected = array('plugin.test_task.test_task_comment', 'app.articles_tags',
'app.test_task_article', 'app.test_task_tag');
$this->assertEqual(sort($result), sort($expected));
} | test that the generation of fixtures works correctly.
@return void
@access public | testFixtureArrayGenerationFromController | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/test.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/test.test.php | MIT |
function testGetObjectType() {
$this->Task->expectOnce('_stop');
$this->Task->setReturnValueAt(0, 'in', 'q');
$this->Task->getObjectType();
$this->Task->setReturnValueAt(1, 'in', 2);
$result = $this->Task->getObjectType();
$this->assertEqual($result, $this->Task->classTypes[1]);
} | test user interaction to get object type
@return void
@access public | testGetObjectType | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/test.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/test.test.php | MIT |
function testRegistryClearWhenBuildingTestObjects() {
ClassRegistry::flush();
$model = ClassRegistry::init('TestTaskComment');
$model->bindModel(array(
'belongsTo' => array(
'Random' => array(
'className' => 'TestTaskArticle',
'foreignKey' => 'article_id',
)
)
));
$keys = ClassRegistry::keys();
$this->assertTrue(in_array('random', $keys));
$object =& $this->Task->buildTestSubject('Model', 'TestTaskComment');
$keys = ClassRegistry::keys();
$this->assertFalse(in_array('random', $keys));
} | creating test subjects should clear the registry so the registry is always fresh
@return void
@access public | testRegistryClearWhenBuildingTestObjects | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/test.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/test.test.php | MIT |
function testGetClassName() {
$objects = App::objects('model');
$skip = $this->skipIf(empty($objects), 'No models in app, this test will fail. %s');
if ($skip) {
return;
}
$this->Task->setReturnValueAt(0, 'in', 'MyCustomClass');
$result = $this->Task->getClassName('Model');
$this->assertEqual($result, 'MyCustomClass');
$this->Task->setReturnValueAt(1, 'in', 1);
$result = $this->Task->getClassName('Model');
$options = App::objects('model');
$this->assertEqual($result, $options[0]);
} | test that getClassName returns the user choice as a classname.
@return void
@access public | testGetClassName | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/test.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/test.test.php | MIT |
function testGetUserFixtures() {
$this->Task->setReturnValueAt(0, 'in', 'y');
$this->Task->setReturnValueAt(1, 'in', 'app.pizza, app.topping, app.side_dish');
$result = $this->Task->getUserFixtures();
$expected = array('app.pizza', 'app.topping', 'app.side_dish');
$this->assertEqual($result, $expected);
} | Test the user interaction for defining additional fixtures.
@return void
@access public | testGetUserFixtures | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/test.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/test.test.php | MIT |
function testGetRealClassname() {
$result = $this->Task->getRealClassname('Model', 'Post');
$this->assertEqual($result, 'Post');
$result = $this->Task->getRealClassname('Controller', 'Posts');
$this->assertEqual($result, 'PostsController');
$result = $this->Task->getRealClassname('Helper', 'Form');
$this->assertEqual($result, 'FormHelper');
$result = $this->Task->getRealClassname('Behavior', 'Containable');
$this->assertEqual($result, 'ContainableBehavior');
$result = $this->Task->getRealClassname('Component', 'Auth');
$this->assertEqual($result, 'AuthComponent');
} | test that resolving classnames works
@return void
@access public | testGetRealClassname | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/test.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/test.test.php | MIT |
function testBakeModelTest() {
$this->Task->setReturnValue('createFile', true);
$this->Task->setReturnValue('isLoadableClass', true);
$result = $this->Task->bake('Model', 'TestTaskArticle');
$this->assertPattern('/App::import\(\'Model\', \'TestTaskArticle\'\)/', $result);
$this->assertPattern('/class TestTaskArticleTestCase extends CakeTestCase/', $result);
$this->assertPattern('/function startTest\(\)/', $result);
$this->assertPattern("/\\\$this->TestTaskArticle \=\& ClassRegistry::init\('TestTaskArticle'\)/", $result);
$this->assertPattern('/function endTest\(\)/', $result);
$this->assertPattern('/unset\(\$this->TestTaskArticle\)/', $result);
$this->assertPattern('/function testDoSomething\(\)/i', $result);
$this->assertPattern('/function testDoSomethingElse\(\)/i', $result);
$this->assertPattern("/'app\.test_task_article'/", $result);
if (PHP5) {
$this->assertPattern("/'plugin\.test_task\.test_task_comment'/", $result);
}
$this->assertPattern("/'app\.test_task_tag'/", $result);
$this->assertPattern("/'app\.articles_tag'/", $result);
} | test baking files. The conditionally run tests are known to fail in PHP4
as PHP4 classnames are all lower case, breaking the plugin path inflection.
@return void
@access public | testBakeModelTest | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/test.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/test.test.php | MIT |
function testBakeControllerTest() {
$this->Task->setReturnValue('createFile', true);
$this->Task->setReturnValue('isLoadableClass', true);
$result = $this->Task->bake('Controller', 'TestTaskComments');
$this->assertPattern('/App::import\(\'Controller\', \'TestTaskComments\'\)/', $result);
$this->assertPattern('/class TestTaskCommentsControllerTestCase extends CakeTestCase/', $result);
$this->assertPattern('/class TestTestTaskCommentsController extends TestTaskCommentsController/', $result);
$this->assertPattern('/var \$autoRender = false/', $result);
$this->assertPattern('/function redirect\(\$url, \$status = null, \$exit = true\)/', $result);
$this->assertPattern('/function startTest\(\)/', $result);
$this->assertPattern("/\\\$this->TestTaskComments \=\& new TestTestTaskCommentsController\(\)/", $result);
$this->assertPattern("/\\\$this->TestTaskComments->constructClasses\(\)/", $result);
$this->assertPattern('/function endTest\(\)/', $result);
$this->assertPattern('/unset\(\$this->TestTaskComments\)/', $result);
$this->assertPattern("/'app\.test_task_article'/", $result);
if (PHP5) {
$this->assertPattern("/'plugin\.test_task\.test_task_comment'/", $result);
}
$this->assertPattern("/'app\.test_task_tag'/", $result);
$this->assertPattern("/'app\.articles_tag'/", $result);
} | test baking controller test files, ensure that the stub class is generated.
Conditional assertion is known to fail on PHP4 as classnames are all lower case
causing issues with inflection of path name from classname.
@return void
@access public | testBakeControllerTest | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/test.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/test.test.php | MIT |
function testGenerateConstructor() {
$result = $this->Task->generateConstructor('controller', 'PostsController');
$expected = "new TestPostsController();\n\t\t\$this->Posts->constructClasses();\n";
$this->assertEqual($result, $expected);
$result = $this->Task->generateConstructor('model', 'Post');
$expected = "ClassRegistry::init('Post');\n";
$this->assertEqual($result, $expected);
$result = $this->Task->generateConstructor('helper', 'FormHelper');
$expected = "new FormHelper();\n";
$this->assertEqual($result, $expected);
} | test Constructor generation ensure that constructClasses is called for controllers
@return void
@access public | testGenerateConstructor | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/test.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/test.test.php | MIT |
function testMockClassGeneration() {
$result = $this->Task->hasMockClass('controller');
$this->assertTrue($result);
} | Test that mock class generation works for the appropriate classes
@return void
@access public | testMockClassGeneration | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/test.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/test.test.php | MIT |
function testBakeWithPlugin() {
$this->Task->plugin = 'TestTest';
$path = APP . 'plugins' . DS . 'test_test' . DS . 'tests' . DS . 'cases' . DS . 'helpers' . DS . 'form.test.php';
$this->Task->expectAt(0, 'createFile', array($path, '*'));
$this->Task->bake('Helper', 'Form');
} | test bake() with a -plugin param
@return void
@access public | testBakeWithPlugin | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/test.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/test.test.php | MIT |
function testInteractiveWithPlugin() {
$testApp = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS;
App::build(array(
'plugins' => array($testApp)
), true);
$this->Task->plugin = 'TestPlugin';
$path = $testApp . 'test_plugin' . DS . 'tests' . DS . 'cases' . DS . 'helpers' . DS . 'other_helper.test.php';
$this->Task->setReturnValueAt(0, 'in', 5); //helper
$this->Task->setReturnValueAt(1, 'in', 1); //OtherHelper
$this->Task->expectAt(0, 'createFile', array($path, '*'));
$this->Task->expectAt(9, 'out', array('1. OtherHelper'));
$this->Task->execute();
} | test interactive with plugins lists from the plugin
@return void | testInteractiveWithPlugin | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/test.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/test.test.php | MIT |
function testTestCaseFileName() {
$this->Task->path = '/my/path/tests/';
$result = $this->Task->testCaseFileName('Model', 'Post');
$expected = $this->Task->path . 'cases' . DS . 'models' . DS . 'post.test.php';
$this->assertEqual($result, $expected);
$result = $this->Task->testCaseFileName('Helper', 'Form');
$expected = $this->Task->path . 'cases' . DS . 'helpers' . DS . 'form.test.php';
$this->assertEqual($result, $expected);
$result = $this->Task->testCaseFileName('Controller', 'Posts');
$expected = $this->Task->path . 'cases' . DS . 'controllers' . DS . 'posts_controller.test.php';
$this->assertEqual($result, $expected);
$result = $this->Task->testCaseFileName('Behavior', 'Containable');
$expected = $this->Task->path . 'cases' . DS . 'behaviors' . DS . 'containable.test.php';
$this->assertEqual($result, $expected);
$result = $this->Task->testCaseFileName('Component', 'Auth');
$expected = $this->Task->path . 'cases' . DS . 'components' . DS . 'auth.test.php';
$this->assertEqual($result, $expected);
$this->Task->plugin = 'TestTest';
$result = $this->Task->testCaseFileName('Model', 'Post');
$expected = APP . 'plugins' . DS . 'test_test' . DS . 'tests' . DS . 'cases' . DS . 'models' . DS . 'post.test.php';
$this->assertEqual($result, $expected);
} | Test filename generation for each type + plugins
@return void
@access public | testTestCaseFileName | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/test.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/test.test.php | MIT |
function testExecuteWithOneArg() {
$this->Task->args[0] = 'Model';
$this->Task->setReturnValueAt(0, 'in', 'TestTaskTag');
$this->Task->setReturnValue('isLoadableClass', true);
$this->Task->expectAt(0, 'createFile', array('*', new PatternExpectation('/class TestTaskTagTestCase extends CakeTestCase/')));
$this->Task->execute();
} | test execute with a type defined
@return void
@access public | testExecuteWithOneArg | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/test.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/test.test.php | MIT |
function testExecuteWithTwoArgs() {
$this->Task->args = array('Model', 'TestTaskTag');
$this->Task->setReturnValueAt(0, 'in', 'TestTaskTag');
$this->Task->setReturnValue('isLoadableClass', true);
$this->Task->expectAt(0, 'createFile', array('*', new PatternExpectation('/class TestTaskTagTestCase extends CakeTestCase/')));
$this->Task->execute();
} | test execute with type and class name defined
@return void
@access public | testExecuteWithTwoArgs | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/test.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/test.test.php | MIT |
function startTest() {
$this->Dispatcher =& new TestViewTaskMockShellDispatcher();
$this->Dispatcher->shellPaths = App::path('shells');
$this->Task =& new MockViewTask($this->Dispatcher);
$this->Task->name = 'ViewTask';
$this->Task->Dispatch =& $this->Dispatcher;
$this->Task->Template =& new TemplateTask($this->Dispatcher);
$this->Task->Controller =& new ViewTaskMockControllerTask();
$this->Task->Project =& new ViewTaskMockProjectTask();
$this->Task->DbConfig =& new ViewTaskMockProjectTask();
$this->Task->path = TMP;
$this->Task->Template->params['theme'] = 'default';
$this->_routing = Configure::read('Routing');
} | startTest method
Ensure that the default theme is used
@return void
@access public | startTest | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/view.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/view.test.php | MIT |
function endTest() {
ClassRegistry::flush();
Configure::write('Routing', $this->_routing);
} | endTest method
@return void
@access public | endTest | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/view.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/view.test.php | MIT |
function testGetContent() {
$vars = array(
'modelClass' => 'TestViewModel',
'schema' => array(),
'primaryKey' => 'id',
'displayField' => 'name',
'singularVar' => 'testViewModel',
'pluralVar' => 'testViewModels',
'singularHumanName' => 'Test View Model',
'pluralHumanName' => 'Test View Models',
'fields' => array('id', 'name', 'body'),
'associations' => array()
);
$result = $this->Task->getContent('view', $vars);
$this->assertPattern('/Delete Test View Model/', $result);
$this->assertPattern('/Edit Test View Model/', $result);
$this->assertPattern('/List Test View Models/', $result);
$this->assertPattern('/New Test View Model/', $result);
$this->assertPattern('/testViewModel\[\'TestViewModel\'\]\[\'id\'\]/', $result);
$this->assertPattern('/testViewModel\[\'TestViewModel\'\]\[\'name\'\]/', $result);
$this->assertPattern('/testViewModel\[\'TestViewModel\'\]\[\'body\'\]/', $result);
} | Test getContent and parsing of Templates.
@return void
@access public | testGetContent | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/view.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/view.test.php | MIT |
function testGetContentWithAdminAction() {
$_back = Configure::read('Routing');
Configure::write('Routing.prefixes', array('admin'));
$vars = array(
'modelClass' => 'TestViewModel',
'schema' => array(),
'primaryKey' => 'id',
'displayField' => 'name',
'singularVar' => 'testViewModel',
'pluralVar' => 'testViewModels',
'singularHumanName' => 'Test View Model',
'pluralHumanName' => 'Test View Models',
'fields' => array('id', 'name', 'body'),
'associations' => array()
);
$result = $this->Task->getContent('admin_view', $vars);
$this->assertPattern('/Delete Test View Model/', $result);
$this->assertPattern('/Edit Test View Model/', $result);
$this->assertPattern('/List Test View Models/', $result);
$this->assertPattern('/New Test View Model/', $result);
$this->assertPattern('/testViewModel\[\'TestViewModel\'\]\[\'id\'\]/', $result);
$this->assertPattern('/testViewModel\[\'TestViewModel\'\]\[\'name\'\]/', $result);
$this->assertPattern('/testViewModel\[\'TestViewModel\'\]\[\'body\'\]/', $result);
$result = $this->Task->getContent('admin_add', $vars);
$this->assertPattern("/input\('name'\)/", $result);
$this->assertPattern("/input\('body'\)/", $result);
$this->assertPattern('/List Test View Models/', $result);
Configure::write('Routing', $_back);
} | test getContent() using an admin_prefixed action.
@return void
@access public | testGetContentWithAdminAction | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/view.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/view.test.php | MIT |
function testBake() {
$this->Task->controllerName = 'ViewTaskComments';
$this->Task->controllerPath = 'view_task_comments';
$this->Task->expectAt(0, 'createFile', array(
TMP . 'view_task_comments' . DS . 'view.ctp',
new PatternExpectation('/View Task Articles/')
));
$this->Task->bake('view', true);
$this->Task->expectAt(1, 'createFile', array(TMP . 'view_task_comments' . DS . 'edit.ctp', '*'));
$this->Task->bake('edit', true);
$this->Task->expectAt(2, 'createFile', array(
TMP . 'view_task_comments' . DS . 'index.ctp',
new PatternExpectation('/\$viewTaskComment\[\'Article\'\]\[\'title\'\]/')
));
$this->Task->bake('index', true);
} | test Bake method
@return void
@access public | testBake | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/view.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/view.test.php | MIT |
function testBakeWithNoTemplate() {
$this->Task->controllerName = 'ViewTaskComments';
$this->Task->controllerPath = 'view_task_comments';
$this->Task->expectNever('createFile');
$this->Task->bake('delete', true);
} | test that baking a view with no template doesn't make a file.
@return void | testBakeWithNoTemplate | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/view.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/view.test.php | MIT |
function testBakeWithPlugin() {
$this->Task->controllerName = 'ViewTaskComments';
$this->Task->controllerPath = 'view_task_comments';
$this->Task->plugin = 'TestTest';
$path = APP . 'plugins' . DS . 'test_test' . DS . 'views' . DS . 'view_task_comments' . DS . 'view.ctp';
$this->Task->expectAt(0, 'createFile', array($path, '*'));
$this->Task->bake('view', true);
} | test bake() with a -plugin param
@return void
@access public | testBakeWithPlugin | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/view.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/view.test.php | MIT |
function testBakeActions() {
$this->Task->controllerName = 'ViewTaskComments';
$this->Task->controllerPath = 'view_task_comments';
$this->Task->expectAt(0, 'createFile', array(
TMP . 'view_task_comments' . DS . 'view.ctp',
new PatternExpectation('/View Task Comments/')
));
$this->Task->expectAt(1, 'createFile', array(
TMP . 'view_task_comments' . DS . 'edit.ctp',
new PatternExpectation('/Edit View Task Comment/')
));
$this->Task->expectAt(2, 'createFile', array(
TMP . 'view_task_comments' . DS . 'index.ctp',
new PatternExpectation('/ViewTaskComment/')
));
$this->Task->bakeActions(array('view', 'edit', 'index'), array());
} | test bake actions baking multiple actions.
@return void
@access public | testBakeActions | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/view.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/view.test.php | MIT |
function testCustomAction() {
$this->Task->controllerName = 'ViewTaskComments';
$this->Task->controllerPath = 'view_task_comments';
$this->Task->params['app'] = APP;
$this->Task->setReturnValueAt(0, 'in', '');
$this->Task->setReturnValueAt(1, 'in', 'my_action');
$this->Task->setReturnValueAt(2, 'in', 'y');
$this->Task->expectAt(0, 'createFile', array(TMP . 'view_task_comments' . DS . 'my_action.ctp', '*'));
$this->Task->customAction();
} | test baking a customAction (non crud)
@return void
@access public | testCustomAction | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/view.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/view.test.php | MIT |
function testExecuteIntoAll() {
$this->Task->args[0] = 'all';
$this->Task->Controller->setReturnValue('listAll', array('view_task_comments'));
$this->Task->Controller->expectOnce('listAll');
$this->Task->expectCallCount('createFile', 2);
$this->Task->expectAt(0, 'createFile', array(TMP . 'view_task_comments' . DS . 'index.ctp', '*'));
$this->Task->expectAt(1, 'createFile', array(TMP . 'view_task_comments' . DS . 'add.ctp', '*'));
$this->Task->execute();
} | Test all()
@return void
@access public | testExecuteIntoAll | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/view.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/view.test.php | MIT |
function testExecuteIntoAllWithActionName() {
$this->Task->args = array('all', 'index');
$this->Task->Controller->setReturnValue('listAll', array('view_task_comments'));
$this->Task->Controller->expectOnce('listAll');
$this->Task->expectCallCount('createFile', 1);
$this->Task->expectAt(0, 'createFile', array(TMP . 'view_task_comments' . DS . 'index.ctp', '*'));
$this->Task->execute();
} | Test all() with action parameter
@return void
@access public | testExecuteIntoAllWithActionName | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/view.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/view.test.php | MIT |
function testExecuteWithActionParam() {
$this->Task->args[0] = 'ViewTaskComments';
$this->Task->args[1] = 'view';
$this->Task->expectCallCount('createFile', 1);
$this->Task->expectAt(0, 'createFile', array(TMP . 'view_task_comments' . DS . 'view.ctp', '*'));
$this->Task->execute();
} | test `cake bake view $controller view`
@return void
@access public | testExecuteWithActionParam | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/view.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/view.test.php | MIT |
function testExecuteWithController() {
$this->Task->args[0] = 'ViewTaskComments';
$this->Task->expectCallCount('createFile', 2);
$this->Task->expectAt(0, 'createFile', array(TMP . 'view_task_comments' . DS . 'index.ctp', '*'));
$this->Task->expectAt(1, 'createFile', array(TMP . 'view_task_comments' . DS . 'add.ctp', '*'));
$this->Task->execute();
} | test `cake bake view $controller`
Ensure that views are only baked for actions that exist in the controller.
@return void
@access public | testExecuteWithController | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/view.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/view.test.php | MIT |
function testExecuteWithControllerVariations() {
$this->Task->args = array('ViewTaskComments');
$this->Task->expectAt(0, 'createFile', array(TMP . 'view_task_comments' . DS . 'index.ctp', '*'));
$this->Task->expectAt(1, 'createFile', array(TMP . 'view_task_comments' . DS . 'add.ctp', '*'));
$this->Task->execute();
$this->Task->args = array('ViewTaskComment');
$this->Task->expectAt(0, 'createFile', array(TMP . 'view_task_comments' . DS . 'index.ctp', '*'));
$this->Task->expectAt(1, 'createFile', array(TMP . 'view_task_comments' . DS . 'add.ctp', '*'));
$this->Task->execute();
} | test that both plural and singular forms can be used for baking views.
@return void
@access public | testExecuteWithControllerVariations | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/view.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/view.test.php | MIT |
function testExecuteWithControllerAndAdminFlag() {
$_back = Configure::read('Routing');
Configure::write('Routing.prefixes', array('admin'));
$this->Task->args[0] = 'ViewTaskArticles';
$this->Task->params['admin'] = 1;
$this->Task->Project->setReturnValue('getPrefix', 'admin_');
$this->Task->expectCallCount('createFile', 4);
$this->Task->expectAt(0, 'createFile', array(TMP . 'view_task_articles' . DS . 'admin_index.ctp', '*'));
$this->Task->expectAt(1, 'createFile', array(TMP . 'view_task_articles' . DS . 'admin_add.ctp', '*'));
$this->Task->expectAt(2, 'createFile', array(TMP . 'view_task_articles' . DS . 'admin_view.ctp', '*'));
$this->Task->expectAt(3, 'createFile', array(TMP . 'view_task_articles' . DS . 'admin_edit.ctp', '*'));
$this->Task->execute();
Configure::write('Routing', $_back);
} | test `cake bake view $controller -admin`
Which only bakes admin methods, not non-admin methods.
@return void
@access public | testExecuteWithControllerAndAdminFlag | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/view.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/view.test.php | MIT |
function testExecuteInteractive() {
$this->Task->connection = 'test_suite';
$this->Task->args = array();
$this->Task->params = array();
$this->Task->Controller->setReturnValue('getName', 'ViewTaskComments');
$this->Task->setReturnValue('in', 'y');
$this->Task->setReturnValueAt(0, 'in', 'y');
$this->Task->setReturnValueAt(1, 'in', 'y');
$this->Task->setReturnValueAt(2, 'in', 'n');
$this->Task->expectCallCount('createFile', 4);
$this->Task->expectAt(0, 'createFile', array(
TMP . 'view_task_comments' . DS . 'index.ctp',
new PatternExpectation('/ViewTaskComment/')
));
$this->Task->expectAt(1, 'createFile', array(
TMP . 'view_task_comments' . DS . 'view.ctp',
new PatternExpectation('/ViewTaskComment/')
));
$this->Task->expectAt(2, 'createFile', array(
TMP . 'view_task_comments' . DS . 'add.ctp',
new PatternExpectation('/Add View Task Comment/')
));
$this->Task->expectAt(3, 'createFile', array(
TMP . 'view_task_comments' . DS . 'edit.ctp',
new PatternExpectation('/Edit View Task Comment/')
));
$this->Task->execute();
} | test execute into interactive.
@return void
@access public | testExecuteInteractive | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/view.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/view.test.php | MIT |
function testExecuteWithAlternateTemplates() {
$this->Task->connection = 'test_suite';
$this->Task->args = array('ViewTaskComments', 'index', 'list');
$this->Task->params = array();
$this->Task->expectCallCount('createFile', 1);
$this->Task->expectAt(0, 'createFile', array(
TMP . 'view_task_comments' . DS . 'list.ctp',
new PatternExpectation('/ViewTaskComment/')
));
$this->Task->execute();
} | test `cake bake view posts index list`
@return void
@access public | testExecuteWithAlternateTemplates | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/view.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/view.test.php | MIT |
function testExecuteInteractiveWithAdmin() {
Configure::write('Routing.prefixes', array('admin'));
$this->Task->connection = 'test_suite';
$this->Task->args = array();
$this->Task->Controller->setReturnValue('getName', 'ViewTaskComments');
$this->Task->Project->setReturnValue('getPrefix', 'admin_');
$this->Task->setReturnValueAt(0, 'in', 'y');
$this->Task->setReturnValueAt(1, 'in', 'n');
$this->Task->setReturnValueAt(2, 'in', 'y');
$this->Task->expectCallCount('createFile', 4);
$this->Task->expectAt(0, 'createFile', array(
TMP . 'view_task_comments' . DS . 'admin_index.ctp',
new PatternExpectation('/ViewTaskComment/')
));
$this->Task->expectAt(1, 'createFile', array(
TMP . 'view_task_comments' . DS . 'admin_view.ctp',
new PatternExpectation('/ViewTaskComment/')
));
$this->Task->expectAt(2, 'createFile', array(
TMP . 'view_task_comments' . DS . 'admin_add.ctp',
new PatternExpectation('/Add View Task Comment/')
));
$this->Task->expectAt(3, 'createFile', array(
TMP . 'view_task_comments' . DS . 'admin_edit.ctp',
new PatternExpectation('/Edit View Task Comment/')
));
$this->Task->execute();
} | test execute into interactive() with admin methods.
@return void
@access public | testExecuteInteractiveWithAdmin | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/view.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/view.test.php | MIT |
function testGetTemplate() {
$result = $this->Task->getTemplate('delete');
$this->assertFalse($result);
$result = $this->Task->getTemplate('add');
$this->assertEqual($result, 'form');
Configure::write('Routing.prefixes', array('admin'));
$result = $this->Task->getTemplate('admin_add');
$this->assertEqual($result, 'form');
} | test getting templates, make sure noTemplateActions works
@return void | testGetTemplate | php | Datawalke/Coordino | cake/tests/cases/console/libs/tasks/view.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/console/libs/tasks/view.test.php | MIT |
function setUp() {
$this->_cacheDisable = Configure::read('Cache.disable');
Configure::write('Cache.disable', false);
$this->_defaultCacheConfig = Cache::config('default');
Cache::config('default', array('engine' => 'File', 'path' => TMP . 'tests'));
} | setUp method
@access public
@return void | setUp | php | Datawalke/Coordino | cake/tests/cases/libs/cache.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache.test.php | MIT |
function tearDown() {
Configure::write('Cache.disable', $this->_cacheDisable);
Cache::config('default', $this->_defaultCacheConfig['settings']);
} | tearDown method
@access public
@return void | tearDown | php | Datawalke/Coordino | cake/tests/cases/libs/cache.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache.test.php | MIT |
function testConfig() {
$settings = array('engine' => 'File', 'path' => TMP . 'tests', 'prefix' => 'cake_test_');
$results = Cache::config('new', $settings);
$this->assertEqual($results, Cache::config('new'));
$this->assertTrue(isset($results['engine']));
$this->assertTrue(isset($results['settings']));
} | testConfig method
@access public
@return void | testConfig | php | Datawalke/Coordino | cake/tests/cases/libs/cache.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache.test.php | MIT |
function testNonFatalErrorsWithCachedisable() {
Configure::write('Cache.disable', true);
Cache::config('test', array('engine' => 'File', 'path' => TMP, 'prefix' => 'error_test_'));
Cache::write('no_save', 'Noooo!', 'test');
Cache::read('no_save', 'test');
Cache::delete('no_save', 'test');
Cache::set('duration', '+10 minutes');
Configure::write('Cache.disable', false);
} | Check that no fatal errors are issued doing normal things when Cache.disable is true.
@return void | testNonFatalErrorsWithCachedisable | php | Datawalke/Coordino | cake/tests/cases/libs/cache.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache.test.php | MIT |
function testConfigWithLibAndPluginEngines() {
App::build(array(
'libs' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'libs' . DS),
'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
), true);
$settings = array('engine' => 'TestAppCache', 'path' => TMP, 'prefix' => 'cake_test_');
$result = Cache::config('libEngine', $settings);
$this->assertEqual($result, Cache::config('libEngine'));
$settings = array('engine' => 'TestPlugin.TestPluginCache', 'path' => TMP, 'prefix' => 'cake_test_');
$result = Cache::config('pluginLibEngine', $settings);
$this->assertEqual($result, Cache::config('pluginLibEngine'));
Cache::drop('libEngine');
Cache::drop('pluginLibEngine');
App::build();
} | test configuring CacheEngines in App/libs
@return void | testConfigWithLibAndPluginEngines | php | Datawalke/Coordino | cake/tests/cases/libs/cache.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache.test.php | MIT |
function testInvaidConfig() {
$this->expectError();
Cache::config('invalid', array(
'engine' => 'File',
'duration' => '+1 year',
'prefix' => 'testing_invalid_',
'path' => 'data/',
'serialize' => true,
'random' => 'wii'
));
$read = Cache::read('Test', 'invalid');
$this->assertEqual($read, null);
} | testInvalidConfig method
Test that the cache class doesn't cause fatal errors with a partial path
@access public
@return void | testInvaidConfig | php | Datawalke/Coordino | cake/tests/cases/libs/cache.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache.test.php | MIT |
function testConfigChange() {
$_cacheConfigSessions = Cache::config('sessions');
$_cacheConfigTests = Cache::config('tests');
$result = Cache::config('sessions', array('engine'=> 'File', 'path' => TMP . 'sessions'));
$this->assertEqual($result['settings'], Cache::settings('sessions'));
$result = Cache::config('tests', array('engine'=> 'File', 'path' => TMP . 'tests'));
$this->assertEqual($result['settings'], Cache::settings('tests'));
Cache::config('sessions', $_cacheConfigSessions['settings']);
Cache::config('tests', $_cacheConfigTests['settings']);
} | testConfigChange method
@access public
@return void | testConfigChange | php | Datawalke/Coordino | cake/tests/cases/libs/cache.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache.test.php | MIT |
function testConfigSettingDefaultConfigKey() {
Cache::config('test_name', array('engine' => 'File', 'prefix' => 'test_name_'));
Cache::config('test_name');
Cache::write('value_one', 'I am cached');
$result = Cache::read('value_one');
$this->assertEqual($result, 'I am cached');
Cache::config('default');
$result = Cache::read('value_one');
$this->assertEqual($result, null);
Cache::write('value_one', 'I am in default config!');
$result = Cache::read('value_one');
$this->assertEqual($result, 'I am in default config!');
Cache::config('test_name');
$result = Cache::read('value_one');
$this->assertEqual($result, 'I am cached');
Cache::delete('value_one');
Cache::config('default');
Cache::delete('value_one');
} | test that calling config() sets the 'default' configuration up.
@return void | testConfigSettingDefaultConfigKey | php | Datawalke/Coordino | cake/tests/cases/libs/cache.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache.test.php | MIT |
function testWritingWithConfig() {
$_cacheConfigSessions = Cache::config('sessions');
Cache::write('test_somthing', 'this is the test data', 'tests');
$expected = array(
'path' => TMP . 'sessions',
'prefix' => 'cake_',
'lock' => false,
'serialize' => true,
'duration' => 3600,
'probability' => 100,
'engine' => 'File',
'isWindows' => DIRECTORY_SEPARATOR == '\\'
);
$this->assertEqual($expected, Cache::settings('sessions'));
Cache::config('sessions', $_cacheConfigSessions['settings']);
} | testWritingWithConfig method
@access public
@return void | testWritingWithConfig | php | Datawalke/Coordino | cake/tests/cases/libs/cache.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache.test.php | MIT |
function testConfigured() {
$result = Cache::configured();
$this->assertTrue(in_array('_cake_core_', $result));
$this->assertTrue(in_array('default', $result));
} | test that configured returns an array of the currently configured cache
settings
@return void | testConfigured | php | Datawalke/Coordino | cake/tests/cases/libs/cache.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache.test.php | MIT |
function testInitSettings() {
Cache::config('for_test', array('engine' => 'File', 'path' => TMP . 'tests'));
$settings = Cache::settings();
$expecting = array(
'engine' => 'File',
'duration'=> 3600,
'probability' => 100,
'path'=> TMP . 'tests',
'prefix'=> 'cake_',
'lock' => false,
'serialize'=> true,
'isWindows' => DIRECTORY_SEPARATOR == '\\'
);
$this->assertEqual($settings, $expecting);
} | testInitSettings method
@access public
@return void | testInitSettings | php | Datawalke/Coordino | cake/tests/cases/libs/cache.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache.test.php | MIT |
function testDrop() {
App::build(array(
'libs' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'libs' . DS),
'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
), true);
$result = Cache::drop('some_config_that_does_not_exist');
$this->assertFalse($result);
$_testsConfig = Cache::config('tests');
$result = Cache::drop('tests');
$this->assertTrue($result);
Cache::config('unconfigTest', array(
'engine' => 'TestAppCache'
));
$this->assertTrue(Cache::isInitialized('unconfigTest'));
$this->assertTrue(Cache::drop('unconfigTest'));
$this->assertFalse(Cache::isInitialized('TestAppCache'));
Cache::config('tests', $_testsConfig);
App::build();
} | test that drop removes cache configs, and that further attempts to use that config
do not work.
@return void | testDrop | php | Datawalke/Coordino | cake/tests/cases/libs/cache.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache.test.php | MIT |
function testWriteEmptyValues() {
Cache::write('App.falseTest', false);
$this->assertIdentical(Cache::read('App.falseTest'), false);
Cache::write('App.trueTest', true);
$this->assertIdentical(Cache::read('App.trueTest'), true);
Cache::write('App.nullTest', null);
$this->assertIdentical(Cache::read('App.nullTest'), null);
Cache::write('App.zeroTest', 0);
$this->assertIdentical(Cache::read('App.zeroTest'), 0);
Cache::write('App.zeroTest2', '0');
$this->assertIdentical(Cache::read('App.zeroTest2'), '0');
} | testWriteEmptyValues method
@access public
@return void | testWriteEmptyValues | php | Datawalke/Coordino | cake/tests/cases/libs/cache.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache.test.php | MIT |
function testCacheDisable() {
Configure::write('Cache.disable', false);
Cache::config('test_cache_disable_1', array('engine'=> 'File', 'path' => TMP . 'tests'));
$this->assertTrue(Cache::write('key_1', 'hello'));
$this->assertIdentical(Cache::read('key_1'), 'hello');
Configure::write('Cache.disable', true);
$this->assertFalse(Cache::write('key_2', 'hello'));
$this->assertFalse(Cache::read('key_2'));
Configure::write('Cache.disable', false);
$this->assertTrue(Cache::write('key_3', 'hello'));
$this->assertIdentical(Cache::read('key_3'), 'hello');
Configure::write('Cache.disable', true);
Cache::config('test_cache_disable_2', array('engine'=> 'File', 'path' => TMP . 'tests'));
$this->assertFalse(Cache::write('key_4', 'hello'));
$this->assertFalse(Cache::read('key_4'));
Configure::write('Cache.disable', false);
$this->assertTrue(Cache::write('key_5', 'hello'));
$this->assertIdentical(Cache::read('key_5'), 'hello');
Configure::write('Cache.disable', true);
$this->assertFalse(Cache::write('key_6', 'hello'));
$this->assertFalse(Cache::read('key_6'));
} | testCacheDisable method
Check that the "Cache.disable" configuration and a change to it
(even after a cache config has been setup) is taken into account.
@link https://trac.cakephp.org/ticket/6236
@access public
@return void | testCacheDisable | php | Datawalke/Coordino | cake/tests/cases/libs/cache.test.php | https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/cache.test.php | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.