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 \InFog\SimpleFinance\Entities\Movement(); $movement->setDate($date); $movement->setAmount(new \InFog\SimpleFinance\Types\Money($amount)); $movement->setName(new \InFog\SimpleFinance\Types\SmallString($name)); $movement->setDescription(new \InFog\SimpleFinance\Types\Text('Description of a movement')); return $this->repository->save($movement); }
public function testCreateCollectionAndIterateOverIt() { $collection = new \InFog\SimpleFinance\Collections\Movement(); $m1 = new \InFog\SimpleFinance\Entities\Movement(); $m1->setName(new \InFog\SimpleFinance\Types\SmallString('First Movement')); $m2 = new \InFog\SimpleFinance\Entities\Movement(); $m2->setName(new \InFog\SimpleFinance\Types\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); }
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); }