prophesize(RdsDeliveryExecutionService::class); $this->classUnderTest = new RdsDeliveryExecution($serviceMock->reveal()); } /** * @param string $variableName * @param callable $validator * * @dataProvider variableProvider */ public function testGetters($variableName, $validator) { $getterMethod = 'get' . ucfirst($variableName); $this->assertTrue(method_exists($this->classUnderTest, $getterMethod)); $this->assertTrue($validator($this->classUnderTest->$getterMethod())); } /** * @param $variableName * @param $validator * @param $value * * @dataProvider variableProvider */ public function testSetters($variableName, $validator, $value) { $getterMethod = 'get' . ucfirst($variableName); $setterMethod = 'set' . ucfirst($variableName); $this->assertTrue(method_exists($this->classUnderTest, $setterMethod)); $this->classUnderTest->$setterMethod($value); $this->assertTrue($validator($this->classUnderTest->$getterMethod())); } /** * DataProvider for the variables of class under test * * @return array */ public function variableProvider() { return [ ['identifier', function ($value) { return $value === null || is_string($value); }, 'test'], ['label', function ($value) { return $value === null || is_string($value); }, 'test'], ['userIdentifier', function ($value) { return $value === null || is_string($value); }, 'test'], ['startTime', function ($value) { return $value === null || is_int($value); }, new DateTime()], ['finishTime', function ($value) { return $value === null || is_int($value); }, new DateTime()], ]; } }