Passed
Push — master ( 8cf9c5...df1ad3 )
by Guillermo A.
02:14
created

ModelTest::testOffsetUnset()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace GuillermoandraeTest\Models;
4
5
use PHPUnit\Framework\TestCase;
6
use Guillermoandrae\Models\AbstractModel;
7
8
class ModelTest extends TestCase
9
{
10
    public function testOffsetGet()
11
    {
12
        $data = ['hey' => 'there', 'us' => 'them'];
13
        $model = $this->getMockForAbstractClass(AbstractModel::class, [$data]);
14
        $this->assertSame('there', $model['hey']);
15
    }
16
17
    public function testOffsetSet()
18
    {
19
        $data = ['hey' => 'there'];
20
        $model = $this->getMockForAbstractClass(AbstractModel::class, [$data]);
21
        $model['you'] = 'two';
22
        $this->assertSame('two', $model['you']);
23
    }
24
25
    public function testOffsetSetNullOffset()
26
    {
27
        $model = $this->getMockForAbstractClass(AbstractModel::class);
28
        $model[] = 'two';
29
        $this->assertSame('two', $model[0]);
30
    }
31
    
32
    public function testOffsetUnset()
33
    {
34
        $data = ['hey' => 'there', 'me' => 'you'];
35
        $model = $this->getMockForAbstractClass(AbstractModel::class, [$data]);
36
        unset($model['me']);
37
        $this->assertNull($model['me']);
38
    }
39
40
    public function testToJson()
41
    {
42
        $model = $this->getMockForAbstractClass(AbstractModel::class);
43
        $this->assertSame(json_encode($model->toArray()), $model->toJson());
0 ignored issues
show
Bug introduced by
The method toJson() does not exist on PHPUnit\Framework\MockObject\MockObject. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

43
        $this->assertSame(json_encode($model->toArray()), $model->/** @scrutinizer ignore-call */ toJson());

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Bug introduced by
The method toArray() does not exist on PHPUnit\Framework\MockObject\MockObject. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

43
        $this->assertSame(json_encode($model->/** @scrutinizer ignore-call */ toArray()), $model->toJson());

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
44
    }
45
}
46