-
Notifications
You must be signed in to change notification settings - Fork 124
Expand file tree
/
Copy pathOffsetFilterTest.php
More file actions
69 lines (58 loc) · 1.98 KB
/
Copy pathOffsetFilterTest.php
File metadata and controls
69 lines (58 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
namespace Ddeboer\DataImport\Filter;
use Ddeboer\DataImport\Filter\OffsetFilter;
/**
* @author Ville Mattila <ville@eventio.fi>
*/
class OffsetFilterTest extends \PHPUnit_Framework_TestCase
{
private function applyFilter(OffsetFilter $filter, array $items) {
$result = array();
foreach ($items as $item) {
if (true === call_user_func($filter, array($item))) {
$result[] = $item;
}
}
return $result;
}
public function testDefaultFilter()
{
$items = array('first','second','third','fourth');
$resultItems = $this->applyFilter(new OffsetFilter(), $items);
$this->assertEquals($resultItems, $items);
}
public function testStartOffset()
{
$items = array('first','second','third','fourth');
$resultItems = $this->applyFilter(new OffsetFilter(1), $items);
$this->assertEquals($resultItems, array('second','third','fourth'));
}
public function testMaxCount()
{
$items = array('first','second','third','fourth');
$resultItems = $this->applyFilter(new OffsetFilter(0, 2), $items);
$this->assertEquals($resultItems, array('first','second'));
}
public function testOffsetWithMaxCount()
{
$items = array('first','second','third','fourth');
$resultItems = $this->applyFilter(new OffsetFilter(1, 1), $items);
$this->assertEquals($resultItems, array('second'));
}
/**
* @expectedException \Ddeboer\DataImport\Exception\StopException
*/
public function testMaxCountStop()
{
$items = array('first','second','third','fourth');
$this->applyFilter(new OffsetFilter(0, 2, true), $items);
}
/**
* @expectedException \Ddeboer\DataImport\Exception\StopException
*/
public function testOffsetWithMaxCountStop()
{
$items = array('first','second','third','fourth');
$this->applyFilter(new OffsetFilter(1, 1, true), $items);
}
}