RelationsInModelFinderTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 5
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 5
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testhasOneOrMany() 0 3 1
1
<?php
2
3
namespace MathieuTu\JsonSyncer\Tests;
4
5
use MathieuTu\JsonSyncer\Helpers\RelationsInModelFinder;
6
7
class RelationsInModelFinderTest extends \PHPUnit\Framework\TestCase
8
{
9
    public function testhasOneOrMany()
10
    {
11
        $this->assertEquals(['foos', 'bar'], RelationsInModelFinder::hasOneOrMany(new MyModel()));
12
    }
13
}
14
15
// phpcs:disable PSR1.Classes.ClassDeclaration.MultipleClasses
16
class MyModel extends \Illuminate\Database\Eloquent\Model
17
{
18
    public function foos()
19
    {
20
        return $this->hasMany('foo');
21
    }
22
23
    public function bar()
24
    {
25
        return $this->hasOne('bar');
26
    }
27
28
    public function baz()
29
    {
30
        return $this->hasManyThrough('baz', 'bar');
31
    }
32
33
    public function notARelation()
34
    {
35
        return 'this is not a relation!';
36
    }
37
38
    public function parent()
39
    {
40
        return $this->belongsTo('parent');
41
    }
42
}
43