Skip to content

Added shortcut to get a PHPUnit_Framework_Constraint_Count instance #628

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

Merged
merged 1 commit into from
May 17, 2013

Conversation

amenk
Copy link

@amenk amenk commented Aug 28, 2012

No description provided.

* @param int $count
* @return PHPUnit_Framework_Constraint_Count
*/
public static function arrayCount($count)

Choose a reason for hiding this comment

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

The name arrayCount() is wrong as objects that implement the Countable interface are also handled by PHPUnit_Framework_Constraint_Count.

@amenk
Copy link
Author

amenk commented Aug 31, 2012

Okay ... and suggestion for another name?

@edorian
Copy link
Contributor

edorian commented Aug 31, 2012

I don't really have a good idea. just count is not really pretty ether and hasExactlyElements($count) reads really ugly too

contains already has meaning.

Maybe something with size. ->with($this->size(5))-> could be readable. Not sure

@whatthejeff
Copy link
Contributor

I like count as it's consistent with count(), assertCount(), Countable, PHPUnit_Framework_Constraint_Count, etc.

@havvg
Copy link

havvg commented Mar 28, 2013

I won't use count as it would collide with \Countable if implemented on a sub class of PHPUnit_Framework_Assert.

How about counts or isCountOf, those comply with isEmpty, fileExists, stringContains etc.

@whatthejeff
Copy link
Contributor

I won't use count as it would collide with \Countable if implemented on a sub class of PHPUnit_Framework_Assert.

Good point :)

How about counts or isCountOf, those comply with isEmpty, fileExists, stringContains etc.

What about countOf? I think that would be more readable when used with the fluent interface:

$stub->expects($this->once())
     ->method('bar')
     ->with($this->countOf(5));

@marijn
Copy link

marijn commented Apr 16, 2013

countOf 👍

@whatthejeff
Copy link
Contributor

Any update on this @havvg?

@whatthejeff
Copy link
Contributor

I'm just going to merge this and call it countOf as there's been no response in 2 months.

whatthejeff added a commit that referenced this pull request May 17, 2013
@whatthejeff whatthejeff merged commit ed2eb77 into sebastianbergmann:master May 17, 2013
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.

6 participants