-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathDefinitionTest.php
59 lines (48 loc) · 1.74 KB
/
DefinitionTest.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
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Magento\Upward\Test;
use Magento\Upward\Definition;
use PHPUnit\Framework\TestCase;
use function BeBat\Verify\verify;
class DefinitionTest extends TestCase
{
/**
* @var Definition
*/
private $definition;
protected function setUp(): void
{
$this->definition = new Definition([
'key0' => [
'key00' => [
'key000' => 'value',
],
],
]);
$this->definition->setBasepath(__DIR__);
}
public function testBasepathInheritance(): void
{
$this->assertionsForBasepath($this->definition->get('key0'));
$this->assertionsForBasepath($this->definition->get('key0.key00'));
$this->assertionsForBasepath($this->definition->get('key0')->get('key00'));
}
public function testTreeAddress(): void
{
verify($this->definition->get('key0'))->is()->instanceOf(Definition::class);
verify($this->definition->get('key0')->getTreeAddress())->is()->sameAs('key0');
verify($this->definition->get('key0.key00'))->is()->instanceOf(Definition::class);
verify($this->definition->get('key0.key00')->getTreeAddress())->is()->sameAs('key0.key00');
verify($this->definition->get('key0')->get('key00'))->is()->instanceOf(Definition::class);
verify($this->definition->get('key0')->get('key00')->getTreeAddress())->is()->sameAs('key0.key00');
}
private function assertionsForBasepath($subject): void
{
verify($subject)->is()->instanceOf(Definition::class);
verify($subject->getBasepath())->is()->sameAs(__DIR__);
}
}