Skip to content
Permalink
Browse files

Added test for _initializeSchema

  • Loading branch information...
lorenzo committed Jul 6, 2014
1 parent 178c587 commit b49c55ff41a409a52ec02d6c690f9929b8094b46
Showing with 24 additions and 0 deletions.
  1. +24 −0 tests/TestCase/ORM/TableTest.php
@@ -263,6 +263,30 @@ public function testSchema() {
);
}
/**
* Tests that _initializeSchema can be used to alter the database schema
*
* @return void
*/
public function testSchemaInitialize() {
$schema = $this->connection->schemaCollection()->describe('users');
$table = $this->getMock('Cake\ORM\Table', ['_initializeSchema'], [
['table' => 'users', 'connection' => $this->connection]
]);
$table->expects($this->once())
->method('_initializeSchema')
->with($schema)
->will($this->returnCallback(function($schema) {
$schema->columnType('username', 'integer');
return $schema;
}));
$result = $table->schema();
$schema->columnType('username', 'integer');
$this->assertEquals($schema, $result);
$this->assertEquals($schema, $result, '_initializeSchema should be called once');
}
/**
* Tests that all fields for a table are added by default in a find when no
* other fields are specified

0 comments on commit b49c55f

Please sign in to comment.
You can’t perform that action at this time.