Exemplo n.º 1
0
 public function testCreateFromArray()
 {
     $expected = new Movement();
     $expected->setDate(new \DateTime('2013-01-01'));
     $expected->setAmount(new Money(100));
     $expected->setName(new SmallString('Test'));
     $expected->setDescription(new Text('Just a test'));
     $result = Movement::createFromArray(array('date' => '2013-01-01', 'amount' => 100, 'name' => 'Test', 'description' => 'Just a test'));
     $this->assertEquals($expected, $result);
 }
Exemplo n.º 2
0
 public function testCreateCollectionAndIterateOverIt()
 {
     $collection = new \InFog\SimpleFinance\Collections\Movement();
     $m1 = new Movement();
     $m1->setName(new SmallString('First Movement'));
     $m2 = new Movement();
     $m2->setName(new SmallString('Second Movement'));
     $collection->add($m1);
     $collection->add($m2);
     $expected = array("First Movement", "Second Movement");
     $result = array();
     foreach ($collection as $m) {
         $result[] = "{$m->getName()}";
     }
     $this->assertEquals($expected, $result);
 }
Exemplo n.º 3
0
 private function createAMovement($name = null, $amount = null, \DateTime $date = null)
 {
     $name = $name ? $name : 'Testing Repository';
     $amount = $amount ? $amount : 10;
     $date = $date ? $date : new \DateTime();
     $movement = new Movement();
     $movement->setDate($date);
     $movement->setAmount(new Money($amount));
     $movement->setName(new SmallString($name));
     $movement->setDescription(new Text('Description of a movement'));
     return $this->repository->save($movement);
 }