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 _execute($sql) { $this->simulated[] = $sql; return null; }
execute method @param mixed $sql @access protected @return void
_execute
php
Datawalke/Coordino
cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
MIT
function getLastQuery() { return $this->simulated[count($this->simulated) - 1]; }
getLastQuery method @access public @return void
getLastQuery
php
Datawalke/Coordino
cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
MIT
function find($conditions = null, $fields = null, $order = null, $recursive = null) { return $conditions; }
find method @param mixed $conditions @param mixed $fields @param mixed $order @param mixed $recursive @access public @return void
find
php
Datawalke/Coordino
cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
MIT
function findAll($conditions = null, $fields = null, $order = null, $recursive = null) { return $conditions; }
findAll method @param mixed $conditions @param mixed $fields @param mixed $order @param mixed $recursive @access public @return void
findAll
php
Datawalke/Coordino
cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
MIT
function schema() { return array( 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), 'client_id' => array('type' => 'integer', 'null' => '', 'default' => '0', 'length' => '11'), 'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), 'login' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), 'passwd' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'), 'addr_1' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'), 'addr_2' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '25'), 'zip_code' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), 'city' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), 'country' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), 'phone' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), 'fax' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), 'url' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'), 'email' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), 'comments' => array('type' => 'text', 'null' => '1', 'default' => '', 'length' => ''), 'last_login'=> array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => ''), 'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''), 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null) ); }
schema method @access public @return void
schema
php
Datawalke/Coordino
cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
MIT
function schema() { return array( 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8', 'key' => 'primary'), 'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), 'email' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), 'created' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => ''), 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null) ); }
schema method @access public @return void
schema
php
Datawalke/Coordino
cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
MIT
function skip() { $this->_initDb(); $this->skipUnless($this->db->config['driver'] == 'postgres', '%s PostgreSQL connection not available'); }
Skip if cannot connect to postgres @access public
skip
php
Datawalke/Coordino
cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
MIT
function setUp() { Configure::write('Cache.disable', true); $this->startTest(); $this->db =& ConnectionManager::getDataSource('test_suite'); $this->db2 = new DboPostgresTestDb($this->db->config, false); $this->model = new PostgresTestModel(); }
Sets up a Dbo class instance for testing @access public
setUp
php
Datawalke/Coordino
cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
MIT
function tearDown() { Configure::write('Cache.disable', false); unset($this->db2); }
Sets up a Dbo class instance for testing @access public
tearDown
php
Datawalke/Coordino
cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
MIT
function testFieldQuoting() { $fields = array( '"PostgresTestModel"."id" AS "PostgresTestModel__id"', '"PostgresTestModel"."client_id" AS "PostgresTestModel__client_id"', '"PostgresTestModel"."name" AS "PostgresTestModel__name"', '"PostgresTestModel"."login" AS "PostgresTestModel__login"', '"PostgresTestModel"."passwd" AS "PostgresTestModel__passwd"', '"PostgresTestModel"."addr_1" AS "PostgresTestModel__addr_1"', '"PostgresTestModel"."addr_2" AS "PostgresTestModel__addr_2"', '"PostgresTestModel"."zip_code" AS "PostgresTestModel__zip_code"', '"PostgresTestModel"."city" AS "PostgresTestModel__city"', '"PostgresTestModel"."country" AS "PostgresTestModel__country"', '"PostgresTestModel"."phone" AS "PostgresTestModel__phone"', '"PostgresTestModel"."fax" AS "PostgresTestModel__fax"', '"PostgresTestModel"."url" AS "PostgresTestModel__url"', '"PostgresTestModel"."email" AS "PostgresTestModel__email"', '"PostgresTestModel"."comments" AS "PostgresTestModel__comments"', '"PostgresTestModel"."last_login" AS "PostgresTestModel__last_login"', '"PostgresTestModel"."created" AS "PostgresTestModel__created"', '"PostgresTestModel"."updated" AS "PostgresTestModel__updated"' ); $result = $this->db->fields($this->model); $expected = $fields; $this->assertEqual($result, $expected); $result = $this->db->fields($this->model, null, 'PostgresTestModel.*'); $expected = $fields; $this->assertEqual($result, $expected); $result = $this->db->fields($this->model, null, array('*', 'AnotherModel.id', 'AnotherModel.name')); $expected = array_merge($fields, array( '"AnotherModel"."id" AS "AnotherModel__id"', '"AnotherModel"."name" AS "AnotherModel__name"')); $this->assertEqual($result, $expected); $result = $this->db->fields($this->model, null, array('*', 'PostgresClientTestModel.*')); $expected = array_merge($fields, array( '"PostgresClientTestModel"."id" AS "PostgresClientTestModel__id"', '"PostgresClientTestModel"."name" AS "PostgresClientTestModel__name"', '"PostgresClientTestModel"."email" AS "PostgresClientTestModel__email"', '"PostgresClientTestModel"."created" AS "PostgresClientTestModel__created"', '"PostgresClientTestModel"."updated" AS "PostgresClientTestModel__updated"')); $this->assertEqual($result, $expected); }
Test field quoting method @access public
testFieldQuoting
php
Datawalke/Coordino
cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
MIT
function testColumnParsing() { $this->assertEqual($this->db2->column('text'), 'text'); $this->assertEqual($this->db2->column('date'), 'date'); $this->assertEqual($this->db2->column('boolean'), 'boolean'); $this->assertEqual($this->db2->column('character varying'), 'string'); $this->assertEqual($this->db2->column('time without time zone'), 'time'); $this->assertEqual($this->db2->column('timestamp without time zone'), 'datetime'); }
testColumnParsing method @access public @return void
testColumnParsing
php
Datawalke/Coordino
cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
MIT
function testValueQuoting() { $this->assertIdentical($this->db2->value(1.2, 'float'), "'1.200000'"); $this->assertEqual($this->db2->value('1,2', 'float'), "'1,2'"); $this->assertEqual($this->db2->value('0', 'integer'), "'0'"); $this->assertEqual($this->db2->value('', 'integer'), 'NULL'); $this->assertEqual($this->db2->value('', 'float'), 'NULL'); $this->assertEqual($this->db2->value('', 'integer', false), "DEFAULT"); $this->assertEqual($this->db2->value('', 'float', false), "DEFAULT"); $this->assertEqual($this->db2->value('0.0', 'float'), "'0.0'"); $this->assertEqual($this->db2->value('t', 'boolean'), "TRUE"); $this->assertEqual($this->db2->value('f', 'boolean'), "FALSE"); $this->assertEqual($this->db2->value(true), "TRUE"); $this->assertEqual($this->db2->value(false), "FALSE"); $this->assertEqual($this->db2->value('t'), "'t'"); $this->assertEqual($this->db2->value('f'), "'f'"); $this->assertEqual($this->db2->value('true', 'boolean'), 'TRUE'); $this->assertEqual($this->db2->value('false', 'boolean'), 'FALSE'); $this->assertEqual($this->db2->value('', 'boolean'), 'FALSE'); $this->assertEqual($this->db2->value(0, 'boolean'), 'FALSE'); $this->assertEqual($this->db2->value(1, 'boolean'), 'TRUE'); $this->assertEqual($this->db2->value('1', 'boolean'), 'TRUE'); $this->assertEqual($this->db2->value(null, 'boolean'), "NULL"); $this->assertEqual($this->db2->value(array()), "NULL"); }
testValueQuoting method @access public @return void
testValueQuoting
php
Datawalke/Coordino
cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
MIT
function testLocalizedFloats() { $restore = setlocale(LC_ALL, null); setlocale(LC_ALL, 'de_DE'); $result = $this->db->value(3.141593, 'float'); $this->assertEqual((string)$result, "'3.141593'"); $result = $this->db->value(3.14); $this->assertEqual((string)$result, "'3.140000'"); setlocale(LC_ALL, $restore); }
test that localized floats don't cause trouble. @return void
testLocalizedFloats
php
Datawalke/Coordino
cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
MIT
function testDateAndTimeAsNull() { $this->assertEqual($this->db2->value(null, 'date'), 'NULL'); $this->assertEqual($this->db2->value('', 'date'), 'NULL'); $this->assertEqual($this->db2->value('', 'datetime'), 'NULL'); $this->assertEqual($this->db2->value(null, 'datetime'), 'NULL'); $this->assertEqual($this->db2->value('', 'timestamp'), 'NULL'); $this->assertEqual($this->db2->value(null, 'timestamp'), 'NULL'); $this->assertEqual($this->db2->value('', 'time'), 'NULL'); $this->assertEqual($this->db2->value(null, 'time'), 'NULL'); }
test that date and time columns do not generate errors with null and nullish values. @return void
testDateAndTimeAsNull
php
Datawalke/Coordino
cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
MIT
function testBooleanNormalization() { $this->assertTrue($this->db2->boolean('t')); $this->assertTrue($this->db2->boolean('true')); $this->assertTrue($this->db2->boolean('TRUE')); $this->assertTrue($this->db2->boolean(true)); $this->assertTrue($this->db2->boolean(1)); $this->assertTrue($this->db2->boolean(" ")); $this->assertFalse($this->db2->boolean('f')); $this->assertFalse($this->db2->boolean('false')); $this->assertFalse($this->db2->boolean('FALSE')); $this->assertFalse($this->db2->boolean(false)); $this->assertFalse($this->db2->boolean(0)); $this->assertFalse($this->db2->boolean('')); }
Tests that different Postgres boolean 'flavors' are properly returned as native PHP booleans @access public @return void
testBooleanNormalization
php
Datawalke/Coordino
cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
MIT
function testBooleanDefaultFalseInSchema() { $model = new Model(array('name' => 'Datatype', 'table' => 'datatypes', 'ds' => 'test_suite')); $model->create(); $this->assertIdentical(false, $model->data['Datatype']['bool']); }
test that default -> false in schemas works correctly. @return void
testBooleanDefaultFalseInSchema
php
Datawalke/Coordino
cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
MIT
function testLastInsertIdMultipleInsert() { $db1 = ConnectionManager::getDataSource('test_suite'); $table = $db1->fullTableName('users', false); $password = '5f4dcc3b5aa765d61d8327deb882cf99'; $db1->execute( "INSERT INTO {$table} (\"user\", password) VALUES ('mariano', '{$password}')" ); $this->assertEqual($db1->lastInsertId($table), 1); $db1->execute("INSERT INTO {$table} (\"user\", password) VALUES ('hoge', '{$password}')"); $this->assertEqual($db1->lastInsertId($table), 2); }
testLastInsertIdMultipleInsert method @access public @return void
testLastInsertIdMultipleInsert
php
Datawalke/Coordino
cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
MIT
function testSchemaScoping() { $db1 =& ConnectionManager::getDataSource('test_suite'); $db1->cacheSources = false; $db1->reconnect(array('persistent' => false)); $db1->query('CREATE SCHEMA _scope_test'); $db2 =& ConnectionManager::create( 'test_suite_2', array_merge($db1->config, array('driver' => 'postgres', 'schema' => '_scope_test')) ); $db2->cacheSources = false; $db2->query('DROP SCHEMA _scope_test'); }
Tests that table lists and descriptions are scoped to the proper Postgres schema @access public @return void
testSchemaScoping
php
Datawalke/Coordino
cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
MIT
function testColumnUseLength() { $result = array('name' => 'foo', 'type' => 'string', 'length' => 100, 'default' => 'FOO'); $expected = '"foo" varchar(100) DEFAULT \'FOO\''; $this->assertEqual($this->db->buildColumn($result), $expected); $result = array('name' => 'foo', 'type' => 'text', 'length' => 100, 'default' => 'FOO'); $expected = '"foo" text DEFAULT \'FOO\''; $this->assertEqual($this->db->buildColumn($result), $expected); }
Tests that column types without default lengths in $columns do not have length values applied when generating schemas. @access public @return void
testColumnUseLength
php
Datawalke/Coordino
cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
MIT
function testSchemaIndexSyntax() { $schema = new CakeSchema(); $schema->tables = array('i18n' => array( 'id' => array( 'type' => 'integer', 'null' => false, 'default' => null, 'length' => 10, 'key' => 'primary' ), 'locale' => array('type'=>'string', 'null' => false, 'length' => 6, 'key' => 'index'), 'model' => array('type'=>'string', 'null' => false, 'key' => 'index'), 'foreign_key' => array( 'type'=>'integer', 'null' => false, 'length' => 10, 'key' => 'index' ), 'field' => array('type'=>'string', 'null' => false, 'key' => 'index'), 'content' => array('type'=>'text', 'null' => true, 'default' => null), 'indexes' => array( 'PRIMARY' => array('column' => 'id', 'unique' => 1), 'locale' => array('column' => 'locale', 'unique' => 0), 'model' => array('column' => 'model', 'unique' => 0), 'row_id' => array('column' => 'foreign_key', 'unique' => 0), 'field' => array('column' => 'field', 'unique' => 0) ) )); $result = $this->db->createSchema($schema); $this->assertNoPattern('/^CREATE INDEX(.+);,$/', $result); }
Tests the syntax of generated schema indexes @access public @return void
testSchemaIndexSyntax
php
Datawalke/Coordino
cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
MIT
function testCakeSchema() { $db1 =& ConnectionManager::getDataSource('test_suite'); $db1->cacheSources = false; $db1->reconnect(array('persistent' => false)); $db1->query('CREATE TABLE ' . $db1->fullTableName('datatype_tests') . ' ( id serial NOT NULL, "varchar" character varying(40) NOT NULL, "full_length" character varying NOT NULL, "timestamp" timestamp without time zone, date date, CONSTRAINT test_suite_data_types_pkey PRIMARY KEY (id) )'); $model = new Model(array('name' => 'DatatypeTest', 'ds' => 'test_suite')); $schema = new CakeSchema(array('connection' => 'test_suite')); $result = $schema->read(array( 'connection' => 'test_suite', )); $schema->tables = array('datatype_tests' => $result['tables']['missing']['datatype_tests']); $result = $db1->createSchema($schema, 'datatype_tests'); $this->assertNoPattern('/timestamp DEFAULT/', $result); $this->assertPattern('/\"full_length\"\s*text\s.*,/', $result); $this->assertPattern('/timestamp\s*,/', $result); $db1->query('DROP TABLE ' . $db1->fullTableName('datatype_tests')); $db1->query($result); $result2 = $schema->read(array( 'connection' => 'test_suite', 'models' => array('DatatypeTest') )); $schema->tables = array('datatype_tests' => $result2['tables']['missing']['datatype_tests']); $result2 = $db1->createSchema($schema, 'datatype_tests'); $this->assertEqual($result, $result2); $db1->query('DROP TABLE ' . $db1->fullTableName('datatype_tests')); }
testCakeSchema method Test that schema generated postgresql queries are valid. ref #5696 Check that the create statement for a schema generated table is the same as the original sql @return void @access public
testCakeSchema
php
Datawalke/Coordino
cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
MIT
function testIndexGeneration() { $name = $this->db->fullTableName('index_test', false); $this->db->query('CREATE TABLE ' . $name . ' ("id" serial NOT NULL PRIMARY KEY, "bool" integer, "small_char" varchar(50), "description" varchar(40) )'); $this->db->query('CREATE INDEX pointless_bool ON ' . $name . '("bool")'); $this->db->query('CREATE UNIQUE INDEX char_index ON ' . $name . '("small_char")'); $expected = array( 'PRIMARY' => array('column' => 'id', 'unique' => 1), 'pointless_bool' => array('column' => 'bool', 'unique' => 0), 'char_index' => array('column' => 'small_char', 'unique' => 1), ); $result = $this->db->index($name); $this->assertEqual($expected, $result); $this->db->query('DROP TABLE ' . $name); $name = $this->db->fullTableName('index_test_2', false); $this->db->query('CREATE TABLE ' . $name . ' ("id" serial NOT NULL PRIMARY KEY, "bool" integer, "small_char" varchar(50), "description" varchar(40) )'); $this->db->query('CREATE UNIQUE INDEX multi_col ON ' . $name . '("small_char", "bool")'); $expected = array( 'PRIMARY' => array('column' => 'id', 'unique' => 1), 'multi_col' => array('column' => array('small_char', 'bool'), 'unique' => 1), ); $result = $this->db->index($name); $this->assertEqual($expected, $result); $this->db->query('DROP TABLE ' . $name); }
Test index generation from table info. @return void
testIndexGeneration
php
Datawalke/Coordino
cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
MIT
function testAlterSchema() { $Old =& new CakeSchema(array( 'connection' => 'test_suite', 'name' => 'AlterPosts', 'alter_posts' => array( 'id' => array('type' => 'integer', 'key' => 'primary'), 'author_id' => array('type' => 'integer', 'null' => false), 'title' => array('type' => 'string', 'null' => true), 'body' => array('type' => 'text'), 'published' => array('type' => 'string', 'length' => 1, 'default' => 'N'), 'created' => array('type' => 'datetime'), 'updated' => array('type' => 'datetime'), ) )); $this->db->query($this->db->createSchema($Old)); $New =& new CakeSchema(array( 'connection' => 'test_suite', 'name' => 'AlterPosts', 'alter_posts' => array( 'id' => array('type' => 'integer', 'key' => 'primary'), 'author_id' => array('type' => 'integer', 'null' => true), 'title' => array('type' => 'string', 'null' => false, 'default' => 'my title'), 'body' => array('type' => 'string', 'length' => 500), 'status' => array('type' => 'integer', 'length' => 3, 'default' => 1), 'created' => array('type' => 'datetime'), 'updated' => array('type' => 'datetime'), ) )); $this->db->query($this->db->alterSchema($New->compare($Old), 'alter_posts')); $model = new CakeTestModel(array('table' => 'alter_posts', 'ds' => 'test_suite')); $result = $model->schema(); $this->assertTrue(isset($result['status'])); $this->assertFalse(isset($result['published'])); $this->assertEqual($result['body']['type'], 'string'); $this->assertEqual($result['status']['default'], 1); $this->assertEqual($result['author_id']['null'], true); $this->assertEqual($result['title']['null'], false); $this->db->query($this->db->dropSchema($New)); $New =& new CakeSchema(array( 'connection' => 'test_suite', 'name' => 'AlterPosts', 'alter_posts' => array( 'id' => array('type' => 'string', 'length' => 36, 'key' => 'primary'), 'author_id' => array('type' => 'integer', 'null' => false), 'title' => array('type' => 'string', 'null' => true), 'body' => array('type' => 'text'), 'published' => array('type' => 'string', 'length' => 1, 'default' => 'N'), 'created' => array('type' => 'datetime'), 'updated' => array('type' => 'datetime'), ) )); $result = $this->db->alterSchema($New->compare($Old), 'alter_posts'); $this->assertNoPattern('/varchar\(36\) NOT NULL/i', $result); }
Test the alterSchema capabilities of postgres @access public @return void
testAlterSchema
php
Datawalke/Coordino
cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
MIT
function testAlterIndexes() { $this->db->cacheSources = false; $schema1 =& new CakeSchema(array( 'name' => 'AlterTest1', 'connection' => 'test_suite', 'altertest' => array( 'id' => array('type' => 'integer', 'null' => false, 'default' => 0), 'name' => array('type' => 'string', 'null' => false, 'length' => 50), 'group1' => array('type' => 'integer', 'null' => true), 'group2' => array('type' => 'integer', 'null' => true) ) )); $this->db->query($this->db->createSchema($schema1)); $schema2 =& new CakeSchema(array( 'name' => 'AlterTest2', 'connection' => 'test_suite', 'altertest' => array( 'id' => array('type' => 'integer', 'null' => false, 'default' => 0), 'name' => array('type' => 'string', 'null' => false, 'length' => 50), 'group1' => array('type' => 'integer', 'null' => true), 'group2' => array('type' => 'integer', 'null' => true), 'indexes' => array( 'name_idx' => array('column' => 'name', 'unique' => 0), 'group_idx' => array('column' => 'group1', 'unique' => 0), 'compound_idx' => array('column' => array('group1', 'group2'), 'unique' => 0), 'PRIMARY' => array('column' => 'id', 'unique' => 1) ) ) )); $this->db->query($this->db->alterSchema($schema2->compare($schema1))); $indexes = $this->db->index('altertest'); $this->assertEqual($schema2->tables['altertest']['indexes'], $indexes); // Change three indexes, delete one and add another one $schema3 =& new CakeSchema(array( 'name' => 'AlterTest3', 'connection' => 'test_suite', 'altertest' => array( 'id' => array('type' => 'integer', 'null' => false, 'default' => 0), 'name' => array('type' => 'string', 'null' => false, 'length' => 50), 'group1' => array('type' => 'integer', 'null' => true), 'group2' => array('type' => 'integer', 'null' => true), 'indexes' => array( 'name_idx' => array('column' => 'name', 'unique' => 1), 'group_idx' => array('column' => 'group2', 'unique' => 0), 'compound_idx' => array('column' => array('group2', 'group1'), 'unique' => 0), 'another_idx' => array('column' => array('group1', 'name'), 'unique' => 0)) ))); $this->db->query($this->db->alterSchema($schema3->compare($schema2))); $indexes = $this->db->index('altertest'); $this->assertEqual($schema3->tables['altertest']['indexes'], $indexes); // Compare us to ourself. $this->assertEqual($schema3->compare($schema3), array()); // Drop the indexes $this->db->query($this->db->alterSchema($schema1->compare($schema3))); $indexes = $this->db->index('altertest'); $this->assertEqual(array(), $indexes); $this->db->query($this->db->dropSchema($schema1)); }
Test the alter index capabilities of postgres @access public @return void
testAlterIndexes
php
Datawalke/Coordino
cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
MIT
function testVirtualFieldAsAConstant() { $this->loadFixtures('Article', 'Comment'); $Article =& ClassRegistry::init('Article'); $Article->virtualFields = array( 'empty' => "NULL", 'number' => 43, 'truth' => 'TRUE' ); $result = $Article->find('first'); $this->assertNull($result['Article']['empty']); $this->assertTrue($result['Article']['truth']); $this->assertIdentical('43', $result['Article']['number']); }
Test that virtual fields work with SQL constants @return void
testVirtualFieldAsAConstant
php
Datawalke/Coordino
cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
MIT
function testOrderAdditionalParams() { $result = $this->db->order(array('title' => 'DESC NULLS FIRST', 'body' => 'DESC')); $expected = ' ORDER BY "title" DESC NULLS FIRST, "body" DESC'; $this->assertEqual($result, $expected); }
Tests additional order options for postgres @access public @return void
testOrderAdditionalParams
php
Datawalke/Coordino
cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
MIT
function testQuoteDistinctInFunction() { $this->loadFixtures('Article'); $Article = new Article; $result = $this->db->fields($Article, null, array('COUNT(DISTINCT Article.id)')); $expected = array('COUNT(DISTINCT "Article"."id")'); $this->assertEqual($result, $expected); $result = $this->db->fields($Article, null, array('COUNT(DISTINCT id)')); $expected = array('COUNT(DISTINCT "id")'); $this->assertEqual($result, $expected); $result = $this->db->fields($Article, null, array('COUNT(DISTINCT FUNC(id))')); $expected = array('COUNT(DISTINCT FUNC("id"))'); $this->assertEqual($result, $expected); }
Test it is possible to do a SELECT COUNT(DISTINCT Model.field) query in postgres and it gets correctly quoted
testQuoteDistinctInFunction
php
Datawalke/Coordino
cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
MIT
function testUpdateAllWithNonQualifiedConditions() { $this->loadFixtures('Article'); $Article =& new Article(); $result = $Article->updateAll(array('title' => "'Awesome'"), array('title' => 'Third Article')); $this->assertTrue($result); $result = $Article->find('count', array( 'conditions' => array('Article.title' => 'Awesome') )); $this->assertEqual($result, 1, 'Article count is wrong or fixture has changed.'); }
test that saveAll works even with conditions that lack a model name. @return void
testUpdateAllWithNonQualifiedConditions
php
Datawalke/Coordino
cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
MIT
function testAlteringTwoTables() { $schema1 =& new CakeSchema(array( 'name' => 'AlterTest1', 'connection' => 'test_suite', 'altertest' => array( 'id' => array('type' => 'integer', 'null' => false, 'default' => 0), 'name' => array('type' => 'string', 'null' => false, 'length' => 50), ), 'other_table' => array( 'id' => array('type' => 'integer', 'null' => false, 'default' => 0), 'name' => array('type' => 'string', 'null' => false, 'length' => 50), ) )); $schema2 =& new CakeSchema(array( 'name' => 'AlterTest1', 'connection' => 'test_suite', 'altertest' => array( 'id' => array('type' => 'integer', 'null' => false, 'default' => 0), 'field_two' => array('type' => 'string', 'null' => false, 'length' => 50), ), 'other_table' => array( 'id' => array('type' => 'integer', 'null' => false, 'default' => 0), 'field_two' => array('type' => 'string', 'null' => false, 'length' => 50), ) )); $result = $this->db->alterSchema($schema2->compare($schema1)); $this->assertEqual(2, substr_count($result, 'field_two'), 'Too many fields'); $this->assertFalse(strpos(';ALTER', $result), 'Too many semi colons'); }
test alterSchema on two tables. @return void
testAlteringTwoTables
php
Datawalke/Coordino
cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
MIT
function _execute($sql) { $this->simulated[] = $sql; return null; }
execute method @param mixed $sql @access protected @return void
_execute
php
Datawalke/Coordino
cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php
MIT
function getLastQuery() { return $this->simulated[count($this->simulated) - 1]; }
getLastQuery method @access public @return void
getLastQuery
php
Datawalke/Coordino
cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php
MIT
function skip() { $this->_initDb(); $this->skipUnless($this->db->config['driver'] == 'sqlite', '%s SQLite connection not available'); }
Skip if cannot connect to SQLite @access public
skip
php
Datawalke/Coordino
cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php
MIT
function setUp() { Configure::write('Cache.disable', true); $this->startTest(); $this->db =& ConnectionManager::getDataSource('test_suite'); $this->db2 = new DboSqliteTestDb($this->db->config, false); }
Sets up a Dbo class instance for testing @access public
setUp
php
Datawalke/Coordino
cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php
MIT
function tearDown() { Configure::write('Cache.disable', false); unset($this->db2); }
Sets up a Dbo class instance for testing @access public
tearDown
php
Datawalke/Coordino
cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php
MIT
function testTableListCacheDisabling() { $this->assertFalse(in_array('foo_test', $this->db->listSources())); $this->db->query('CREATE TABLE foo_test (test VARCHAR(255));'); $this->assertTrue(in_array('foo_test', $this->db->listSources())); $this->db->query('DROP TABLE foo_test;'); $this->assertFalse(in_array('foo_test', $this->db->listSources())); }
Tests that SELECT queries from DboSqlite::listSources() are not cached @access public
testTableListCacheDisabling
php
Datawalke/Coordino
cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php
MIT
function testIndex() { $name = $this->db->fullTableName('with_a_key'); $this->db->query('CREATE TABLE ' . $name . ' ("id" int(11) PRIMARY KEY, "bool" int(1), "small_char" varchar(50), "description" varchar(40) );'); $this->db->query('CREATE INDEX pointless_bool ON ' . $name . '("bool")'); $this->db->query('CREATE UNIQUE INDEX char_index ON ' . $name . '("small_char")'); $expected = array( 'PRIMARY' => array('column' => 'id', 'unique' => 1), 'pointless_bool' => array('column' => 'bool', 'unique' => 0), 'char_index' => array('column' => 'small_char', 'unique' => 1), ); $result = $this->db->index($name); $this->assertEqual($expected, $result); $this->db->query('DROP TABLE ' . $name); $this->db->query('CREATE TABLE ' . $name . ' ("id" int(11) PRIMARY KEY, "bool" int(1), "small_char" varchar(50), "description" varchar(40) );'); $this->db->query('CREATE UNIQUE INDEX multi_col ON ' . $name . '("small_char", "bool")'); $expected = array( 'PRIMARY' => array('column' => 'id', 'unique' => 1), 'multi_col' => array('column' => array('small_char', 'bool'), 'unique' => 1), ); $result = $this->db->index($name); $this->assertEqual($expected, $result); $this->db->query('DROP TABLE ' . $name); }
test Index introspection. @access public @return void
testIndex
php
Datawalke/Coordino
cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php
MIT
function testCacheKeyName() { Configure::write('Cache.disable', false); $dbName = 'db' . rand() . '$(*%&).db'; $this->assertFalse(file_exists(TMP . $dbName)); $config = $this->db->config; $db = new DboSqlite(array_merge($this->db->config, array('database' => TMP . $dbName))); $this->assertTrue(file_exists(TMP . $dbName)); $db->execute("CREATE TABLE test_list (id VARCHAR(255));"); $db->cacheSources = true; $this->assertEqual($db->listSources(), array('test_list')); $db->cacheSources = false; $fileName = '_' . preg_replace('/[^A-Za-z0-9_\-+]/', '_', TMP . $dbName) . '_list'; $result = Cache::read($fileName, '_cake_model_'); $this->assertEqual($result, array('test_list')); Cache::delete($fileName, '_cake_model_'); Configure::write('Cache.disable', true); }
Tests that cached table descriptions are saved under the sanitized key name @access public
testCacheKeyName
php
Datawalke/Coordino
cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php
MIT
function testBuildColumn() { $data = array( 'name' => 'int_field', 'type' => 'integer', 'null' => false, ); $result = $this->db->buildColumn($data); $expected = '"int_field" integer(11) NOT NULL'; $this->assertEqual($result, $expected); $data = array( 'name' => 'name', 'type' => 'string', 'length' => 20, 'null' => false, ); $result = $this->db->buildColumn($data); $expected = '"name" varchar(20) NOT NULL'; $this->assertEqual($result, $expected); $data = array( 'name' => 'testName', 'type' => 'string', 'length' => 20, 'default' => null, 'null' => true, 'collate' => 'NOCASE' ); $result = $this->db->buildColumn($data); $expected = '"testName" varchar(20) DEFAULT NULL COLLATE NOCASE'; $this->assertEqual($result, $expected); $data = array( 'name' => 'testName', 'type' => 'string', 'length' => 20, 'default' => 'test-value', 'null' => false, ); $result = $this->db->buildColumn($data); $expected = '"testName" varchar(20) DEFAULT \'test-value\' NOT NULL'; $this->assertEqual($result, $expected); $data = array( 'name' => 'testName', 'type' => 'integer', 'length' => 10, 'default' => 10, 'null' => false, ); $result = $this->db->buildColumn($data); $expected = '"testName" integer(10) DEFAULT \'10\' NOT NULL'; $this->assertEqual($result, $expected); $data = array( 'name' => 'testName', 'type' => 'integer', 'length' => 10, 'default' => 10, 'null' => false, 'collate' => 'BADVALUE' ); $result = $this->db->buildColumn($data); $expected = '"testName" integer(10) DEFAULT \'10\' NOT NULL'; $this->assertEqual($result, $expected); }
test building columns with SQLite @return void
testBuildColumn
php
Datawalke/Coordino
cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php
MIT
function testDescribe() { $Model =& new Model(array('name' => 'User', 'ds' => 'test_suite', 'table' => 'users')); $result = $this->db->describe($Model); $expected = array( 'id' => array( 'type' => 'integer', 'key' => 'primary', 'null' => false, 'default' => null, 'length' => 11 ), 'user' => array( 'type' => 'string', 'length' => 255, 'null' => false, 'default' => null ), 'password' => array( 'type' => 'string', 'length' => 255, 'null' => false, 'default' => null ), 'created' => array( 'type' => 'datetime', 'null' => true, 'default' => null, 'length' => null, ), 'updated' => array( 'type' => 'datetime', 'null' => true, 'default' => null, 'length' => null, ) ); $this->assertEqual($result, $expected); }
test describe() and normal results. @return void
testDescribe
php
Datawalke/Coordino
cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php
MIT
function testDescribeWithUuidPrimaryKey() { $tableName = 'uuid_tests'; $this->db->query("CREATE TABLE {$tableName} (id VARCHAR(36) PRIMARY KEY, name VARCHAR, created DATETIME, modified DATETIME)"); $Model =& new Model(array('name' => 'UuidTest', 'ds' => 'test_suite', 'table' => 'uuid_tests')); $result = $this->db->describe($Model); $expected = array( 'type' => 'string', 'length' => 36, 'null' => false, 'default' => null, 'key' => 'primary', ); $this->assertEqual($result['id'], $expected); $this->db->query('DROP TABLE ' . $tableName); }
test that describe does not corrupt UUID primary keys @return void
testDescribeWithUuidPrimaryKey
php
Datawalke/Coordino
cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php
MIT
function schema() { $this->_schema = array( 'id' => array('type' => 'integer', 'null' => false, 'default' => '', 'length' => '8'), 'title' => array('type' => 'string', 'null' => false, 'default' => '', 'length' => '255'), 'body' => array('type' => 'string', 'null' => true, 'default' => '', 'length' => ''), 'number' => array('type' => 'integer', 'null' => false, 'default' => '', 'length' => '8'), 'date' => array('type' => 'date', 'null' => true, 'default' => '', 'length' => ''), 'created' => array('type' => 'date', 'null' => true, 'default' => '', 'length' => ''), 'modified' => array('type' => 'datetime', 'null' => true, 'default' => '', 'length' => null) ); return $this->_schema; }
schema method @access public @return void
schema
php
Datawalke/Coordino
cake/tests/cases/libs/view/helper.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helper.test.php
MIT
function schema() { $this->_schema = array( 'id' => array('type' => 'integer', 'null' => false, 'default' => '', 'length' => '8'), 'author_id' => array('type' => 'integer', 'null' => false, 'default' => '', 'length' => '8'), 'title' => array('type' => 'string', 'null' => false, 'default' => '', 'length' => '255'), 'body' => array('type' => 'string', 'null' => true, 'default' => '', 'length' => ''), 'created' => array('type' => 'date', 'null' => true, 'default' => '', 'length' => ''), 'modified' => array('type' => 'datetime', 'null' => true, 'default' => '', 'length' => null) ); return $this->_schema; }
schema method @access public @return void
schema
php
Datawalke/Coordino
cake/tests/cases/libs/view/helper.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helper.test.php
MIT
function schema() { $this->_schema = array( 'id' => array('type' => 'integer', 'null' => false, 'default' => '', 'length' => '8'), 'name' => array('type' => 'string', 'null' => false, 'default' => '', 'length' => '255'), 'created' => array('type' => 'date', 'null' => true, 'default' => '', 'length' => ''), 'modified' => array('type' => 'datetime', 'null' => true, 'default' => '', 'length' => null) ); return $this->_schema; }
schema method @access public @return void
schema
php
Datawalke/Coordino
cake/tests/cases/libs/view/helper.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helper.test.php
MIT
function schema() { $this->_schema = array( 'helper_test_post_id' => array('type' => 'integer', 'null' => false, 'default' => '', 'length' => '8'), 'helper_test_tag_id' => array('type' => 'integer', 'null' => false, 'default' => '', 'length' => '8'), ); return $this->_schema; }
schema method @access public @return void
schema
php
Datawalke/Coordino
cake/tests/cases/libs/view/helper.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helper.test.php
MIT
function parseAttributes($options, $exclude = null, $insertBefore = ' ', $insertAfter = null) { return $this->_parseAttributes($options, $exclude, $insertBefore, $insertAfter); }
expose a method as public @param string $options @param string $exclude @param string $insertBefore @param string $insertAfter @return void
parseAttributes
php
Datawalke/Coordino
cake/tests/cases/libs/view/helper.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helper.test.php
MIT
function setUp() { ClassRegistry::flush(); Router::reload(); $null = null; $this->View = new View($null); $this->Helper = new Helper(); ClassRegistry::addObject('HelperTestPost', new HelperTestPost()); ClassRegistry::addObject('HelperTestComment', new HelperTestComment()); ClassRegistry::addObject('HelperTestTag', new HelperTestTag()); }
setUp method @access public @return void
setUp
php
Datawalke/Coordino
cake/tests/cases/libs/view/helper.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helper.test.php
MIT
function tearDown() { unset($this->Helper, $this->View); ClassRegistry::flush(); }
tearDown method @access public @return void
tearDown
php
Datawalke/Coordino
cake/tests/cases/libs/view/helper.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helper.test.php
MIT
function testSetEntity() { // PHP4 reference hack ClassRegistry::removeObject('view'); ClassRegistry::addObject('view', $this->View); $this->Helper->setEntity('HelperTestPost.id'); $this->assertFalse($this->View->modelScope); $this->assertEqual($this->View->model, 'HelperTestPost'); $this->assertEqual($this->View->field, 'id'); $this->assertEqual($this->View->modelId, null); $this->assertEqual($this->View->association, null); $this->Helper->setEntity('HelperTestComment.body'); $this->assertFalse($this->View->modelScope); $this->assertEqual($this->View->model, 'HelperTestComment'); $this->assertEqual($this->View->field, 'body'); $this->assertEqual($this->View->modelId, null); $this->assertEqual($this->View->association, null); $this->assertEqual($this->View->fieldSuffix, null); $this->Helper->setEntity('HelperTestPost', true); $this->assertTrue($this->View->modelScope); $this->assertEqual($this->View->model, 'HelperTestPost'); $this->assertEqual($this->View->field, null); $this->assertEqual($this->View->modelId, null); $this->assertEqual($this->View->association, null); $this->assertEqual($this->View->fieldSuffix, null); $this->Helper->setEntity('_Token.fields'); $this->assertTrue($this->View->modelScope); $this->assertEqual($this->View->model, 'HelperTestPost'); $this->assertEqual($this->View->field, 'fields'); $this->assertEqual($this->View->modelId, null); $this->assertEqual($this->View->association, '_Token'); $this->assertEqual($this->View->fieldSuffix, null); $this->Helper->setEntity('id'); $this->assertTrue($this->View->modelScope); $this->assertEqual($this->View->model, 'HelperTestPost'); $this->assertEqual($this->View->field, 'id'); $this->assertEqual($this->View->modelId, null); $this->assertEqual($this->View->association, null); $this->assertEqual($this->View->fieldSuffix, null); $this->Helper->setEntity('HelperTestComment.body'); $this->assertTrue($this->View->modelScope); $this->assertEqual($this->View->model, 'HelperTestPost'); $this->assertEqual($this->View->field, 'body'); $this->assertEqual($this->View->modelId, null); $this->assertEqual($this->View->association, 'HelperTestComment'); $this->assertEqual($this->View->fieldSuffix, null); $this->Helper->setEntity('body'); $this->assertTrue($this->View->modelScope); $this->assertEqual($this->View->model, 'HelperTestPost'); $this->assertEqual($this->View->field, 'body'); $this->assertEqual($this->View->modelId, null); $this->assertEqual($this->View->association, null); $this->assertEqual($this->View->fieldSuffix, null); $this->Helper->setEntity('Something.else'); $this->assertTrue($this->View->modelScope); $this->assertEqual($this->View->model, 'HelperTestPost'); $this->assertEqual($this->View->field, 'else'); $this->assertEqual($this->View->modelId, false); $this->assertEqual($this->View->association, 'Something'); $this->assertEqual($this->View->fieldSuffix, ''); $this->Helper->setEntity('5.id'); $this->assertTrue($this->View->modelScope); $this->assertEqual($this->View->model, 'HelperTestPost'); $this->assertEqual($this->View->field, 'id'); $this->assertEqual($this->View->modelId, '5'); $this->assertEqual($this->View->association, null); $this->assertEqual($this->View->fieldSuffix, null); $this->assertEqual($this->View->entity(), array('HelperTestPost', 5, 'id')); $this->Helper->setEntity('0.id'); $this->assertTrue($this->View->modelScope); $this->assertEqual($this->View->model, 'HelperTestPost'); $this->assertEqual($this->View->field, 'id'); $this->assertEqual($this->View->modelId, '0'); $this->assertEqual($this->View->association, null); $this->assertEqual($this->View->fieldSuffix, null); $this->assertEqual($this->View->entity(), array('HelperTestPost', 0, 'id')); $this->Helper->setEntity('5.created.month'); $this->assertTrue($this->View->modelScope); $this->assertEqual($this->View->model, 'HelperTestPost'); $this->assertEqual($this->View->field, 'created'); $this->assertEqual($this->View->modelId, '5'); $this->assertEqual($this->View->association, null); $this->assertEqual($this->View->fieldSuffix, 'month'); $this->Helper->setEntity('HelperTestComment.5.id'); $this->assertTrue($this->View->modelScope); $this->assertEqual($this->View->model, 'HelperTestPost'); $this->assertEqual($this->View->field, 'id'); $this->assertEqual($this->View->modelId, '5'); $this->assertEqual($this->View->association, 'HelperTestComment'); $this->assertEqual($this->View->fieldSuffix, null); $this->Helper->setEntity('HelperTestComment.id.time'); $this->assertTrue($this->View->modelScope); $this->assertEqual($this->View->model, 'HelperTestPost'); $this->assertEqual($this->View->field, 'id'); $this->assertEqual($this->View->modelId, null); $this->assertEqual($this->View->association, 'HelperTestComment'); $this->assertEqual($this->View->fieldSuffix, 'time'); $this->Helper->setEntity('HelperTestTag'); $this->assertTrue($this->View->modelScope); $this->assertEqual($this->View->model, 'HelperTestPost'); $this->assertEqual($this->View->field, 'HelperTestTag'); $this->assertEqual($this->View->modelId, ''); $this->assertEqual($this->View->association, 'HelperTestTag'); $this->assertEqual($this->View->fieldSuffix, ''); $this->Helper->setEntity(null); $this->Helper->setEntity('ModelThatDoesntExist.field_that_doesnt_exist'); $this->assertFalse($this->View->modelScope); $this->assertEqual($this->View->model, 'ModelThatDoesntExist'); $this->assertEqual($this->View->field, 'field_that_doesnt_exist'); $this->assertEqual($this->View->modelId, null); $this->assertEqual($this->View->association, null); $this->assertEqual($this->View->fieldSuffix, null); }
testFormFieldNameParsing method @access public @return void
testSetEntity
php
Datawalke/Coordino
cake/tests/cases/libs/view/helper.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helper.test.php
MIT
function testSetEntityWithView() { $this->assertNull($this->Helper->setEntity('Allow.view.group_id')); $this->assertNull($this->Helper->setEntity('Allow.view')); $this->assertNull($this->Helper->setEntity('View.view')); }
test that 'view' doesn't break things. @return void
testSetEntityWithView
php
Datawalke/Coordino
cake/tests/cases/libs/view/helper.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helper.test.php
MIT
function testValue() { $this->Helper->data = array('fullname' => 'This is me'); $this->Helper->setEntity('fullname'); $result = $this->Helper->value('fullname'); $this->assertEqual($result, 'This is me'); $this->Helper->data = array('Post' => array('name' => 'First Post')); $this->Helper->setEntity('Post.name'); $result = $this->Helper->value('Post.name'); $this->assertEqual($result, 'First Post'); $this->Helper->data = array('Post' => array(2 => array('name' => 'First Post'))); $this->Helper->setEntity('Post.2.name'); $result = $this->Helper->value('Post.2.name'); $this->assertEqual($result, 'First Post'); $this->Helper->data = array('Post' => array(2 => array('created' => array('year' => '2008')))); $this->Helper->setEntity('Post.2.created'); $result = $this->Helper->value('Post.2.created'); $this->assertEqual($result, array('year' => '2008')); $this->Helper->data = array('Post' => array(2 => array('created' => array('year' => '2008')))); $this->Helper->setEntity('Post.2.created.year'); $result = $this->Helper->value('Post.2.created.year'); $this->assertEqual($result, '2008'); $this->Helper->data = array('HelperTestTag' => array('HelperTestTag' => '')); $this->Helper->setEntity('HelperTestTag.HelperTestTag'); $result = $this->Helper->value('HelperTestTag.HelperTestTag'); $this->assertEqual($result, ''); $this->Helper->data = array('HelperTestTag' => array('HelperTestTag' => array(2, 3, 4))); $this->Helper->setEntity('HelperTestTag.HelperTestTag'); $result = $this->Helper->value('HelperTestTag.HelperTestTag'); $this->assertEqual($result, array(2, 3, 4)); $this->Helper->data = array( 'HelperTestTag' => array( array('id' => 3), array('id' => 5) ) ); $this->Helper->setEntity('HelperTestTag.HelperTestTag'); $result = $this->Helper->value('HelperTestTag.HelperTestTag'); $this->assertEqual($result, array(3 => 3, 5 => 5)); $this->Helper->data = array('zero' => 0); $this->Helper->setEntity('zero'); $result = $this->Helper->value(array('default' => 'something'), 'zero'); $this->assertEqual($result, array('value' => 0)); $this->Helper->data = array('zero' => '0'); $result = $this->Helper->value(array('default' => 'something'), 'zero'); $this->assertEqual($result, array('value' => '0')); $this->Helper->setEntity('inexistent'); $result = $this->Helper->value(array('default' => 'something'), 'inexistent'); $this->assertEqual($result, array('value' => 'something')); }
test getting values from Helper @return void
testValue
php
Datawalke/Coordino
cake/tests/cases/libs/view/helper.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helper.test.php
MIT
function testUrlConversion() { $result = $this->Helper->url('/controller/action/1'); $this->assertEqual($result, '/controller/action/1'); $result = $this->Helper->url('/controller/action/1?one=1&two=2'); $this->assertEqual($result, '/controller/action/1?one=1&two=2'); $result = $this->Helper->url(array('controller' => 'posts', 'action' => 'index', 'page' => '1" onclick="alert(\'XSS\');"')); $this->assertEqual($result, "/posts/index/page:1" onclick="alert('XSS');""); $result = $this->Helper->url('/controller/action/1/param:this+one+more'); $this->assertEqual($result, '/controller/action/1/param:this+one+more'); $result = $this->Helper->url('/controller/action/1/param:this%20one%20more'); $this->assertEqual($result, '/controller/action/1/param:this%20one%20more'); $result = $this->Helper->url('/controller/action/1/param:%7Baround%20here%7D%5Bthings%5D%5Bare%5D%24%24'); $this->assertEqual($result, '/controller/action/1/param:%7Baround%20here%7D%5Bthings%5D%5Bare%5D%24%24'); $result = $this->Helper->url(array( 'controller' => 'posts', 'action' => 'index', 'param' => '%7Baround%20here%7D%5Bthings%5D%5Bare%5D%24%24' )); $this->assertEqual($result, "/posts/index/param:%7Baround%20here%7D%5Bthings%5D%5Bare%5D%24%24"); $result = $this->Helper->url(array( 'controller' => 'posts', 'action' => 'index', 'page' => '1', '?' => array('one' => 'value', 'two' => 'value', 'three' => 'purple') )); $this->assertEqual($result, "/posts/index/page:1?one=value&two=value&three=purple"); }
Ensure HTML escaping of url params. So link addresses are valid and not exploited @return void
testUrlConversion
php
Datawalke/Coordino
cake/tests/cases/libs/view/helper.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helper.test.php
MIT
function testAssetTimestampPluginsAndThemes() { $_timestamp = Configure::read('Asset.timestamp'); Configure::write('Asset.timestamp', 'force'); App::build(array( 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS), 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS), )); $result = $this->Helper->assetTimestamp('/test_plugin/css/test_plugin_asset.css'); $this->assertPattern('#/test_plugin/css/test_plugin_asset.css\?[0-9]+$#', $result, 'Missing timestamp plugin'); $result = $this->Helper->assetTimestamp('/test_plugin/css/i_dont_exist.css'); $this->assertPattern('#/test_plugin/css/i_dont_exist.css\?$#', $result, 'No error on missing file'); $result = $this->Helper->assetTimestamp('/theme/test_theme/js/theme.js'); $this->assertPattern('#/theme/test_theme/js/theme.js\?[0-9]+$#', $result, 'Missing timestamp theme'); $result = $this->Helper->assetTimestamp('/theme/test_theme/js/non_existant.js'); $this->assertPattern('#/theme/test_theme/js/non_existant.js\?$#', $result, 'No error on missing file'); App::build(); Configure::write('Asset.timestamp', $_timestamp); }
test assetTimestamp with plugins and themes @return void
testAssetTimestampPluginsAndThemes
php
Datawalke/Coordino
cake/tests/cases/libs/view/helper.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helper.test.php
MIT
function testFieldsWithSameName() { // PHP4 reference hack ClassRegistry::removeObject('view'); ClassRegistry::addObject('view', $this->View); $this->Helper->setEntity('HelperTestTag', true); $this->Helper->setEntity('HelperTestTag.id'); $this->assertEqual($this->View->model, 'HelperTestTag'); $this->assertEqual($this->View->field, 'id'); $this->assertEqual($this->View->modelId, null); $this->assertEqual($this->View->association, null); $this->assertEqual($this->View->fieldSuffix, null); $this->Helper->setEntity('My.id'); $this->assertEqual($this->View->model, 'HelperTestTag'); $this->assertEqual($this->View->field, 'id'); $this->assertEqual($this->View->modelId, null); $this->assertEqual($this->View->association, 'My'); $this->assertEqual($this->View->fieldSuffix, null); $this->Helper->setEntity('MyOther.id'); $this->assertEqual($this->View->model, 'HelperTestTag'); $this->assertEqual($this->View->field, 'id'); $this->assertEqual($this->View->modelId, null); $this->assertEqual($this->View->association, 'MyOther'); $this->assertEqual($this->View->fieldSuffix, null); }
testFieldsWithSameName method @access public @return void
testFieldsWithSameName
php
Datawalke/Coordino
cake/tests/cases/libs/view/helper.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helper.test.php
MIT
function testFieldSameAsModel() { // PHP4 reference hack ClassRegistry::removeObject('view'); ClassRegistry::addObject('view', $this->View); $this->Helper->setEntity('HelperTestTag', true); $this->Helper->setEntity('helper_test_post'); $this->assertEqual($this->View->model, 'HelperTestTag'); $this->assertEqual($this->View->field, 'helper_test_post'); $this->assertEqual($this->View->modelId, null); $this->assertEqual($this->View->association, null); $this->assertEqual($this->View->fieldSuffix, null); $this->Helper->setEntity('HelperTestTag'); $this->assertEqual($this->View->model, 'HelperTestTag'); $this->assertEqual($this->View->field, 'HelperTestTag'); $this->assertEqual($this->View->modelId, null); $this->assertEqual($this->View->association, null); $this->assertEqual($this->View->fieldSuffix, null); $this->assertEqual($this->View->entityPath, 'HelperTestTag'); }
testFieldSameAsModel method @access public @return void
testFieldSameAsModel
php
Datawalke/Coordino
cake/tests/cases/libs/view/helper.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helper.test.php
MIT
function testFieldSuffixForDate() { // PHP4 reference hack ClassRegistry::removeObject('view'); ClassRegistry::addObject('view', $this->View); $this->Helper->setEntity('HelperTestPost', true); $this->assertEqual($this->View->model, 'HelperTestPost'); $this->assertEqual($this->View->field, null); $this->assertEqual($this->View->modelId, null); $this->assertEqual($this->View->association, null); $this->assertEqual($this->View->fieldSuffix, null); $this->Helper->setEntity('date.month'); $this->assertEqual($this->View->model, 'HelperTestPost'); $this->assertEqual($this->View->field, 'date'); $this->assertEqual($this->View->modelId, null); $this->assertEqual($this->View->association, null); $this->assertEqual($this->View->fieldSuffix, 'month'); }
testFieldSuffixForDate method @access public @return void
testFieldSuffixForDate
php
Datawalke/Coordino
cake/tests/cases/libs/view/helper.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helper.test.php
MIT
function testMulitDimensionValue() { $this->Helper->data = array(); for ($i = 0; $i < 2; $i++) { $this->Helper->data['Model'][$i] = 'what'; $result[] = $this->Helper->value("Model.{$i}"); $this->Helper->data['Model'][$i] = array(); for ($j = 0; $j < 2; $j++) { $this->Helper->data['Model'][$i][$j] = 'how'; $result[] = $this->Helper->value("Model.{$i}.{$j}"); } } $expected = array('what', 'how', 'how', 'what', 'how', 'how'); $this->assertEqual($result, $expected); $this->Helper->data['HelperTestComment']['5']['id'] = 'ok'; $result = $this->Helper->value('HelperTestComment.5.id'); $this->assertEqual($result, 'ok'); $this->Helper->setEntity('HelperTestPost', true); $this->Helper->data['HelperTestPost']['5']['created']['month'] = '10'; $result = $this->Helper->value('5.created.month'); $this->assertEqual($result, 10); $this->Helper->data['HelperTestPost']['0']['id'] = 100; $result = $this->Helper->value('0.id'); $this->assertEqual($result, 100); }
testMulitDimensionValue method @access public @return void
testMulitDimensionValue
php
Datawalke/Coordino
cake/tests/cases/libs/view/helper.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helper.test.php
MIT
function testClean() { $result = $this->Helper->clean(array()); $this->assertEqual($result, null); $result = $this->Helper->clean(array('<script>with something</script>', '<applet>something else</applet>')); $this->assertEqual($result, array('with something', 'something else')); $result = $this->Helper->clean('<script>with something</script>'); $this->assertEqual($result, 'with something'); $result = $this->Helper->clean('<script type="text/javascript">alert("ruined");</script>'); $this->assertNoPattern('#</*script#', $result); $result = $this->Helper->clean("<script \ntype=\"text/javascript\">\n\talert('ruined');\n\n\t\t</script>"); $this->assertNoPattern('#</*script#', $result); $result = $this->Helper->clean('<body/onload=do(/something/)>'); $this->assertEqual($result, '<body/>'); $result = $this->Helper->clean('&lt;script&gt;alert(document.cookie)&lt;/script&gt;'); $this->assertEqual($result, '&amp;lt;script&amp;gt;alert(document.cookie)&amp;lt;/script&amp;gt;'); }
testClean method @access public @return void
testClean
php
Datawalke/Coordino
cake/tests/cases/libs/view/helper.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helper.test.php
MIT
function testMultiDimensionalField() { // PHP4 reference hack ClassRegistry::removeObject('view'); ClassRegistry::addObject('view', $this->View); $this->Helper->setEntity('HelperTestPost', true); $this->Helper->setEntity('HelperTestPost.2.HelperTestComment.1.title'); $this->assertEqual($this->View->model, 'HelperTestPost'); $this->assertEqual($this->View->association, 'HelperTestComment'); $this->assertEqual($this->View->modelId,2); $this->assertEqual($this->View->field, 'title'); $this->Helper->setEntity('HelperTestPost.1.HelperTestComment.1.HelperTestTag.1.created'); $this->assertEqual($this->View->field,'created'); $this->assertEqual($this->View->association,'HelperTestTag'); $this->assertEqual($this->View->modelId,1); $this->Helper->setEntity('HelperTestPost.0.HelperTestComment.1.HelperTestTag.1.fake'); $this->assertEqual($this->View->model,'HelperTestPost'); $this->assertEqual($this->View->association,'HelperTestTag'); $this->assertEqual($this->View->field,null); $this->Helper->setEntity('1.HelperTestComment.1.HelperTestTag.created.year'); $this->assertEqual($this->View->model,'HelperTestPost'); $this->assertEqual($this->View->association,'HelperTestTag'); $this->assertEqual($this->View->field,'created'); $this->assertEqual($this->View->modelId,1); $this->assertEqual($this->View->fieldSuffix,'year'); $this->Helper->data['HelperTestPost'][2]['HelperTestComment'][1]['title'] = 'My Title'; $result = $this->Helper->value('HelperTestPost.2.HelperTestComment.1.title'); $this->assertEqual($result,'My Title'); $this->Helper->data['HelperTestPost'][2]['HelperTestComment'][1]['created']['year'] = 2008; $result = $this->Helper->value('HelperTestPost.2.HelperTestComment.1.created.year'); $this->assertEqual($result,2008); $this->Helper->data[2]['HelperTestComment'][1]['created']['year'] = 2008; $result = $this->Helper->value('HelperTestPost.2.HelperTestComment.1.created.year'); $this->assertEqual($result,2008); $this->Helper->data['HelperTestPost']['title'] = 'My Title'; $result = $this->Helper->value('title'); $this->assertEqual($result,'My Title'); $this->Helper->data['My']['title'] = 'My Title'; $result = $this->Helper->value('My.title'); $this->assertEqual($result,'My Title'); }
testMultiDimensionalField method @access public @return void
testMultiDimensionalField
php
Datawalke/Coordino
cake/tests/cases/libs/view/helper.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/helper.test.php
MIT
function download() { $path = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'vendors' . DS .'css' . DS; $id = 'test_asset.css'; $extension = 'css'; $this->set(compact('path', 'id', 'extension')); }
index download @access public @return void
download
php
Datawalke/Coordino
cake/tests/cases/libs/view/media.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/media.test.php
MIT
function _isActive() { return $this->active; }
_isActive method. Usted de $active property to mock an active (true) connection, or an aborted (false) one @access protected @return void
_isActive
php
Datawalke/Coordino
cake/tests/cases/libs/view/media.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/media.test.php
MIT
function startTest() { Router::reload(); $this->Controller =& new Controller(); $this->MediaController =& new MediaController(); $this->MediaController->viewPath = 'posts'; }
startTest method @access public @return void
startTest
php
Datawalke/Coordino
cake/tests/cases/libs/view/media.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/media.test.php
MIT
function endTest() { unset($this->MediaView); unset($this->MediaController); unset($this->Controller); ClassRegistry::flush(); }
endTest method @access public @return void
endTest
php
Datawalke/Coordino
cake/tests/cases/libs/view/media.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/media.test.php
MIT
function testRender() { ob_start(); $this->MediaController->download(); $this->MediaView =& new TestMediaView($this->MediaController); $result = $this->MediaView->render(); $output = ob_get_clean(); $this->assertTrue($result !== false); $this->assertEqual($output, 'this is the test asset css file'); }
testRender method @access public @return void
testRender
php
Datawalke/Coordino
cake/tests/cases/libs/view/media.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/media.test.php
MIT
function testConnectionAborted() { $this->MediaController->download(); $this->MediaView =& new TestMediaView($this->MediaController); $this->MediaView->active = false; $result = $this->MediaView->render(); $this->assertFalse($result); }
testConnectionAborted method @access public @return void
testConnectionAborted
php
Datawalke/Coordino
cake/tests/cases/libs/view/media.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/media.test.php
MIT
function index() { $this->set('testData', 'Some test data'); $test2 = 'more data'; $test3 = 'even more data'; $this->set(compact('test2', 'test3')); }
index method @access public @return void
index
php
Datawalke/Coordino
cake/tests/cases/libs/view/theme.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/theme.test.php
MIT
function renderElement($name, $params = array()) { return $name; }
renderElement method @param mixed $name @param array $params @access public @return void
renderElement
php
Datawalke/Coordino
cake/tests/cases/libs/view/theme.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/theme.test.php
MIT
function getViewFileName($name = null) { return $this->_getViewFileName($name); }
getViewFileName method @param mixed $name @access public @return void
getViewFileName
php
Datawalke/Coordino
cake/tests/cases/libs/view/theme.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/theme.test.php
MIT
function getLayoutFileName($name = null) { return $this->_getLayoutFileName($name); }
getLayoutFileName method @param mixed $name @access public @return void
getLayoutFileName
php
Datawalke/Coordino
cake/tests/cases/libs/view/theme.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/theme.test.php
MIT
function cakeError($method, $messages) { $error =& new ThemeViewTestErrorHandler($method, $messages); return $error; }
cakeError method @param mixed $method @param mixed $messages @access public @return void
cakeError
php
Datawalke/Coordino
cake/tests/cases/libs/view/theme.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/theme.test.php
MIT
function setUp() { Router::reload(); $this->Controller =& new Controller(); $this->PostsController =& new ThemePostsController(); $this->PostsController->viewPath = 'posts'; $this->PostsController->index(); $this->ThemeView =& new ThemeView($this->PostsController); }
setUp method @access public @return void
setUp
php
Datawalke/Coordino
cake/tests/cases/libs/view/theme.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/theme.test.php
MIT
function tearDown() { unset($this->ThemeView); unset($this->PostsController); unset($this->Controller); ClassRegistry::flush(); }
tearDown method @access public @return void
tearDown
php
Datawalke/Coordino
cake/tests/cases/libs/view/theme.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/theme.test.php
MIT
function testConstructionNoRegister() { ClassRegistry::flush(); $controller = null; $Theme =& new ThemeView($controller, false); $ThemeTwo =& ClassRegistry::getObject('view'); $this->assertFalse($ThemeTwo); }
test that the theme view can be constructed without going into the registry @return void
testConstructionNoRegister
php
Datawalke/Coordino
cake/tests/cases/libs/view/theme.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/theme.test.php
MIT
function testPluginThemedGetTemplate() { $this->Controller->plugin = 'test_plugin'; $this->Controller->name = 'TestPlugin'; $this->Controller->viewPath = 'tests'; $this->Controller->action = 'index'; $this->Controller->theme = 'test_theme'; $ThemeView =& new TestThemeView($this->Controller); $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'plugins' . DS . 'test_plugin' . DS . 'tests' . DS .'index.ctp'; $result = $ThemeView->getViewFileName('index'); $this->assertEqual($result, $expected); $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'plugins' . DS . 'test_plugin' . DS . 'layouts' . DS .'plugin_default.ctp'; $result = $ThemeView->getLayoutFileName('plugin_default'); $this->assertEqual($result, $expected); $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'layouts' . DS .'default.ctp'; $result = $ThemeView->getLayoutFileName('default'); $this->assertEqual($result, $expected); }
testPluginGetTemplate method @access public @return void
testPluginThemedGetTemplate
php
Datawalke/Coordino
cake/tests/cases/libs/view/theme.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/theme.test.php
MIT
function testGetTemplate() { $this->Controller->plugin = null; $this->Controller->name = 'Pages'; $this->Controller->viewPath = 'pages'; $this->Controller->action = 'display'; $this->Controller->params['pass'] = array('home'); $ThemeView =& new TestThemeView($this->Controller); $ThemeView->theme = 'test_theme'; $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS .'pages' . DS .'home.ctp'; $result = $ThemeView->getViewFileName('home'); $this->assertEqual($result, $expected); $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'posts' . DS .'index.ctp'; $result = $ThemeView->getViewFileName('/posts/index'); $this->assertEqual($result, $expected); $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'layouts' . DS .'default.ctp'; $result = $ThemeView->getLayoutFileName(); $this->assertEqual($result, $expected); $ThemeView->layoutPath = 'rss'; $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'layouts' . DS . 'rss' . DS . 'default.ctp'; $result = $ThemeView->getLayoutFileName(); $this->assertEqual($result, $expected); $ThemeView->layoutPath = 'email' . DS . 'html'; $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'layouts' . DS . 'email' . DS . 'html' . DS . 'default.ctp'; $result = $ThemeView->getLayoutFileName(); $this->assertEqual($result, $expected); }
testGetTemplate method @access public @return void
testGetTemplate
php
Datawalke/Coordino
cake/tests/cases/libs/view/theme.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/theme.test.php
MIT
function testMissingView() { $this->Controller->plugin = null; $this->Controller->name = 'Pages'; $this->Controller->viewPath = 'pages'; $this->Controller->action = 'display'; $this->Controller->theme = 'my_theme'; $this->Controller->params['pass'] = array('home'); restore_error_handler(); $View =& new TestThemeView($this->Controller); ob_start(); $result = $View->getViewFileName('does_not_exist'); $expected = str_replace(array("\t", "\r\n", "\n"), "", ob_get_clean()); set_error_handler('simpleTestErrorHandler'); $this->assertPattern("/PagesController::/", $expected); $this->assertPattern("/views(\/|\\\)themed(\/|\\\)my_theme(\/|\\\)pages(\/|\\\)does_not_exist.ctp/", $expected); }
testMissingView method @access public @return void
testMissingView
php
Datawalke/Coordino
cake/tests/cases/libs/view/theme.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/theme.test.php
MIT
function testMissingLayout() { $this->Controller->plugin = null; $this->Controller->name = 'Posts'; $this->Controller->viewPath = 'posts'; $this->Controller->layout = 'whatever'; $this->Controller->theme = 'my_theme'; restore_error_handler(); $View =& new TestThemeView($this->Controller); ob_start(); $result = $View->getLayoutFileName(); $expected = str_replace(array("\t", "\r\n", "\n"), "", ob_get_clean()); set_error_handler('simpleTestErrorHandler'); $this->assertPattern("/Missing Layout/", $expected); $this->assertPattern("/views(\/|\\\)themed(\/|\\\)my_theme(\/|\\\)layouts(\/|\\\)whatever.ctp/", $expected); }
testMissingLayout method @access public @return void
testMissingLayout
php
Datawalke/Coordino
cake/tests/cases/libs/view/theme.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/theme.test.php
MIT
function testMemoryLeakInPaths() { if ($this->skipIf(!function_exists('memory_get_usage'), 'No memory measurement function, cannot test for possible memory leak. %s')) { return; } $this->Controller->plugin = null; $this->Controller->name = 'Posts'; $this->Controller->viewPath = 'posts'; $this->Controller->layout = 'whatever'; $this->Controller->theme = 'test_theme'; $View =& new ThemeView($this->Controller); $View->element('test_element'); $start = memory_get_usage(); for ($i = 0; $i < 10; $i++) { $View->element('test_element'); } $end = memory_get_usage(); $this->assertWithinMargin($start, $end, 3500); }
test memory leaks that existed in _paths at one point. @return void
testMemoryLeakInPaths
php
Datawalke/Coordino
cake/tests/cases/libs/view/theme.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/theme.test.php
MIT
function index() { $this->set('testData', 'Some test data'); $test2 = 'more data'; $test3 = 'even more data'; $this->set(compact('test2', 'test3')); }
index method @access public @return void
index
php
Datawalke/Coordino
cake/tests/cases/libs/view/view.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/view.test.php
MIT
function getViewFileName($name = null) { return $this->_getViewFileName($name); }
getViewFileName method @param mixed $name @access public @return void
getViewFileName
php
Datawalke/Coordino
cake/tests/cases/libs/view/view.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/view.test.php
MIT
function getLayoutFileName($name = null) { return $this->_getLayoutFileName($name); }
getLayoutFileName method @param mixed $name @access public @return void
getLayoutFileName
php
Datawalke/Coordino
cake/tests/cases/libs/view/view.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/view.test.php
MIT
function loadHelpers(&$loaded, $helpers, $parent = null) { return $this->_loadHelpers($loaded, $helpers, $parent); }
loadHelpers method @param mixed $loaded @param mixed $helpers @param mixed $parent @access public @return void
loadHelpers
php
Datawalke/Coordino
cake/tests/cases/libs/view/view.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/view.test.php
MIT
function paths($plugin = null, $cached = true) { return $this->_paths($plugin, $cached); }
paths method @param string $plugin @param boolean $cached @access public @return void
paths
php
Datawalke/Coordino
cake/tests/cases/libs/view/view.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/view.test.php
MIT
function cakeError($method, $messages) { $error =& new ViewTestErrorHandler($method, $messages); return $error; }
cakeError method @param mixed $method @param mixed $messages @access public @return void
cakeError
php
Datawalke/Coordino
cake/tests/cases/libs/view/view.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/view.test.php
MIT
function beforeLayout() { $this->property = 'Valuation'; }
beforeLayout method @access public @return void
beforeLayout
php
Datawalke/Coordino
cake/tests/cases/libs/view/view.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/view.test.php
MIT
function afterLayout() { $View =& ClassRegistry::getObject('afterView'); $View->output .= 'modified in the afterlife'; }
afterLayout method @access public @return void
afterLayout
php
Datawalke/Coordino
cake/tests/cases/libs/view/view.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/view.test.php
MIT
function setUp() { Router::reload(); $this->Controller = new Controller(); $this->PostsController = new ViewPostsController(); $this->PostsController->viewPath = 'posts'; $this->PostsController->index(); $this->View = new View($this->PostsController); }
setUp method @access public @return void
setUp
php
Datawalke/Coordino
cake/tests/cases/libs/view/view.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/view.test.php
MIT
function tearDown() { unset($this->View); unset($this->PostsController); unset($this->Controller); }
tearDown method @access public @return void
tearDown
php
Datawalke/Coordino
cake/tests/cases/libs/view/view.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/view.test.php
MIT
function testPluginGetTemplate() { $this->Controller->plugin = 'test_plugin'; $this->Controller->name = 'TestPlugin'; $this->Controller->viewPath = 'tests'; $this->Controller->action = 'index'; $View = new TestView($this->Controller); $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS .'test_plugin' . DS . 'views' . DS .'tests' . DS .'index.ctp'; $result = $View->getViewFileName('index'); $this->assertEqual($result, $expected); $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS .'test_plugin' . DS . 'views' . DS . 'layouts' . DS .'default.ctp'; $result = $View->getLayoutFileName(); $this->assertEqual($result, $expected); }
testPluginGetTemplate method @access public @return void
testPluginGetTemplate
php
Datawalke/Coordino
cake/tests/cases/libs/view/view.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/view.test.php
MIT
function testPluginPathGeneration() { $this->Controller->plugin = 'test_plugin'; $this->Controller->name = 'TestPlugin'; $this->Controller->viewPath = 'tests'; $this->Controller->action = 'index'; $View = new TestView($this->Controller); $paths = $View->paths(); $this->assertEqual($paths, App::path('views')); $paths = $View->paths('test_plugin'); $expected = array( TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'plugins' . DS . 'test_plugin' . DS, TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS . 'views' . DS, TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS, TEST_CAKE_CORE_INCLUDE_PATH . 'libs' . DS . 'view' . DS ); $this->assertEqual($paths, $expected); }
test that plugin/$plugin_name is only appended to the paths it should be. @return void
testPluginPathGeneration
php
Datawalke/Coordino
cake/tests/cases/libs/view/view.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/view.test.php
MIT
function testCamelCasePluginGetTemplate() { $this->Controller->plugin = 'TestPlugin'; $this->Controller->name = 'TestPlugin'; $this->Controller->viewPath = 'tests'; $this->Controller->action = 'index'; $View = new TestView($this->Controller); App::build(array( 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS), 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS) )); $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS .'test_plugin' . DS . 'views' . DS .'tests' . DS .'index.ctp'; $result = $View->getViewFileName('index'); $this->assertEqual($result, $expected); $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS .'test_plugin' . DS . 'views' . DS . 'layouts' . DS .'default.ctp'; $result = $View->getLayoutFileName(); $this->assertEqual($result, $expected); }
test that CamelCase plugins still find their view files. @return void
testCamelCasePluginGetTemplate
php
Datawalke/Coordino
cake/tests/cases/libs/view/view.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/view.test.php
MIT
function testGetTemplate() { $this->Controller->plugin = null; $this->Controller->name = 'Pages'; $this->Controller->viewPath = 'pages'; $this->Controller->action = 'display'; $this->Controller->params['pass'] = array('home'); $View = new TestView($this->Controller); $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS .'pages' . DS .'home.ctp'; $result = $View->getViewFileName('home'); $this->assertEqual($result, $expected); $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS .'posts' . DS .'index.ctp'; $result = $View->getViewFileName('/posts/index'); $this->assertEqual($result, $expected); $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS .'posts' . DS .'index.ctp'; $result = $View->getViewFileName('../posts/index'); $this->assertEqual($result, $expected); $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'layouts' . DS .'default.ctp'; $result = $View->getLayoutFileName(); $this->assertEqual($result, $expected); $View->layoutPath = 'rss'; $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'layouts' . DS . 'rss' . DS . 'default.ctp'; $result = $View->getLayoutFileName(); $this->assertEqual($result, $expected); $View->layoutPath = 'email' . DS . 'html'; $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'layouts' . DS . 'email' . DS . 'html' . DS . 'default.ctp'; $result = $View->getLayoutFileName(); $this->assertEqual($result, $expected); }
testGetTemplate method @access public @return void
testGetTemplate
php
Datawalke/Coordino
cake/tests/cases/libs/view/view.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/view.test.php
MIT
function testMissingView() { $this->Controller->plugin = null; $this->Controller->name = 'Pages'; $this->Controller->viewPath = 'pages'; $this->Controller->action = 'display'; $this->Controller->params['pass'] = array('home'); $View = new TestView($this->Controller); ob_start(); $result = $View->getViewFileName('does_not_exist'); $expected = str_replace(array("\t", "\r\n", "\n"), "", ob_get_clean()); $this->assertPattern("/PagesController::/", $expected); $this->assertPattern("/pages(\/|\\\)does_not_exist.ctp/", $expected); }
testMissingView method @access public @return void
testMissingView
php
Datawalke/Coordino
cake/tests/cases/libs/view/view.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/view.test.php
MIT
function testMissingLayout() { $this->Controller->plugin = null; $this->Controller->name = 'Posts'; $this->Controller->viewPath = 'posts'; $this->Controller->layout = 'whatever'; $View = new TestView($this->Controller); ob_start(); $result = $View->getLayoutFileName(); $expected = str_replace(array("\t", "\r\n", "\n"), "", ob_get_clean()); $this->assertPattern("/Missing Layout/", $expected); $this->assertPattern("/layouts(\/|\\\)whatever.ctp/", $expected); }
testMissingLayout method @access public @return void
testMissingLayout
php
Datawalke/Coordino
cake/tests/cases/libs/view/view.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/view.test.php
MIT
function testViewVars() { $this->assertEqual($this->View->viewVars, array('testData' => 'Some test data', 'test2' => 'more data', 'test3' => 'even more data')); }
testViewVars method @access public @return void
testViewVars
php
Datawalke/Coordino
cake/tests/cases/libs/view/view.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/view.test.php
MIT
function testUUIDGeneration() { $result = $this->View->uuid('form', array('controller' => 'posts', 'action' => 'index')); $this->assertEqual($result, 'form5988016017'); $result = $this->View->uuid('form', array('controller' => 'posts', 'action' => 'index')); $this->assertEqual($result, 'formc3dc6be854'); $result = $this->View->uuid('form', array('controller' => 'posts', 'action' => 'index')); $this->assertEqual($result, 'form28f92cc87f'); }
testUUIDGeneration method @access public @return void
testUUIDGeneration
php
Datawalke/Coordino
cake/tests/cases/libs/view/view.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/view.test.php
MIT
function testAddInlineScripts() { $this->View->addScript('prototype.js'); $this->View->addScript('prototype.js'); $this->assertEqual($this->View->__scripts, array('prototype.js')); $this->View->addScript('mainEvent', 'Event.observe(window, "load", function() { doSomething(); }, true);'); $this->assertEqual($this->View->__scripts, array('prototype.js', 'mainEvent' => 'Event.observe(window, "load", function() { doSomething(); }, true);')); }
testAddInlineScripts method @access public @return void
testAddInlineScripts
php
Datawalke/Coordino
cake/tests/cases/libs/view/view.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/view.test.php
MIT
function testElement() { $result = $this->View->element('test_element'); $this->assertEqual($result, 'this is the test element'); $result = $this->View->element('plugin_element', array('plugin' => 'test_plugin')); $this->assertEqual($result, 'this is the plugin element using params[plugin]'); $this->View->plugin = 'test_plugin'; $result = $this->View->element('test_plugin_element'); $this->assertEqual($result, 'this is the test set using View::$plugin plugin element'); $result = $this->View->element('non_existant_element'); $this->assertPattern('/Not Found:/', $result); $this->assertPattern('/non_existant_element/', $result); }
testElement method @access public @return void
testElement
php
Datawalke/Coordino
cake/tests/cases/libs/view/view.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/view.test.php
MIT
function testElementExtensions() { $this->View->ext = '.xml'; $result = $this->View->element('test_element'); $this->assertEqual(trim($result), '<p>test element</p>'); }
Test that alternate extensions work with duplicated elements. @return void
testElementExtensions
php
Datawalke/Coordino
cake/tests/cases/libs/view/view.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/view.test.php
MIT
function testElementParamsDontOverwriteHelpers() { $Controller = new ViewPostsController(); $Controller->helpers = array('Form'); $View = new View($Controller); $result = $View->element('type_check', array('form' => 'string'), true); $this->assertEqual('string', $result); $View->set('form', 'string'); $result = $View->element('type_check', array(), true); $this->assertEqual('string', $result); }
test that additional element viewVars don't get overwritten with helpers. @return void
testElementParamsDontOverwriteHelpers
php
Datawalke/Coordino
cake/tests/cases/libs/view/view.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/view.test.php
MIT
function testElementCacheHelperNoCache() { $Controller = new ViewPostsController(); $View = new View($Controller); $empty = array(); $helpers = $View->_loadHelpers($empty, array('cache')); $View->loaded = $helpers; $result = $View->element('test_element', array('ram' => 'val', 'test' => array('foo', 'bar'))); $this->assertEqual($result, 'this is the test element'); }
testElementCacheHelperNoCache method @access public @return void
testElementCacheHelperNoCache
php
Datawalke/Coordino
cake/tests/cases/libs/view/view.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/view/view.test.php
MIT