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.');
 }
Ejemplo n.º 2
0
 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());
 }
Ejemplo n.º 3
0
 /**
  * @covers Model::create
  */
 public function testCreate()
 {
     $instance = TestModel::create();
     $this->assertInstanceOf('TestModel', $instance);
 }
Ejemplo n.º 4
0
 public function testMagicSetter()
 {
     $model = TestModel::create()->setAnotherProperty('value')->setProp1(1);
     $this->assertEquals(1, $model->prop1);
     $this->assertEquals('value', $model->another_property);
 }
Ejemplo n.º 5
0
 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());
     }
 }