Passed
Push — master ( 94b014...e2ddcf )
by Petr
07:02
created

ClassTest::testInit()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 8
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 10
rs 10
1
<?php
2
3
namespace BasicTests;
4
5
6
use CommonTestClass;
7
use kalanis\kw_locks\LockException;
8
use kalanis\kw_locks\Methods\ClassLock;
9
use kalanis\kw_locks\Methods\StorageLock;
10
use kalanis\kw_storage\Storage\Target\Memory;
11
12
13
class ClassTest extends CommonTestClass
14
{
15
    /**
16
     * @throws LockException
17
     */
18
    public function testInit(): void
19
    {
20
        $lib = $this->getPassLib();
21
        $lib->setClass(new Memory()); // not need too many things
22
        $this->assertFalse($lib->has()); // nothing now
23
        $this->assertTrue($lib->create()); // new one
24
        $this->assertFalse($lib->create()); // already has
25
        $this->assertTrue($lib->has());
26
        $this->assertTrue($lib->delete()); // delete current
27
        $this->assertFalse($lib->has()); // nothing here
28
    }
29
30
    protected function getPassLib(): ClassLock
31
    {
32
        return new ClassLock(new StorageLock(new \XStorage()));
33
    }
34
}
35