Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix withArgs method when an empty array passed. Issue #278 #279

Merged
merged 5 commits into from
Feb 24, 2014

Conversation

demsey2
Copy link
Contributor

@demsey2 demsey2 commented Feb 17, 2014

Issue #278

@@ -327,6 +327,7 @@ public function with()
*/
public function withArgs(array $args)
{
if(empty($args)) return $this->withNoArgs();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please reformat the code, so { and } are used too. It can be easily done with PhpStorm's "Reformat Code" feature.

@aik099
Copy link

aik099 commented Feb 18, 2014

@davedevelopment, build failed, but only for hhvm. Maybe you should allow failures on hhvm?

@@ -315,7 +316,11 @@ protected function _matchArg($expected, &$actual)
*/
public function with()
{
$this->_expectedArgs = func_get_args();
$args = func_get_args();
if (empty($args)) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is code duplication. Now the with method can be transformed into return $this->withArgs(func_get_args()) safely.

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling b0850d1 on demsey2:master into 619f304 on padraic:master.

@aik099
Copy link

aik099 commented Feb 18, 2014

Can you squash commits now?

@@ -339,7 +342,8 @@ public function withArgs(array $args)
public function withNoArgs()
{
$this->_noArgsExpectation = true;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hopefully nobody will do this, but if you call ->withNoArgs()->with('arg') then the $this->_noArgsExpectation flag won't be reset. Maybe we should reset that flag to false when passing in valid argument list?

Is it ok, @davedevelopment ?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I'm guessing such type of protection isn't needed.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was under the impression it was fixed by 833f511

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed it was. Never saw that. I personally always reply to inline code comments when I implement wasn't been asked there. This way it's easier.

Always doing a squash before PR merging is good idea, since having 5 commits in main repo just to change 2 small methods doesn't make commit history cleaner.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Squashing doesn't really interest me, unless the history is really messy.
We have merge commits, they're good enough for me.
On 25 Feb 2014 12:28, "Alexander Obuhovich" notifications@github.com
wrote:

In library/Mockery/Expectation.php:

@@ -339,7 +342,8 @@ public function withArgs(array $args)
public function withNoArgs()
{
$this->_noArgsExpectation = true;

It was. Never saw that. I personally always reply to inline code comments
when I implement wasn't been asked there. This way it's easier.

Always doing a squash before PR merging is good idea, since having 5
commits in main repo just to change 2 small methods doesn't make commit
history cleaner.


Reply to this email directly or view it on GitHubhttps://github.com//pull/279/files#r10033466
.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) when pulling 833f511 on demsey2:master into 619f304 on padraic:master.

davedevelopment added a commit that referenced this pull request Feb 24, 2014
Fix withArgs method when an empty array passed. Issue #278
@davedevelopment davedevelopment merged commit 4ce6f30 into mockery:master Feb 24, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants