Exemplo n.º 1
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.º 2
0
 public function testCreateFromArray()
 {
     $expected = new \InFog\SimpleFinance\Entities\Movement();
     $expected->setDate(new \DateTime('2013-01-01'));
     $expected->setAmount(new \InFog\SimpleFinance\Types\Money(100));
     $expected->setName(new \InFog\SimpleFinance\Types\SmallString('Test'));
     $expected->setDescription(new \InFog\SimpleFinance\Types\Text('Just a test'));
     $result = \InFog\SimpleFinance\Entities\Movement::createFromArray(array('date' => '2013-01-01', 'amount' => 100, 'name' => 'Test', 'description' => 'Just a test'));
     $this->assertEquals($expected, $result);
 }
Exemplo n.º 3
0
 public function createDTO(\InFog\SimpleFinance\Entities\Movement $movement)
 {
     $dto = new \stdClass();
     $dto->id = $movement->getId();
     $dto->date = $movement->getDate()->format('Y-m-d H:i:s');
     $dto->amount = $movement->getAmount()->getValue();
     $dto->name = $movement->getName()->getValue();
     $dto->description = $movement->getDescription()->getValue();
     return $dto;
 }
Exemplo n.º 4
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);
 }