public function testToBuy() { $response = $this->getMockResponse(['data' => self::$buy]); $buy = $this->mapper->toBuy($response); $this->assertEquals(self::$buy['id'], $buy->getId()); $this->assertEquals(self::$buy['status'], $buy->getStatus()); $this->assertInstanceOf(PaymentMethod::class, $buy->getPaymentMethod()); $this->assertEquals(self::$buy['payment_method']['id'], $buy->getPaymentMethod()->getId()); $this->assertInstanceOf(Transaction::class, $buy->getTransaction()); $this->assertEquals(self::$buy['transaction']['id'], $buy->getTransaction()->getId()); $this->assertInstanceOf(Money::class, $buy->getAmount()); $this->assertEquals(self::$buy['amount']['amount'], $buy->getAmount()->getAmount()); $this->assertEquals(self::$buy['amount']['currency'], $buy->getAmount()->getCurrency()); $this->assertInstanceOf(Money::class, $buy->getTotal()); $this->assertEquals(self::$buy['total']['amount'], $buy->getTotal()->getAmount()); $this->assertEquals(self::$buy['total']['currency'], $buy->getTotal()->getCurrency()); $this->assertInstanceOf(Money::class, $buy->getSubtotal()); $this->assertEquals(self::$buy['subtotal']['amount'], $buy->getSubtotal()->getAmount()); $this->assertEquals(self::$buy['subtotal']['currency'], $buy->getSubtotal()->getCurrency()); $this->assertInstanceOf(\DateTime::class, $buy->getCreatedAt()); $this->assertInstanceOf(\DateTime::class, $buy->getUpdatedAt()); $this->assertEquals(self::$buy['resource_path'], $buy->getResourcePath()); $this->assertEquals(self::$buy['committed'], $buy->isCommitted()); $this->assertEquals(self::$buy['instant'], $buy->isInstant()); $this->assertInternalType('array', $buy->getFees()); $this->assertArrayHasKey(0, $buy->getFees()); $this->assertInstanceOf(Fee::class, $buy->getFees()[0]); $this->assertEquals(self::$buy['fees'][0]['type'], $buy->getFees()[0]->getType()); $this->assertInstanceOf(Money::class, $buy->getFees()[0]->getAmount()); $this->assertEquals(self::$buy['fees'][0]['amount']['amount'], $buy->getFees()[0]->getAmount()->getAmount()); $this->assertEquals(self::$buy['fees'][0]['amount']['currency'], $buy->getFees()[0]->getAmount()->getCurrency()); $this->assertInstanceOf(\DateTime::class, $buy->getPayoutAt()); $this->assertEquals(self::$buy, $buy->getRawData()); }