• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

The-oGlow / ezlogging / 17456967516

04 Sep 2025 07:43AM UTC coverage: 83.249%. Remained the same
17456967516

push

github

ollily
update analysis files

164 of 197 relevant lines covered (83.25%)

7.29 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

12.9
/src/PHPUnit/Framework/EasyGoingTestCase.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of ezlogging
7
 *
8
 * (c) 2025 Oliver Glowa, coding.glowa.com
9
 *
10
 * This source file is subject to the Apache-2.0 license that is bundled
11
 * with this source code in the file LICENSE.
12
 */
13

14
namespace PHPUnit\Framework;
15

16
use Monolog\ConsoleLogger;
17

18
abstract class EasyGoingTestCase extends TestCase
19
{
20
    /** @var \Monolog\Logger */
21
    protected $logger;
22

23
    /** @var mixed */
24
    protected $o2t;
25

26
    public function setUp(): void
2✔
27
    {
28
        parent::setUp();
2✔
29
        $this->logger = new ConsoleLogger(self::class);
2✔
30
        $this->o2t    = $this->prepareO2t();
2✔
31
    }
32

33
    /**
34
     * @return mixed
35
     */
36
    abstract protected function prepareO2t();
37

38
    /**
39
     * @return mixed
40
     */
41
    abstract protected function getCasto2t();
42

43
    /**
44
     * @param mixed[] $constants
45
     */
46
    protected function verifyConstAllExists(array $constants = []): void
×
47
    {
48
        foreach ($constants as $constant) {
×
49
            $this->verifyConstExists($constant);
×
50
        }
51
    }
52

53
    /**
54
     * @param mixed[] $constants
55
     */
56
    protected function verifyConstArrayAllExists(array $constants = []): void
×
57
    {
58
        foreach ($constants as $constant => $expectedSize) {
×
59
            $this->verifyConstExists($constant);
×
60
            $this->verifyConstArraySize($constant, $expectedSize);
×
61
        }
62
    }
63

64
    protected function verifyConstArraySize(string $constantName, int $expectedSize): void
×
65
    {
66
        $constantValue = constant($constantName);
×
67
        static::assertIsArray($constantValue);
×
68
        static::assertCount($expectedSize, $constantValue);
×
69
    }
70

71
    /**
72
     * @param string $constantName
73
     *
74
     * @SuppressWarnings("PHPMD.ElseExpression")
75
     */
76
    protected function verifyConstExists(string $constantName): void
×
77
    {
78
        if (defined($constantName)) {
×
79
            $constantValue = constant($constantName);
×
80
            $this->logger->debug("Checking '$constantName'=" . var_export($constantValue, true));
×
81
            if (!static::isPrimitive($constantValue)) {
×
82
                static::assertNotEmpty($constantValue);
×
83
            }
84
        } else {
85
            static::fail(sprintf("FAIL: Constant '%s' not exists", $constantName));
×
86
        }
87
    }
88
    public const LOP = 'int|integer|bool|boolean|float';
89

90
    /**
91
     * @param mixed $var
92
     *
93
     * @return bool
94
     */
95
    protected static function isPrimitive($var): bool
×
96
    {
97
        $primitive = false;
×
98
        if (isset($var) && strpos(self::LOP, gettype($var)) > 0) {
×
99
            $primitive = true;
×
100
        }
101

102
        return $primitive;
×
103
    }
104

105
    public function testInit(): void
×
106
    {
107
        static::assertNotEmpty($this->o2t);
×
108
        static::assertIsObject($this->o2t);
×
109
        static::assertInstanceOf(get_class($this->o2t), $this->prepareO2t());
×
110
    }
111
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc