Skip to content

Commit 2362659

Browse files
fix tests
1 parent 5380c45 commit 2362659

File tree

5 files changed

+34
-57
lines changed

5 files changed

+34
-57
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
},
4343
"autoload-dev": {
4444
"psr-4": {
45-
"Tests\\" : "tests/"
45+
"PowerComponents\\LivewirePowerGrid\\Tests\\" : "tests/"
4646
}
4747
}
4848
}

tests/Feature/PowerGridComponentFilterNameOptionsTest.php

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22

33
use Illuminate\Database\Eloquent\Collection;
44
use Illuminate\Database\Eloquent\Model;
5-
use PowerComponents\LivewirePowerGrid\PowerGrid;
65
use PowerComponents\LivewirePowerGrid\PowerGridComponent;
76

87
beforeEach(function () {
98
$this->component = new PowerGridComponent;
9+
$this->columns = [
10+
'id',
11+
'name'
12+
];
1013
});
1114

1215
it('clean filters', function () {
@@ -24,13 +27,6 @@
2427

2528
it('properly filters by "name is"', function () {
2629

27-
/*
28-
$pg = new PowerGridComponent();
29-
$filters = $pg->filters;
30-
$model = Dish::query();
31-
32-
*/
33-
3430
$data = new Collection([
3531
new ModelStub([
3632
'id' => '1',
@@ -51,7 +47,12 @@
5147
]
5248
];
5349

54-
$filtered = \PowerComponents\LivewirePowerGrid\Helpers\Collection::filter($this->component->filters, $data);
50+
$filtered = \PowerComponents\LivewirePowerGrid\Helpers\Collection::query($data)
51+
->setColumns($this->columns)
52+
->setSearch('')
53+
->setFilters($this->component->filters)
54+
->filterContains()
55+
->filter();
5556

5657
$this->assertCount(1,$filtered);
5758
$this->AssertEquals($filtered->first()->name, 'john');
@@ -78,7 +79,12 @@
7879
]
7980
];
8081

81-
$filtered = \PowerComponents\LivewirePowerGrid\Helpers\Collection::filter($this->component->filters, $data);
82+
$filtered = \PowerComponents\LivewirePowerGrid\Helpers\Collection::query($data)
83+
->setColumns($this->columns)
84+
->setSearch('')
85+
->setFilters($this->component->filters)
86+
->filterContains()
87+
->filter();
8288
$this->assertEmpty($filtered);
8389
});
8490

@@ -103,7 +109,12 @@
103109
]
104110
];
105111

106-
$filtered = \PowerComponents\LivewirePowerGrid\Helpers\Collection::filter($this->component->filters, $data);
112+
$filtered = \PowerComponents\LivewirePowerGrid\Helpers\Collection::query($data)
113+
->setColumns($this->columns)
114+
->setSearch('')
115+
->setFilters($this->component->filters)
116+
->filterContains()
117+
->filter();
107118

108119
$this->assertCount(1, $filtered);
109120
$this->AssertEquals($filtered->first()->name, 'john smith');
@@ -130,7 +141,12 @@
130141
]
131142
];
132143

133-
$filtered = \PowerComponents\LivewirePowerGrid\Helpers\Collection::filter($this->component->filters, $data);
144+
$filtered = \PowerComponents\LivewirePowerGrid\Helpers\Collection::query($data)
145+
->setColumns($this->columns)
146+
->setSearch('')
147+
->setFilters($this->component->filters)
148+
->filterContains()
149+
->filter();
134150

135151
$this->assertCount(2, $filtered);
136152
});

tests/Feature/PowerGridTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?php
22

3-
namespace PowerComponents\LivewirePowerGrid\Tests;
3+
namespace PowerComponents\LivewirePowerGrid\Tests\Feature;
44

55
use Illuminate\Database\Eloquent\Collection;
66
use Illuminate\Database\Eloquent\Model;
7-
use Tests\TestCase;
87
use PowerComponents\LivewirePowerGrid\PowerGrid;
8+
use PowerComponents\LivewirePowerGrid\Tests\TestCase;
99

1010
class PowerGridTest extends TestCase
1111
{

tests/Pest.php

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,9 @@
11
<?php
22

3-
use SebastianBergmann\CodeCoverage\Report\Xml\Tests;
3+
use Orchestra\Testbench\TestCase;
44

5-
/*
6-
|--------------------------------------------------------------------------
7-
| Test Case
8-
|--------------------------------------------------------------------------
9-
|
10-
| The closure you provide to your test functions is always bound to a specific PHPUnit test
11-
| case class. By default, that class is "PHPUnit\Framework\TestCase". Of course, you may
12-
| need to change it using the "uses()" function to bind a different classes or traits.
13-
|
14-
*/
15-
16-
uses(\Orchestra\Testbench\TestCase::class)->in(__DIR__);
17-
18-
/*
19-
|--------------------------------------------------------------------------
20-
| Expectations
21-
|--------------------------------------------------------------------------
22-
|
23-
| When you're writing tests, you often need to check that values meet certain conditions. The
24-
| "expect()" function gives you access to a set of "expectations" methods that you can use
25-
| to assert different things. Of course, you may extend the Expectation API at any time.
26-
|
27-
*/
5+
uses(TestCase::class)->in(__DIR__);
286

297
expect()->extend('toBeOne', function () {
308
return $this->toBe(1);
319
});
32-
33-
/*
34-
|--------------------------------------------------------------------------
35-
| Functions
36-
|--------------------------------------------------------------------------
37-
|
38-
| While Pest is very powerful out-of-the-box, you may have some testing code specific to your
39-
| project that you don't want to repeat in every file. Here you can also expose helpers as
40-
| global functions to help you to reduce the number of lines of code in your test files.
41-
|
42-
*/
43-
44-
function something()
45-
{
46-
// ..
47-
}

tests/TestCase.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
<?php
22

3-
namespace Tests;
3+
namespace PowerComponents\LivewirePowerGrid\Tests;
44

55
use PowerComponents\LivewirePowerGrid\Providers\PowerGridServiceProvider;
66

77
class TestCase extends \Orchestra\Testbench\TestCase
88
{
99
protected function getPackageProviders($app)
1010
{
11-
1211
return [
1312
PowerGridServiceProvider::class
1413
];

0 commit comments

Comments
 (0)