Exemple #1
0
 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();
 }
Exemple #2
0
	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;
	}