Completed
Push — develop ( f34a65...a0b033 )
by Abdelrahman
02:30
created

EloquentRepositoryTests::testFindAll()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
class EloquentRepositoryTests extends \AbstractEloquentTests
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
{
5
    public function testFindAll()
6
    {
7
        $userRepository = $this->userRepository();
8
        $result         = $userRepository->findAll();
9
        $this->assertCount(2, $result);
10
        $this->assertContainsOnlyInstancesOf(\Rinvex\Tests\Stubs\EloquentUser::class, $result);
11
    }
12
13
    public function testFind()
14
    {
15
        $userRepository = $this->userRepository();
16
        $result         = $userRepository->find(1);
17
        $this->assertInstanceOf(\Rinvex\Tests\Stubs\EloquentUser::class, $result);
18
        $this->assertEquals(1, $result->id);
19
    }
20
21
    public function testFindBy()
22
    {
23
        $userRepository = $this->userRepository();
24
        $result         = $userRepository->findBy('name', 'evsign');
25
        $this->assertInstanceOf(\Rinvex\Tests\Stubs\EloquentUser::class, $result);
26
        $this->assertEquals('evsign', $result->name);
27
    }
28
29
    public function testFindFirst()
30
    {
31
        $userRepository = $this->userRepository();
32
        $result         = $userRepository->findFirst();
33
        $this->assertInstanceOf(\Rinvex\Tests\Stubs\EloquentUser::class, $result);
34
        $this->assertEquals(1, $result->id);
35
    }
36
37
    public function testFindWhere()
38
    {
39
        $userRepository = $this->userRepository();
40
        $result         = $userRepository->findWhere(['name', '=', 'omranic']);
41
        $this->assertCount(1, $result);
42
        $this->assertInstanceOf(\Illuminate\Database\Eloquent\Collection::class, $result);
43
        $this->assertContainsOnlyInstancesOf(\Rinvex\Tests\Stubs\EloquentUser::class, $result);
44
        $this->assertEquals('omranic', $result->first()->name);
45
    }
46
47
    public function testFindWhereIn()
48
    {
49
        $userRepository = $this->userRepository();
50
        $result         = $userRepository->findWhereIn(['name', ['omranic', 'evsign']]);
51
        $this->assertCount(2, $result);
52
        $this->assertInstanceOf(\Illuminate\Database\Eloquent\Collection::class, $result);
53
        $this->assertContainsOnlyInstancesOf(\Rinvex\Tests\Stubs\EloquentUser::class, $result);
54
        $this->assertEquals(['evsign', 'omranic'], $result->pluck('name')->toArray());
55
    }
56
}
57