File tree Expand file tree Collapse file tree 1 file changed +61
-0
lines changed Expand file tree Collapse file tree 1 file changed +61
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace ViewComponents \Eloquent \Test ;
4+
5+ use PHPUnit_Framework_TestCase ;
6+ use ViewComponents \Eloquent \EloquentDataProvider ;
7+ use ViewComponents \Eloquent \Test \Mock \TestUser ;
8+ use ViewComponents \TestingHelpers \Test \DefaultFixture ;
9+ use Illuminate \Database \Capsule \Manager as DB ;
10+
11+ class DataSourceSupportTest extends PHPUnit_Framework_TestCase
12+ {
13+ public function testNewEloquentBuilder ()
14+ {
15+ $ provider = new EloquentDataProvider ((new TestUser ())->newQuery ());
16+ self ::assertEquals (
17+ DefaultFixture::getTotalCount (),
18+ $ provider ->count ()
19+ );
20+ }
21+
22+ public function testEloquentBuilderWithPreCondition ()
23+ {
24+ $ provider = new EloquentDataProvider (TestUser::where ('name ' , '= ' , 'David ' ));
25+ self ::assertEquals (
26+ 1 ,
27+ $ provider ->count ()
28+ );
29+ }
30+
31+ public function testModelName ()
32+ {
33+ $ provider = new EloquentDataProvider (TestUser::class);
34+ self ::assertEquals (
35+ DefaultFixture::getTotalCount (),
36+ $ provider ->count ()
37+ );
38+ }
39+
40+ public function testDatabaseQueryBuilder ()
41+ {
42+ $ provider = new EloquentDataProvider (DB ::table ('test_users ' ));
43+ self ::assertEquals (
44+ DefaultFixture::getTotalCount (),
45+ $ provider ->count ()
46+ );
47+ }
48+
49+ public function testDatabaseQueryBuilderWithPreCondition ()
50+ {
51+ $ provider = new EloquentDataProvider (
52+ DB
53+ ::table ('test_users ' )
54+ ->where ('name ' , '= ' , 'David ' )
55+ );
56+ self ::assertEquals (
57+ 1 ,
58+ $ provider ->count ()
59+ );
60+ }
61+ }
You can’t perform that action at this time.
0 commit comments