setFilter() final public method

final public setFilter ( callable $filter = null )
$filter callable
Example #1
0
 public function testFilter()
 {
     $this->provider->shouldReceive('fetch')->andReturn(new \ArrayIterator(range(1, 10)));
     $records = $this->porter->import($this->specification->setFilter(function ($record) {
         return $record % 2;
     }));
     self::assertInstanceOf(PorterRecords::class, $records);
     self::assertSame([1, 3, 5, 7, 9], iterator_to_array($records));
     /** @var FilteredRecords $previous */
     self::assertInstanceOf(FilteredRecords::class, $previous = $records->getPreviousCollection());
     self::assertNotSame($previous->getFilter(), $this->specification->getFilter(), 'Filter was not cloned.');
 }
 public function testFilter()
 {
     self::assertSame($filter = [$this, __FUNCTION__], $this->specification->setFilter($filter)->getFilter());
 }