This repository was archived by the owner on Aug 8, 2019. It is now read-only.
File tree 2 files changed +26
-6
lines changed 2 files changed +26
-6
lines changed Original file line number Diff line number Diff line change @@ -947,10 +947,10 @@ static public function __callStatic($method, $args)
947
947
/**
948
948
* Assert that the count of countable is equal to count.
949
949
*
950
- * @param mixed $countable
951
- * @param int $count
952
- * @param string $message
953
- * @param string $propertyPath
950
+ * @param array|\Countable $countable
951
+ * @param int $count
952
+ * @param string $message
953
+ * @param string $propertyPath
954
954
* @return void
955
955
* @throws \Assert\AssertionFailedException
956
956
*/
Original file line number Diff line number Diff line change @@ -821,16 +821,36 @@ public function testAllWithNoValueThrows()
821
821
public function testValidCount ()
822
822
{
823
823
Assertion::count (array ('Hi ' ), 1 );
824
+ Assertion::count (new OneCountable (), 1 );
824
825
}
825
826
826
- public function testInvalidCount ()
827
+ public static function dataInvalidCount ()
828
+ {
829
+ return array (
830
+ array (array ('Hi ' , 'There ' ), 3 ),
831
+ array (new OneCountable (), 2 ),
832
+ );
833
+ }
834
+
835
+ /**
836
+ * @dataProvider dataInvalidCount
837
+ */
838
+ public function testInvalidCount ($ countable , $ count )
827
839
{
828
840
$ this ->setExpectedException ('Assert\AssertionFailedException ' , null , Assertion::INVALID_COUNT );
829
- Assertion::count (array ( ' Hi ' , ' there ' ), 1 );
841
+ Assertion::count ($ countable , $ count );
830
842
}
831
843
}
832
844
833
845
class ChildStdClass extends \stdClass
834
846
{
835
847
836
848
}
849
+
850
+ class OneCountable implements \Countable
851
+ {
852
+ public function count ()
853
+ {
854
+ return 1 ;
855
+ }
856
+ }
You can’t perform that action at this time.
0 commit comments