Skip to content

Commit

Permalink
Remove use of TestCase::getMock() from "Collection" namepace tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Jun 4, 2016
1 parent 3270507 commit ee02ce9
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 12 deletions.
49 changes: 39 additions & 10 deletions tests/TestCase/Collection/CollectionTest.php
Expand Up @@ -82,7 +82,9 @@ public function testEeach()
{
$items = ['a' => 1, 'b' => 2, 'c' => 3];
$collection = new Collection($items);
$callable = $this->getMock('stdClass', ['__invoke']);
$callable = $this->getMockBuilder(\StdClass::class)
->setMethods(['__invoke'])
->getMock();
$callable->expects($this->at(0))
->method('__invoke')
->with(1, 'a');
Expand Down Expand Up @@ -118,7 +120,10 @@ public function testFilterChaining()
{
$items = ['a' => 1, 'b' => 2, 'c' => 3];
$collection = new Collection($items);
$callable = $this->getMock('stdClass', ['__invoke']);
$callable = $this->getMockBuilder(\StdClass::class)
->setMethods(['__invoke'])
->getMock();

$callable->expects($this->once())
->method('__invoke')
->with(3, 'c');
Expand Down Expand Up @@ -156,7 +161,10 @@ public function testEveryReturnTrue()
{
$items = ['a' => 1, 'b' => 2, 'c' => 3];
$collection = new Collection($items);
$callable = $this->getMock('stdClass', ['__invoke']);
$callable = $this->getMockBuilder(\StdClass::class)
->setMethods(['__invoke'])
->getMock();

$callable->expects($this->at(0))
->method('__invoke')
->with(1, 'a')
Expand All @@ -181,7 +189,10 @@ public function testEveryReturnFalse()
{
$items = ['a' => 1, 'b' => 2, 'c' => 3];
$collection = new Collection($items);
$callable = $this->getMock('stdClass', ['__invoke']);
$callable = $this->getMockBuilder(\StdClass::class)
->setMethods(['__invoke'])
->getMock();

$callable->expects($this->at(0))
->method('__invoke')
->with(1, 'a')
Expand All @@ -195,7 +206,10 @@ public function testEveryReturnFalse()

$items = [];
$collection = new Collection($items);
$callable = $this->getMock('stdClass', ['__invoke']);
$callable = $this->getMockBuilder(\StdClass::class)
->setMethods(['__invoke'])
->getMock();

$callable->expects($this->never())
->method('__invoke');
$this->assertFalse($collection->every($callable));
Expand All @@ -210,7 +224,10 @@ public function testSomeReturnTrue()
{
$items = ['a' => 1, 'b' => 2, 'c' => 3];
$collection = new Collection($items);
$callable = $this->getMock('stdClass', ['__invoke']);
$callable = $this->getMockBuilder(\StdClass::class)
->setMethods(['__invoke'])
->getMock();

$callable->expects($this->at(0))
->method('__invoke')
->with(1, 'a')
Expand All @@ -232,7 +249,10 @@ public function testSomeReturnFalse()
{
$items = ['a' => 1, 'b' => 2, 'c' => 3];
$collection = new Collection($items);
$callable = $this->getMock('stdClass', ['__invoke']);
$callable = $this->getMockBuilder(\StdClass::class)
->setMethods(['__invoke'])
->getMock();

$callable->expects($this->at(0))
->method('__invoke')
->with(1, 'a')
Expand Down Expand Up @@ -289,7 +309,10 @@ public function testReduceWithInitialValue()
{
$items = ['a' => 1, 'b' => 2, 'c' => 3];
$collection = new Collection($items);
$callable = $this->getMock('stdClass', ['__invoke']);
$callable = $this->getMockBuilder(\StdClass::class)
->setMethods(['__invoke'])
->getMock();

$callable->expects($this->at(0))
->method('__invoke')
->with(10, 1, 'a')
Expand All @@ -314,7 +337,10 @@ public function testReduceWithoutInitialValue()
{
$items = ['a' => 1, 'b' => 2, 'c' => 3, 'd' => 4];
$collection = new Collection($items);
$callable = $this->getMock('stdClass', ['__invoke']);
$callable = $this->getMockBuilder(\StdClass::class)
->setMethods(['__invoke'])
->getMock();

$callable->expects($this->at(0))
->method('__invoke')
->with(1, 2, 'b')
Expand Down Expand Up @@ -759,7 +785,10 @@ public function testCompile()
{
$items = ['a' => 1, 'b' => 2, 'c' => 3];
$collection = new Collection($items);
$callable = $this->getMock('stdClass', ['__invoke']);
$callable = $this->getMockBuilder(\StdClass::class)
->setMethods(['__invoke'])
->getMock();

$callable->expects($this->at(0))
->method('__invoke')
->with(1, 'a')
Expand Down
4 changes: 3 additions & 1 deletion tests/TestCase/Collection/Iterator/FilterIteratorTest.php
Expand Up @@ -32,7 +32,9 @@ class FilterIteratorTest extends TestCase
public function testFilter()
{
$items = new \ArrayIterator([1, 2, 3]);
$callable = $this->getMock('stdClass', ['__invoke']);
$callable = $this->getMockBuilder(\StdClass::class)
->setMethods(['__invoke'])
->getMock();
$callable->expects($this->at(0))
->method('__invoke')
->with(1, 0, $items)
Expand Down
4 changes: 3 additions & 1 deletion tests/TestCase/Collection/Iterator/ReplaceIteratorTest.php
Expand Up @@ -32,7 +32,9 @@ class ReplaceIteratorTest extends TestCase
public function testReplace()
{
$items = new \ArrayIterator([1, 2, 3]);
$callable = $this->getMock('stdClass', ['__invoke']);
$callable = $this->getMockBuilder(\StdClass::class)
->setMethods(['__invoke'])
->getMock();
$callable->expects($this->at(0))
->method('__invoke')
->with(1, 0, $items)
Expand Down

0 comments on commit ee02ce9

Please sign in to comment.