Created
May 8, 2021 18:36
-
-
Save BlackScorp/95418950d92a10fa12d294c0f7b030b3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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