public function testSchemaLoading() { $result = MockPost::schema(); $this->assertTrue($result); MockPost::resetSchema(); $this->assertEqual($result, MockPost::schema()); }
public function testSettingNestedObjectDefaults() { $schema = MockPost::schema()->append(array('nested.value' => array('type' => 'string', 'default' => 'foo'))); $this->assertEqual('foo', MockPost::create()->nested['value']); $data = array('nested' => array('value' => 'bar')); $this->assertEqual('bar', MockPost::create($data)->nested['value']); }
public function testModelWithNoBackend() { $this->assertEqual('mock-source', MockPost::meta('connection')); MockPost::config(array('connection' => false)); $this->assertFalse(MockPost::meta('connection')); $schema = array('id' => array('type' => 'integer'), 'author_id' => array('type' => 'integer'), 'title' => array('type' => 'string'), 'body' => array('type' => 'text')); MockPost::overrideSchema($schema); $this->assertEqual($schema, MockPost::schema()); $post = MockPost::create(array('title' => 'New post')); $this->assertTrue($post instanceof \lithium\data\Entity); $this->assertEqual('New post', $post->title); $this->expectException('/Connection name not defined/'); $post->save(); }
public function testSettingNestedObjectDefaults() { $this->skipIf(!MockMongoConnection::enabled(), 'MongoDb not enabled.'); MockPost::$connection = new MockMongoConnection(); $schema = MockPost::schema(); MockPost::overrideSchema($schema + array('nested.value' => array( 'type' => 'string', 'default' => 'foo' ))); $this->assertEqual('foo', MockPost::create()->nested->value); $data = array('nested' => array('value' => 'bar')); $this->assertEqual('bar', MockPost::create($data)->nested->value); MockPost::overrideSchema($schema); MockPost::$connection = null; }