Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BlackScorp/95418950d92a10fa12d294c0f7b030b3 to your computer and use it in GitHub Desktop.
Save BlackScorp/95418950d92a10fa12d294c0f7b030b3 to your computer and use it in GitHub Desktop.
<?php
use PHPUnit\Framework\TestCase;
abstract class AbstractEntityGetterSetterTester extends TestCase
{
protected $entity;
/**
* @dataProvider getData
*/
public function testSetterGetters($expectedValue,$property){
call_user_func_array([$this->entity,'set'.ucfirst($property)],[$expectedValue]);
$actualValue = call_user_func([$this->entity,'get'.ucfirst($property)]);
$this->assertSame($expectedValue,$actualValue);
}
abstract public function getData();
}
<?php
use BlackScorp\ORM\Entity\User;
class UserTest extends AbstractEntityGetterSetterTester
{
public function setUp(): void
{
$this->entity = new User();
}
public function getData(){
return [
'id'=>[1,'id'], //wert,methode
'username'=>['testUser','username'], //getUsername,setUsername
'password'=>['testPassword','password'],//getPassword,setPassword
];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment