public function testSerializableValues() { $testModel = TestModel::create(['title' => 'Title', 'values' => ['foo' => 'Something', 'bar' => 'Baz']]); $this->assertEquals('Something', $testModel->foo, 'Serialized value not properly set.'); $this->assertEquals('Baz', $testModel->bar, 'Serialized value not properly set.'); $testModel->foo = 'Bar'; $this->assertEquals('Bar', $testModel->foo, 'Serialized value not properly set.'); $testModel->baz = 'bar'; $this->assertNull($testModel->getValue('baz'), 'Unallowed value was set.'); }
public function testGenerateSchema2() { $model = new TestModel(); $schema = Pluf::factory('Pluf_DB_Schema', $this->db); $schema->model = $model; $this->assertEquals(true, $schema->dropTables()); $this->assertEquals(true, $schema->createTables()); $model->title = 'my title'; $model->description = 'A small desc.'; $this->assertEquals(true, $model->create()); $this->assertEquals(1, (int) $model->id); $this->assertEquals(true, $schema->dropTables()); }
/** * @covers Model::create */ public function testCreate() { $instance = TestModel::create(); $this->assertInstanceOf('TestModel', $instance); }
public function testMagicSetter() { $model = TestModel::create()->setAnotherProperty('value')->setProp1(1); $this->assertEquals(1, $model->prop1); $this->assertEquals('value', $model->another_property); }
public function testExceptionOnProperty() { $model = new TestModel(); $model->title = 'title'; $model->description = 'A small desc '; $this->assertEquals(true, $model->create()); try { $rel = $model->should_fail; // next line should not be called $this->assertEquals(true, false); } catch (Exception $e) { $this->assertEquals('Cannot get property "should_fail".', $e->getMessage()); } }