object = $this->getMockBuilder(Settlement::class)->getMockForAbstractClass(); $this->assertTrue(class_exists(Settlement::class)); $this->assertInstanceOf(Settlement::class, $this->object); } /** * Test property "type" * @dataProvider validTypeDataProvider * @param mixed $value * * @return void * @throws Exception */ public function testType(mixed $value): void { $instance = $this->getTestInstance(); $instance->setType($value); self::assertNotNull($instance->getType()); self::assertNotNull($instance->type); self::assertEquals($value, is_array($value) ? $instance->getType()->toArray() : $instance->getType()); self::assertEquals($value, is_array($value) ? $instance->type->toArray() : $instance->type); self::assertContains($instance->getType(), ['cashless', 'prepayment', 'postpayment', 'consideration']); self::assertContains($instance->type, ['cashless', 'prepayment', 'postpayment', 'consideration']); } /** * Test invalid property "type" * @dataProvider invalidTypeDataProvider * @param mixed $value * @param string $exceptionClass * * @return void */ public function testInvalidType(mixed $value, string $exceptionClass): void { $instance = $this->getTestInstance(); $this->expectException($exceptionClass); $instance->setType($value); } /** * @return array[] * @throws Exception */ public function validTypeDataProvider(): array { $instance = $this->getTestInstance(); return $this->getValidDataProviderByType($instance->getValidator()->getRulesByPropName('_type')); } /** * @return array[] * @throws Exception */ public function invalidTypeDataProvider(): array { $instance = $this->getTestInstance(); return $this->getInvalidDataProviderByType($instance->getValidator()->getRulesByPropName('_type')); } /** * Test property "amount" * @dataProvider validAmountDataProvider * @param mixed $value * * @return void * @throws Exception */ public function testAmount(mixed $value): void { $instance = $this->getTestInstance(); $instance->setAmount($value); self::assertNotNull($instance->getAmount()); self::assertNotNull($instance->amount); self::assertEquals($value, is_array($value) ? $instance->getAmount()->toArray() : $instance->getAmount()); self::assertEquals($value, is_array($value) ? $instance->amount->toArray() : $instance->amount); } /** * Test invalid property "amount" * @dataProvider invalidAmountDataProvider * @param mixed $value * @param string $exceptionClass * * @return void */ public function testInvalidAmount(mixed $value, string $exceptionClass): void { $instance = $this->getTestInstance(); $this->expectException($exceptionClass); $instance->setAmount($value); } /** * @return array[] * @throws Exception */ public function validAmountDataProvider(): array { $instance = $this->getTestInstance(); return $this->getValidDataProviderByType($instance->getValidator()->getRulesByPropName('_amount')); } /** * @return array[] * @throws Exception */ public function invalidAmountDataProvider(): array { $instance = $this->getTestInstance(); return $this->getInvalidDataProviderByType($instance->getValidator()->getRulesByPropName('_amount')); } }