Completed
Push — master ( 8a83ac...f28038 )
by Gabriel
04:28
created

SerializableRecordTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 15
c 1
b 0
f 1
dl 0
loc 26
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A test_magic_serialize() 0 11 1
A setUp() 0 11 1
1
<?php
2
3
namespace Nip\Records\Tests\Traits\Serializable;
4
5
use Nip\Database\Connections\Connection;
6
use Nip\Records\Record;
7
use Nip\Records\RecordManager as Records;
8
use Nip\Records\Tests\AbstractTest;
9
10
/**
11
 * Class SerializableRecordTest
12
 * @package Nip\Records\Tests\Traits\Serializable
13
 */
14
class SerializableRecordTest extends AbstractTest
15
{
16
    public function test_magic_serialize()
17
    {
18
        $this->object->property1 = 1;
0 ignored issues
show
Bug Best Practice introduced by
The property property1 does not exist on Nip\Records\Record. Since you implemented __set, consider adding a @property annotation.
Loading history...
19
        $this->object->property2 = false;
0 ignored issues
show
Bug Best Practice introduced by
The property property2 does not exist on Nip\Records\Record. Since you implemented __set, consider adding a @property annotation.
Loading history...
20
21
        $string = serialize($this->object);
22
        self::assertIsString($string);
23
24
        $object = unserialize($string);
25
        self::assertSame(1, $object->property1);
26
        self::assertSame(false, $object->property2);
27
    }
28
29
    protected function setUp()
30
    {
31
        parent::setUp();
32
        $wrapper = new Connection(false);
0 ignored issues
show
Bug introduced by
false of type false is incompatible with the type Closure|PDO expected by parameter $pdo of Nip\Database\Connections\Connection::__construct(). ( Ignorable by Annotation )

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

32
        $wrapper = new Connection(/** @scrutinizer ignore-type */ false);
Loading history...
33
34
        $manager = new Records();
35
        $manager->setDB($wrapper);
36
        $manager->setTable('pages');
37
38
        $this->object = new Record();
39
        $this->object->setManager($manager);
40
    }
41
}
42