object = $this->getMockBuilder(BankCardProduct::class)->getMockForAbstractClass(); $this->assertTrue(class_exists(BankCardProduct::class)); $this->assertInstanceOf(BankCardProduct::class, $this->object); } /** * Test property "code" * @dataProvider validCodeDataProvider * @param mixed $value * * @return void * @throws Exception */ public function testCode(mixed $value): void { $instance = $this->getTestInstance(); $instance->setCode($value); self::assertNotNull($instance->getCode()); self::assertNotNull($instance->code); self::assertEquals($value, is_array($value) ? $instance->getCode()->toArray() : $instance->getCode()); self::assertEquals($value, is_array($value) ? $instance->code->toArray() : $instance->code); } /** * Test invalid property "code" * @dataProvider invalidCodeDataProvider * @param mixed $value * @param string $exceptionClass * * @return void */ public function testInvalidCode(mixed $value, string $exceptionClass): void { $instance = $this->getTestInstance(); $this->expectException($exceptionClass); $instance->setCode($value); } /** * @return array[] * @throws Exception */ public function validCodeDataProvider(): array { $instance = $this->getTestInstance(); return $this->getValidDataProviderByType($instance->getValidator()->getRulesByPropName('_code')); } /** * @return array[] * @throws Exception */ public function invalidCodeDataProvider(): array { $instance = $this->getTestInstance(); return $this->getInvalidDataProviderByType($instance->getValidator()->getRulesByPropName('_code')); } /** * Test property "name" * @dataProvider validNameDataProvider * @param mixed $value * * @return void * @throws Exception */ public function testName(mixed $value): void { $instance = $this->getTestInstance(); self::assertEmpty($instance->getName()); self::assertEmpty($instance->name); $instance->setName($value); self::assertEquals($value, is_array($value) ? $instance->getName()->toArray() : $instance->getName()); self::assertEquals($value, is_array($value) ? $instance->name->toArray() : $instance->name); if (!empty($value)) { self::assertNotNull($instance->getName()); self::assertNotNull($instance->name); } } /** * Test invalid property "name" * @dataProvider invalidNameDataProvider * @param mixed $value * @param string $exceptionClass * * @return void */ public function testInvalidName(mixed $value, string $exceptionClass): void { $instance = $this->getTestInstance(); $this->expectException($exceptionClass); $instance->setName($value); } /** * @return array[] * @throws Exception */ public function validNameDataProvider(): array { $instance = $this->getTestInstance(); return $this->getValidDataProviderByType($instance->getValidator()->getRulesByPropName('_name')); } /** * @return array[] * @throws Exception */ public function invalidNameDataProvider(): array { $instance = $this->getTestInstance(); return $this->getInvalidDataProviderByType($instance->getValidator()->getRulesByPropName('_name')); } }