getTestInstance(); self::assertNull($instance->getType()); self::assertNull($instance->type); $instance->setType($value['type']); self::assertSame($value['type'], $instance->getType()); self::assertSame($value['type'], $instance->type); } /** * @dataProvider invalidTypeDataProvider */ public function testSetInvalidType($value) { $this->expectException('\InvalidArgumentException'); $this->getTestInstance()->setType($value); } /** * @dataProvider validDataProvider */ public function testGetSetAmount($value) { $instance = $this->getTestInstance(); self::assertNull($instance->getAmount()); self::assertNull($instance->amount); $amount = new MonetaryAmount($value['amount']['value'], $value['amount']['currency']); $instance->setAmount($amount); self::assertSame($amount, $instance->getAmount()); self::assertSame($amount, $instance->amount); } /** * @dataProvider validDataProvider */ public function testSetAmountFromArray($value) { $instance = $this->getTestInstance(); $instance->setAmount($value['amount']); self::assertInstanceOf('YooKassa\Model\MonetaryAmount', $instance->getAmount()); self::assertEquals($value['amount']['value'], $instance->getAmount()->getValue()); } /** * @dataProvider invalidAmountDataProvider */ public function testSetInvalidAmount($value) { $this->expectException('\InvalidArgumentException'); $this->getTestInstance()->setAmount($value); } public function validDataProvider() { $result = array(); for ($i = 0; $i < 5; $i++) { $result[] = array( array( 'type' => Random::value(SettlementPayoutPaymentType::getValidValues()), 'amount' => array( 'value' => sprintf('%.2f', round(Random::float(0.1, 99.99), 2)), 'currency' => Random::value(CurrencyCode::getValidValues()), ), ), ); } return $result; } public function invalidTypeDataProvider() { return array( array(null), array(''), array(1.0), array(1), array(true), array(false), array(array()), array(new stdClass()), array(Random::str(1, 10)), ); } public function invalidAmountDataProvider() { return array( array(null), array(''), array(1.0), array(1), array(true), array(false), array(new stdClass()), ); } }