There is the following test. On my computer, the test works OK. On a computer of another developer, the testRoleDictFields method gives an error:
Argument # 2 (No Value) of PHPUnit_Framework_Assert :: assertObjectHasAttribute () must be a object
Those. $dict is not passed to it. The settings and versions of php, PHPUnit, config file and bootstrap are identical on both computers. What else could I miss?
class RolesDictTest extends \PHPUnit_Framework_TestCase { public function testRoleDictGetById() { $dict = Dicts\Role::getByID(330); $this->assertInstanceOf(Dicts\Role::class, $dict); return $dict; } /** * @depends testRoleDictGetById * * @param $dict Dicts\Role */ public function testRoleDictFields($dict) { $this->assertObjectHasAttribute('id', $dict, 'Field "id" not defined'); $this->assertObjectHasAttribute('code', $dict, 'Field "code" not defined'); $this->assertObjectHasAttribute('name', $dict, 'Field "name" not defined'); $this->assertObjectHasAttribute('active', $dict, 'Field "active" not defined'); $this->assertObjectHasAttribute('sort', $dict, 'Field "sort" not defined'); } } UPD. I tried to rewrite the test using the provider.
Now the test looks like this:
class RolesDictTest extends \PHPUnit_Framework_TestCase { /** * @dataProvider rolesIdProvider * * @param $dict Dicts\Role */ public function testRoleDictClass($dict) { $this->assertInstanceOf(Dicts\Role::class, $dict); } /** * @dataProvider rolesIdProvider * @depends testRoleDictClass * * @param $dict Dicts\Role */ public function testRoleDictFields($dict) { $this->assertObjectHasAttribute('id', $dict, 'Field "id" not defined'); $this->assertObjectHasAttribute('code', $dict, 'Field "code" not defined'); $this->assertObjectHasAttribute('name', $dict, 'Field "name" not defined'); $this->assertObjectHasAttribute('active', $dict, 'Field "active" not defined'); $this->assertObjectHasAttribute('sort', $dict, 'Field "sort" not defined'); } public function rolesIdProvider() { return [ 'with ID#330' => [Dicts\Role::getByID(330)], 'with ID#331' => [Dicts\Role::getByID(331)], 'with ID#333' => [Dicts\Role::getByID(333)], ]; } } The result is the same. Everything is OK on my computer. On another, testRoleDictFields does not receive input data.