I am new to PHPunit and while learning it with sample classes, I am getting error. The error is that, the Object $this->sysman, that is initialized in setUp() becomes null after execution of the 1st test. Below is code, which I am trying. Please let me know what is mistake here. Thanks.
class PersonTest extends TestCase {
/** @var SysManService $sysman */
protected $sysman;
protected $personModel;
public function setUp(){
/** @var Adapter $adapter */
$adapter = $this->prophesize(Adapter::class)->reveal();
/** @var LoggerService $logger */
$logger = $this->prophesize(LoggerService::class)->reveal();
/** @var ContainerInterface $container */
$container = $this->prophesize(ContainerInterface::class);
$config = (array)$container->get('config');
$this->sysman = new SysManService($adapter, $logger, $config);
//$sysman = new SysManService($adapter, $logger, $config);
$this->personModel = new Person($this->sysman);
}
protected function tearDown(){ }
public function testPropertyUserNameExists() {
$this->assertObjectHasAttribute('userName', $this->personModel);
}
public function testPropertyPasswordExists() {
$this->assertObjectHasAttribute('password', $this->personModel);
}}