lithium\tests\integration\data\source\database\adapter\PostgreSqlTest::testDefaultValues PHP Метод

testDefaultValues() публичный Метод

public testDefaultValues ( )
    public function testDefaultValues()
    {
        $this->_db->dropSchema('galleries');
        $schema = new Schema(array('fields' => array('id' => array('type' => 'id'), 'name' => array('type' => 'string', 'length' => 255, 'default' => 'image'), 'active' => array('type' => 'boolean', 'default' => false), 'show' => array('type' => 'boolean', 'default' => true), 'empty' => array('type' => 'text', 'null' => true), 'created' => array('type' => 'timestamp', 'null' => true, 'default' => (object) 'CURRENT_TIMESTAMP'), 'modified' => array('type' => 'timestamp', 'null' => false, 'default' => (object) 'CURRENT_TIMESTAMP'))));
        $this->_db->createSchema('galleries', $schema);
        $gallery = Galleries::create();
        $this->assertEqual('image', $gallery->name);
        $this->assertEqual(false, $gallery->active);
        $this->assertEqual(true, $gallery->show);
        $this->assertEqual(null, $gallery->empty);
        $gallery->save();
        $result = Galleries::find('first')->data();
        $this->assertEqual(1, $result['id']);
        $this->assertEqual('image', $result['name']);
        $this->assertEqual(false, $result['active']);
        $this->assertEqual(true, $result['show']);
        $this->assertEqual(null, $result['empty']);
        $this->assertPattern('$\\d{4}-\\d\\d-\\d\\d \\d\\d:\\d\\d:\\d\\d\\.\\d+$', $result['created']);
        $this->assertPattern('$\\d{4}-\\d\\d-\\d\\d \\d\\d:\\d\\d:\\d\\d\\.\\d+$', $result['modified']);
        $time = time();
        $this->assertTrue($time - strtotime($result['created']) < 24 * 3600);
        $this->assertTrue($time - strtotime($result['modified']) < 24 * 3600);
    }