-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathCoverageOnlyTest.php
113 lines (97 loc) · 3.38 KB
/
CoverageOnlyTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?php
namespace Unleash\Client\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Unleash\Client\Configuration\UnleashConfiguration;
use Unleash\Client\Configuration\UnleashContext;
use Unleash\Client\DTO\DefaultFeature;
use Unleash\Client\DTO\DefaultSegment;
use Unleash\Client\DTO\DefaultVariant;
use Unleash\Client\DTO\DefaultVariantPayload;
use Unleash\Client\Enum\VariantPayloadType;
use Unleash\Client\Event\FeatureToggleDisabledEvent;
use Unleash\Client\Event\FeatureToggleMissingStrategyHandlerEvent;
use Unleash\Client\Event\FeatureToggleNotFoundEvent;
use Unleash\Client\Exception\CompoundException;
/**
* This class is only for triggering code that doesn't really make sense to test and is here to achieve 100% code coverage.
* The reason is to catch potential problems during transpilation to lower versions of php.
*/
final class CoverageOnlyTest extends TestCase
{
/**
* For whatever reason PHPUnit doesn't include tests that don't perform assertions when calculating
* code coverage, so here's one dumb assertion that will get triggered after every test.
*/
protected function tearDown(): void
{
self::assertTrue(true);
}
public function testDefaultSegment(): void
{
$instance = new DefaultSegment(1, []);
$instance->getId();
}
public function testUnleashConfiguration(): void
{
$instance = new UnleashConfiguration('', '', '');
$instance->setAppName('test');
$instance->setInstanceId('test');
}
public function testUnleashContext(): void
{
$instance = new UnleashContext();
$instance->getCustomProperties();
}
public function testDefaultVariant(): void
{
$instance = new DefaultVariant('test', true);
$instance->getPayload();
}
public function testDefaultVariantPayload(): void
{
$instance = new DefaultVariantPayload(VariantPayloadType::STRING, 'test');
$instance->getType();
}
public function testFeatureToggleDisabledEvent(): void
{
$instance = new FeatureToggleDisabledEvent(
new DefaultFeature('test', false, []),
new UnleashContext()
);
$instance->getFeature();
$instance->getContext();
}
public function testFeatureToggleMissingStrategyHandlerEvent(): void
{
$instance = new FeatureToggleMissingStrategyHandlerEvent(
new UnleashContext(),
new DefaultFeature('test', false, [])
);
$instance->getContext();
$instance->getFeature();
}
public function testFeatureToggleNotFoundEvent(): void
{
$instance = new FeatureToggleNotFoundEvent(
new UnleashContext(),
'test'
);
$instance->getContext();
$instance->getFeatureName();
}
public function testCompoundException(): void
{
$instance = new CompoundException();
$instance->getExceptions();
}
public function testGetEventDispatcher()
{
$configuration = function () {
return (new UnleashConfiguration('', '', ''))
->setFetchingEnabled(false);
};
$configurationEventDispatcher = $configuration()->setEventDispatcher(new EventDispatcher());
self::assertInstanceOf(EventDispatcher::class, $configurationEventDispatcher->getEventDispatcher());
}
}