-
Notifications
You must be signed in to change notification settings - Fork 3
/
IntegrationClassMapTest.php
53 lines (44 loc) · 1.53 KB
/
IntegrationClassMapTest.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
<?php
/**
* PHP Autoload Override (https://github.com/adriansuter/php-autoload-override)
*
* @license https://github.com/adriansuter/php-autoload-override/blob/master/LICENSE.md (MIT License)
*/
declare(strict_types=1);
namespace AdrianSuter\Autoload\Override\Tests;
class IntegrationClassMapTest extends AbstractIntegrationTest
{
protected function getOverrideDeclarations(): array
{
return [
\My\Integration\TestClassMapOverride\Calculator::class => [
'cos' => function (float $arg): float {
return \sin($arg);
},
],
'My\\Integration\\TestClassMapOverride\\' => [
'cos' => function (float $arg): float {
return $arg * 2;
},
]
];
}
public function testCalculator()
{
$calculator = new \My\Integration\TestClassMapOverride\Calculator();
// Calls \cos() > Overridden by FQCN-declaration.
$this->assertEquals(\sin(\pi() / 2), $calculator->cos(\pi() / 2));
}
public function testGeometry()
{
$geometry = new \My\Integration\TestClassMapOverride\SubNamespace\Geometry();
// Calls \cos() > Overridden by FQNS-declaration.
$this->assertEquals(1, $geometry->cos(0.5));
}
public function testOtherCalculator()
{
$otherCalculator = new \My\Integration\TestClassMapOverride\OtherCalculator();
// Calls \cos() > Overridden by FQNS-declaration.
$this->assertEquals(2, $otherCalculator->cos(1));
}
}