object = $this->getMockBuilder(CreateDealRequest::class)->getMockForAbstractClass(); $this->assertTrue(class_exists(CreateDealRequest::class)); $this->assertInstanceOf(CreateDealRequest::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(), ['safe_deal']); self::assertContains($instance->type, ['safe_deal']); } /** * 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 "fee_moment" * @dataProvider validFeeMomentDataProvider * @param mixed $value * * @return void * @throws Exception */ public function testFeeMoment(mixed $value): void { $instance = $this->getTestInstance(); $instance->setFeeMoment($value); self::assertNotNull($instance->getFeeMoment()); self::assertNotNull($instance->fee_moment); self::assertEquals($value, is_array($value) ? $instance->getFeeMoment()->toArray() : $instance->getFeeMoment()); self::assertEquals($value, is_array($value) ? $instance->fee_moment->toArray() : $instance->fee_moment); } /** * Test invalid property "fee_moment" * @dataProvider invalidFeeMomentDataProvider * @param mixed $value * @param string $exceptionClass * * @return void */ public function testInvalidFeeMoment(mixed $value, string $exceptionClass): void { $instance = $this->getTestInstance(); $this->expectException($exceptionClass); $instance->setFeeMoment($value); } /** * @return array[] * @throws Exception */ public function validFeeMomentDataProvider(): array { $instance = $this->getTestInstance(); return $this->getValidDataProviderByType($instance->getValidator()->getRulesByPropName('_fee_moment')); } /** * @return array[] * @throws Exception */ public function invalidFeeMomentDataProvider(): array { $instance = $this->getTestInstance(); return $this->getInvalidDataProviderByType($instance->getValidator()->getRulesByPropName('_fee_moment')); } /** * Test property "metadata" * @dataProvider validMetadataDataProvider * @param mixed $value * * @return void * @throws Exception */ public function testMetadata(mixed $value): void { $instance = $this->getTestInstance(); self::assertEmpty($instance->getMetadata()); self::assertEmpty($instance->metadata); $instance->setMetadata($value); if (!empty($value)) { self::assertNotNull($instance->getMetadata()); self::assertNotNull($instance->metadata); self::assertTrue($instance->hasMetadata()); foreach ($value as $key => $element) { if (!empty($element)) { self::assertEquals($element, $instance->getMetadata()[$key]); self::assertEquals($element, $instance->metadata[$key]); self::assertIsObject($instance->getMetadata()); self::assertIsObject($instance->metadata); } } self::assertCount(count($value), $instance->getMetadata()); self::assertCount(count($value), $instance->metadata); if ($instance->getMetadata() instanceof Metadata) { self::assertEquals($value, $instance->getMetadata()->toArray()); self::assertEquals($value, $instance->metadata->toArray()); self::assertCount(count($value), $instance->getMetadata()); self::assertCount(count($value), $instance->metadata); } } } /** * Test invalid property "metadata" * @dataProvider invalidMetadataDataProvider * @param mixed $value * @param string $exceptionClass * * @return void */ public function testInvalidMetadata(mixed $value, string $exceptionClass): void { $instance = $this->getTestInstance(); $this->expectException($exceptionClass); $instance->setMetadata($value); } /** * @return array[] * @throws Exception */ public function validMetadataDataProvider(): array { $instance = $this->getTestInstance(); return $this->getValidDataProviderByType($instance->getValidator()->getRulesByPropName('_metadata')); } /** * @return array[] * @throws Exception */ public function invalidMetadataDataProvider(): array { $instance = $this->getTestInstance(); return $this->getInvalidDataProviderByType($instance->getValidator()->getRulesByPropName('_metadata')); } /** * Test property "description" * @dataProvider validDescriptionDataProvider * @param mixed $value * * @return void * @throws Exception */ public function testDescription(mixed $value): void { $instance = $this->getTestInstance(); self::assertEmpty($instance->getDescription()); self::assertEmpty($instance->description); $instance->setDescription($value); self::assertEquals($value, is_array($value) ? $instance->getDescription()->toArray() : $instance->getDescription()); self::assertEquals($value, is_array($value) ? $instance->description->toArray() : $instance->description); if (!empty($value)) { self::assertNotNull($instance->getDescription()); self::assertNotNull($instance->description); self::assertLessThanOrEqual(128, is_string($instance->getDescription()) ? mb_strlen($instance->getDescription()) : $instance->getDescription()); self::assertLessThanOrEqual(128, is_string($instance->description) ? mb_strlen($instance->description) : $instance->description); } } /** * Test invalid property "description" * @dataProvider invalidDescriptionDataProvider * @param mixed $value * @param string $exceptionClass * * @return void */ public function testInvalidDescription(mixed $value, string $exceptionClass): void { $instance = $this->getTestInstance(); $this->expectException($exceptionClass); $instance->setDescription($value); } /** * @return array[] * @throws Exception */ public function validDescriptionDataProvider(): array { $instance = $this->getTestInstance(); return $this->getValidDataProviderByType($instance->getValidator()->getRulesByPropName('_description')); } /** * @return array[] * @throws Exception */ public function invalidDescriptionDataProvider(): array { $instance = $this->getTestInstance(); return $this->getInvalidDataProviderByType($instance->getValidator()->getRulesByPropName('_description')); } /** * Test valid method "validate" * @dataProvider validClassDataProvider * @param mixed $value * * @return void */ public function testValidate(mixed $value): void { $instance = $this->getTestInstance($value); self::assertTrue($instance->validate()); } /** * @return array * @throws Exception */ public function validClassDataProvider(): array { $instance = $this->getTestInstance(); return [$this->getValidDataProviderByClass($instance)]; } /** * Test valid method "builder" * @dataProvider validClassDataProvider * @param mixed $value * * @return void */ public function testBuilder(mixed $value): void { $instance = $this->getTestInstance($value); self::assertInstanceOf(AbstractRequestBuilder::class, $instance::builder()); } }