SchemaTest.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /**
  3. * Lithium: the most rad php framework
  4. *
  5. * @copyright Copyright 2013, Union of RAD (http://union-of-rad.org)
  6. * @license http://opensource.org/licenses/bsd-license.php The BSD License
  7. */
  8. namespace lithium\tests\cases\data;
  9. use lithium\data\Schema;
  10. class SchemaTest extends \lithium\test\Unit {
  11. public function testShortHandTypeDefinitions() {
  12. $schema = new Schema(array('fields' => array(
  13. 'id' => 'int',
  14. 'name' => 'string',
  15. 'active' => array('type' => 'boolean', 'default' => true)
  16. )));
  17. $this->assertEqual('int', $schema->type('id'));
  18. $this->assertEqual('string', $schema->type('name'));
  19. $this->assertEqual('boolean', $schema->type('active'));
  20. $this->assertEqual(array('type' => 'int'), $schema->fields('id'));
  21. $this->assertEqual(array('id', 'name', 'active'), $schema->names());
  22. $expected = array(
  23. 'id' => array('type' => 'int'),
  24. 'name' => array('type' => 'string'),
  25. 'active' => array('type' => 'boolean', 'default' => true)
  26. );
  27. $this->assertEqual($expected, $schema->fields());
  28. }
  29. }
  30. ?>