This repository was archived by the owner on Apr 17, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 150
Expand file tree
/
Copy pathBaseEngineTest.php
More file actions
113 lines (79 loc) · 3.03 KB
/
BaseEngineTest.php
File metadata and controls
113 lines (79 loc) · 3.03 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?php
use Chumper\Datatable\Engines\CollectionEngine;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Input;
use Orchestra\Testbench\TestCase;
use Illuminate\Support\Facades\Config;
class BaseEngineTest extends TestCase {
private $collection;
/**
* @var CollectionEngine
*/
private $engine;
public function setUp()
{
// set up config
Config::shouldReceive('get')->zeroOrMoreTimes()->with("chumper_datatable.engine")->andReturn(
array(
'exactWordSearch' => false,
)
);
$this->collection = new Collection();
$this->engine = new CollectionEngine($this->collection);
}
/**
* @expectedException Exception
*/
public function testAddColumn()
{
$this->engine->addColumn('foo', 'bar');
$this->assertInstanceOf(
'Chumper\Datatable\Columns\TextColumn',
$this->engine->getColumn('foo')
);
$this->engine->addColumn('foo2', function($model){return $model->fooBar;});
$this->assertInstanceOf(
'Chumper\Datatable\Columns\FunctionColumn',
$this->engine->getColumn('foo2')
);
$this->assertEquals(array(1 => 'foo2', 0 => 'foo'), $this->engine->getOrder());
$this->engine->addColumn();
}
public function testClearColumns()
{
$this->engine->addColumn('foo','Bar');
$this->assertInstanceOf(
'Chumper\Datatable\Columns\TextColumn',
$this->engine->getColumn('foo')
);
$this->engine->clearColumns();
$this->assertEquals(array(), $this->engine->getOrder());
}
public function testSearchColumns()
{
$this->engine->searchColumns('id');
$this->assertEquals(array('id'), $this->engine->getSearchingColumns());
$this->engine->searchColumns('name', 'email');
$this->assertEquals(array('name','email'), $this->engine->getSearchingColumns());
$this->engine->searchColumns(array('foo', 'bar'));
$this->assertEquals(array('foo', 'bar'), $this->engine->getSearchingColumns());
}
public function testOrderColumns()
{
$this->engine->orderColumns('id');
$this->assertEquals(array('id'), $this->engine->getOrderingColumns());
$this->engine->orderColumns('name', 'email');
$this->assertEquals(array('name','email'), $this->engine->getOrderingColumns());
$this->engine->orderColumns(array('foo', 'bar'));
$this->assertEquals(array('foo', 'bar'), $this->engine->getOrderingColumns());
}
public function testShowColumns()
{
$this->engine->showColumns('id');
$this->assertEquals(array('id'), $this->engine->getOrder());
$this->engine->showColumns('name', 'email');
$this->assertEquals(array('id','name','email'), $this->engine->getOrder());
$this->engine->showColumns(array('foo', 'bar'));
$this->assertEquals(array('id','name','email', 'foo', 'bar'), $this->engine->getOrder());
}
}