Ejemplo n.º 1
0
 public function testToArray()
 {
     $model = new TestModel();
     $model->setArray(array('prop1' => 1, 'prop2' => 'two'));
     $array = $model->toArray();
     $this->assertEquals(1, $array['prop1']);
     $this->assertEquals('two', $array['prop2']);
 }
Ejemplo n.º 2
0
 /**
  * @covers Model::fromArray
  * @covers Model::toArray
  */
 public function testToAndFromArray()
 {
     $this->assertSame(array('id' => null, 'true_false' => null, 'created' => null, 'updated' => null), $this->instance->toArray());
     $now = time();
     $this->instance->fromArray(array('id' => '1', 'true_false' => 'true', 'created' => time(), 'updated' => time()));
     $this->assertSame(1, $this->instance->getId());
     $this->assertSame(1, $this->instance->getTrueFalse());
     $this->assertSame(date('Y-m-d H:i:s', $now), $this->instance->getCreated());
     $this->assertSame($now, $this->instance->getUpdated(null));
     $this->assertSame(array('id' => 1, 'true_false' => 1, 'created' => date('Y-m-d H:i:s', $now), 'updated' => $now), $this->instance->toArray());
 }
Ejemplo n.º 3
0
 /**
  * Test that the data given at init is loaded
  */
 public function testLoadData()
 {
     $data = array('test' => 'foo');
     $model = new TestModel($data);
     $this->assertEquals($data, $model->toArray());
 }