Exemplo n.º 1
0
 public function testAdd()
 {
     $mocks['currency'] = $this->getMockBuilder('\\SerendipityHQ\\Component\\ValueObjects\\Currency\\Currency')->disableOriginalConstructor()->getMock();
     $mocks['currency']->method('getSubUnit')->willReturn(100);
     $mocks['currency']->method('getDefaultFractionDigits')->willReturn(2);
     $test = ['amount' => 100, 'currency' => $mocks['currency']];
     $resource = new Money($test);
     $toAdd = new Money($test);
     $result = $resource->add($toAdd);
     // Test the value object direct interface
     $this->assertInstanceOf(MoneyInterface::class, $result);
     // Test the type of value object interface
     $this->assertInstanceOf(ComplexValueObjectInterface::class, $result);
     $this->assertInstanceOf(CurrencyInterface::class, $result->getCurrency());
     $this->assertEquals(200, $result->getAmount());
 }