Mockery params are passed to function
up vote
0
down vote
favorite
I have same problem with testing
public function testReturnUser()
$faker = Factory::create();
$user = new User($faker->userName, $faker->email);
$mockFinder = Mockery::mock(ClassFinder::class);
$mockFinder->shouldReceive('find')
->with(User::class, 1)
->andReturn($user);
$helper = new Helper($mockFinder);
$this->assertEquals([$user], $helper->getMethod(User::class));
and in Helper class
class Helper
private $finder;
public function __constructor(ClassFinder $finder)
$this->finder = $finder;
public function getMethod(string $className, array $data =)
return $this->finder->find($className, $data['id']);
So problem is when i call getMethod
without second optional parameter and run test I getting that $data['id']
is invalid index,
although i pass params to Mock object. So if someone knows why this is happend?
php testing mocking mockery
add a comment |
up vote
0
down vote
favorite
I have same problem with testing
public function testReturnUser()
$faker = Factory::create();
$user = new User($faker->userName, $faker->email);
$mockFinder = Mockery::mock(ClassFinder::class);
$mockFinder->shouldReceive('find')
->with(User::class, 1)
->andReturn($user);
$helper = new Helper($mockFinder);
$this->assertEquals([$user], $helper->getMethod(User::class));
and in Helper class
class Helper
private $finder;
public function __constructor(ClassFinder $finder)
$this->finder = $finder;
public function getMethod(string $className, array $data =)
return $this->finder->find($className, $data['id']);
So problem is when i call getMethod
without second optional parameter and run test I getting that $data['id']
is invalid index,
although i pass params to Mock object. So if someone knows why this is happend?
php testing mocking mockery
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have same problem with testing
public function testReturnUser()
$faker = Factory::create();
$user = new User($faker->userName, $faker->email);
$mockFinder = Mockery::mock(ClassFinder::class);
$mockFinder->shouldReceive('find')
->with(User::class, 1)
->andReturn($user);
$helper = new Helper($mockFinder);
$this->assertEquals([$user], $helper->getMethod(User::class));
and in Helper class
class Helper
private $finder;
public function __constructor(ClassFinder $finder)
$this->finder = $finder;
public function getMethod(string $className, array $data =)
return $this->finder->find($className, $data['id']);
So problem is when i call getMethod
without second optional parameter and run test I getting that $data['id']
is invalid index,
although i pass params to Mock object. So if someone knows why this is happend?
php testing mocking mockery
I have same problem with testing
public function testReturnUser()
$faker = Factory::create();
$user = new User($faker->userName, $faker->email);
$mockFinder = Mockery::mock(ClassFinder::class);
$mockFinder->shouldReceive('find')
->with(User::class, 1)
->andReturn($user);
$helper = new Helper($mockFinder);
$this->assertEquals([$user], $helper->getMethod(User::class));
and in Helper class
class Helper
private $finder;
public function __constructor(ClassFinder $finder)
$this->finder = $finder;
public function getMethod(string $className, array $data =)
return $this->finder->find($className, $data['id']);
So problem is when i call getMethod
without second optional parameter and run test I getting that $data['id']
is invalid index,
although i pass params to Mock object. So if someone knows why this is happend?
php testing mocking mockery
php testing mocking mockery
asked Nov 10 at 0:00
squareCircle
1117
1117
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53234791%2fmockery-params-are-passed-to-function%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown