Passed
Pull Request — master (#1312)
by Michael
09:02 queued 02:55
created

test___publicProperties()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 6
c 1
b 0
f 0
nc 3
nop 0
dl 0
loc 9
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
//namespace Xoops\Tests\Database;
6
7
use PHPUnit\Framework\TestCase;
0 ignored issues
show
Bug introduced by
The type PHPUnit\Framework\TestCase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
9
require_once dirname(__DIR__) . '/init_new.php';
10
11
require_once(XOOPS_TU_ROOT_PATH . '/class/logger/xoopslogger.php');
12
require_once(XOOPS_TU_ROOT_PATH . '/class/xoopsload.php');
13
require_once(XOOPS_TU_ROOT_PATH . '/class/preload.php');
14
require_once(XOOPS_TU_ROOT_PATH . '/class/database/databasefactory.php');
15
16
require_once(XOOPS_TU_ROOT_PATH . '/kernel/object.php');
17
18
class XoopsPersistableObjectHandlerTestInstance extends \XoopsPersistableObjectHandler
19
{
20
    // allow access to the protected function in abstract class
21
    public function __construct(
22
        \XoopsDatabase $db,
23
                                        $table = '',
24
                                        $className = '',
25
                                        $keyName = '',
26
                                        $identifierName = ''
27
    ) {
28
        parent::__construct($db, $table, $className, $keyName, $identifierName);
29
    }
30
}
31
32
class XoopsPersistableObjectHandlerTest extends TestCase
33
{
34
    protected $myclass = 'XoopsPersistableObjectHandlerTestInstance';
35
36
    public function test___publicProperties()
37
    {
38
        $items = ['db'];
39
        foreach ($items as $item) {
40
            try {
41
                $prop = new ReflectionProperty($this->myclass, $item);
42
            } catch (ReflectionException $e) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
43
            }
44
            $this->assertTrue($prop->isPublic());
45
        }
46
    }
47
48
    public function test___construct()
49
    {
50
        $conn           = \XoopsDatabaseFactory::getDatabaseConnection();
51
        $table          = 'table';
52
        $className      = 'className';
53
        $keyName        = 'keyName';
54
        $identifierName = 'identifierName';
55
        $instance       = new $this->myclass($conn, $table, $className, $keyName, $identifierName);
56
        $this->assertInstanceOf($this->myclass, $instance);
57
        $this->assertInstanceOf(\XoopsPersistableObjectHandler::class, $instance);
58
    }
59
}
60