Skip to content

Commit 71bb7ec

Browse files
build(deps-dev): bump lunr/halo from 0.8.1 to 0.10.0 (#634)
Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Sean Molenaar <[email protected]>
1 parent f010ccd commit 71bb7ec

35 files changed

+238
-355
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"rize/uri-template": "*"
3131
},
3232
"require-dev": {
33-
"lunr/halo": "~0.8.0",
33+
"lunr/halo": "~0.10.0",
3434
"phpunit/phpunit": "~10.0",
3535
"theseer/autoload": "~1.0",
3636
"phing/phing": "~3.0",

composer.lock

+7-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/PHPDraft/In/Tests/ApibFileParserTest.php

+16-25
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,18 @@
1919
*/
2020
class ApibFileParserTest extends LunrBaseTest
2121
{
22+
23+
private ApibFileParser $class;
24+
2225
/**
2326
* Set up tests.
2427
*
2528
* @return void Test is now set up.
2629
*/
2730
public function setUp(): void
2831
{
29-
$this->class = new ApibFileParser(__DIR__ . '/ApibFileParserTest.php');
30-
$this->reflection = new ReflectionClass('PHPDraft\In\ApibFileParser');
32+
$this->class = new ApibFileParser(__DIR__ . '/ApibFileParserTest.php');
33+
$this->baseSetUp($this->class);
3134
}
3235

3336
/**
@@ -36,9 +39,7 @@ public function setUp(): void
3639
*/
3740
public function testLocationSetup(): void
3841
{
39-
$property = $this->reflection->getProperty('location');
40-
$property->setAccessible(true);
41-
$this->assertSame(__DIR__ . '/', $property->getValue($this->class));
42+
$this->assertPropertyEquals('location', __DIR__ . '/');
4243
}
4344

4445
/**
@@ -47,9 +48,7 @@ public function testLocationSetup(): void
4748
*/
4849
public function testFilenameSetup(): void
4950
{
50-
$property = $this->reflection->getProperty('filename');
51-
$property->setAccessible(true);
52-
$this->assertSame(__DIR__ . '/ApibFileParserTest.php', $property->getValue($this->class));
51+
$this->assertPropertySame('filename', __DIR__ . '/ApibFileParserTest.php');
5352
}
5453

5554
/**
@@ -63,9 +62,7 @@ public function testFilenameSetupWrong(): void
6362
$this->expectExceptionMessageMatches('/API File not found: .*\/drafter\/non_existing_including_apib/');
6463
$this->expectExceptionCode(1);
6564

66-
$property = $this->reflection->getProperty('filename');
67-
$property->setAccessible(true);
68-
$property->setValue($this->class, TEST_STATICS . '/drafter/non_existing_including_apib');
65+
$this->set_reflection_property_value('filename', TEST_STATICS . '/drafter/non_existing_including_apib');
6966
$this->class->parse();
7067
}
7168

@@ -75,21 +72,15 @@ public function testFilenameSetupWrong(): void
7572
*/
7673
public function testParseBasic(): void
7774
{
78-
$property = $this->reflection->getProperty('filename');
79-
$property->setAccessible(true);
80-
$property->setValue($this->class, TEST_STATICS . '/drafter/apib/including.apib');
81-
$loc_property = $this->reflection->getProperty('location');
82-
$loc_property->setAccessible(true);
83-
$loc_property->setValue($this->class, TEST_STATICS . '/drafter/apib/');
84-
85-
$this->mock_function('curl_exec', function () {
86-
return 'hello';
87-
});
75+
$this->set_reflection_property_value('filename', TEST_STATICS . '/drafter/apib/including.apib');
76+
$this->set_reflection_property_value('location', TEST_STATICS . '/drafter/apib/');
77+
78+
79+
$this->mock_function('curl_exec', fn() => 'hello');
80+
8881
$this->class->parse();
89-
$this->unmock_function('curl_exec');
9082

91-
$full_property = $this->reflection->getProperty('full_apib');
92-
$full_property->setAccessible(true);
83+
$this->unmock_function('curl_exec');
9384

9485
$text = "FORMAT: 1A\nHOST: https://owner-api.teslamotors.com\n";
9586
$text .= "EXTRA_HOSTS: https://test.owner-api.teslamotors.com\nSOMETHING: INFO\n\n";
@@ -98,7 +89,7 @@ public function testParseBasic(): void
9889
$text .= " functionality to monitor and control the Model S remotely.\n\nTEST";
9990
$text .= "\n\n# Hello\nThis is a test.\nhello";
10091

101-
$this->assertSame($text, $full_property->getValue($this->class));
92+
$this->assertPropertyEquals('full_apib', $text);
10293
$this->assertSame($text, $this->class->__toString());
10394
}
10495

src/PHPDraft/Model/Elements/ArrayStructureElement.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function __toString(): string
6464
$desc = MarkdownExtra::defaultTransform($this->description);
6565
}
6666

67-
return "<tr><td>{$this->key}</td><td>{$type}</td><td>{$desc}</td></tr>";
67+
return "<tr><td>$this->key</td><td>$type</td><td>$desc</td></tr>";
6868
}
6969

7070
$return = '';

src/PHPDraft/Model/Elements/BasicStructureElement.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ abstract class BasicStructureElement implements StructureElement
2323
*
2424
* @var string|null
2525
*/
26-
public ?string $type;
26+
public ?string $type = null;
2727
/**
2828
* Object description.
2929
*
@@ -65,7 +65,7 @@ abstract class BasicStructureElement implements StructureElement
6565
*
6666
* @var string[]|null
6767
*/
68-
public ?array $deps;
68+
public ?array $deps = null;
6969

7070
/**
7171
* Parse a JSON object to a structure.

src/PHPDraft/Model/Elements/ElementStructureElement.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ public function __toString(): string
5252
{
5353
$type = $this->get_element_as_html($this->type);
5454

55-
$desc = is_null($this->description) ? '' : " - <span class=\"description\">{$this->description}</span>";
56-
$value = is_null($this->value) ? '' : " - <span class=\"example-value pull-right\">{$this->value}</span>";
55+
$desc = is_null($this->description) ? '' : " - <span class=\"description\">$this->description</span>";
56+
$value = is_null($this->value) ? '' : " - <span class=\"example-value pull-right\">$this->value</span>";
5757
return '<li class="list-group-item mdl-list__item">' . $type . $desc . $value . '</li>';
5858
}
5959

src/PHPDraft/Model/Elements/EnumStructureElement.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public function __toString(): string
9191
$type = $this->get_element_as_html($this->element);
9292
$desc = $this->description === null ? '' : MarkdownExtra::defaultTransform($this->description);
9393

94-
return "<tr><td>{$this->key->value}</td><td>{$type}</td><td>{$desc}</td></tr>";
94+
return "<tr><td>{$this->key->value}</td><td>$type</td><td>$desc</td></tr>";
9595
}
9696

9797
/**

src/PHPDraft/Model/Elements/Tests/ArrayStructureElementTest.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ class ArrayStructureElementTest extends LunrBaseTest
2626
*/
2727
public function setUp(): void
2828
{
29-
$this->class = new ArrayStructureElement();
30-
$this->reflection = new \ReflectionClass('PHPDraft\Model\Elements\ArrayStructureElement');
29+
$this->class = new ArrayStructureElement();
30+
$this->baseSetUp($this->class);
3131
}
3232

3333
/**
@@ -179,8 +179,7 @@ public static function parseObjectProvider(): array
179179
*/
180180
public function testNewInstance(): void
181181
{
182-
$method = $this->reflection->getMethod('new_instance');
183-
$method->setAccessible(true);
182+
$method = $this->get_reflection_method('new_instance');
184183
$return = $method->invoke($this->class);
185184
$this->assertInstanceOf(ArrayStructureElement::class, $return);
186185
}

src/PHPDraft/Model/Elements/Tests/BasicStructureElementTest.php

+6-8
Original file line numberDiff line numberDiff line change
@@ -22,28 +22,27 @@
2222
*/
2323
class BasicStructureElementTest extends LunrBaseTest
2424
{
25+
private BasicStructureElement $class;
26+
2527
/**
2628
* Set up tests
2729
*
2830
* @return void
29-
* @throws \ReflectionException
3031
*/
3132
public function setUp(): void
3233
{
3334
$this->class = $this->getMockBuilder('\PHPDraft\Model\Elements\BasicStructureElement')
3435
->disableOriginalConstructor()
3536
->getMockForAbstractClass();
36-
$this->reflection = new ReflectionClass($this->class);
37+
$this->baseSetUp($this->class);
3738
}
3839

3940
/**
4041
* Test if the value the class is initialized with is correct
4142
*/
4243
public function testSetupCorrectly(): void
4344
{
44-
$property = $this->reflection->getProperty('element');
45-
$property->setAccessible(true);
46-
$this->assertNull($property->getValue($this->class));
45+
$this->assertPropertyEquals('element', NULL);
4746
}
4847

4948
/**
@@ -102,8 +101,7 @@ public function testParseCommonDeps(): void
102101
$answer->type = 'cat';
103102
$answer->description = null;
104103

105-
$method = $this->reflection->getMethod('parse_common');
106-
$method->setAccessible(true);
104+
$method = $this->get_reflection_method('parse_common');
107105
$method->invokeArgs($this->class, [json_decode($json), &$dep]);
108106

109107
$this->assertEquals($answer->key, $this->class->key);
@@ -124,7 +122,7 @@ public function testParseCommonDeps(): void
124122
public function testParseCommon($value, BasicStructureElement $expected_value): void
125123
{
126124
$dep = [];
127-
$method = $this->get_accessible_reflection_method('parse_common');
125+
$method = $this->get_reflection_method('parse_common');
128126
$method->invokeArgs($this->class, [$value, &$dep]);
129127

130128
$this->assertEquals($expected_value->key, $this->class->key);

src/PHPDraft/Model/Elements/Tests/ElementStructureElementTest.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@
1212
*/
1313
class ElementStructureElementTest extends LunrBaseTest
1414
{
15+
private ElementStructureElement $class;
16+
1517
/**
1618
* Set up
1719
*/
1820
public function setUp(): void
1921
{
20-
$this->class = new ElementStructureElement();
21-
$this->reflection = new ReflectionClass('PHPDraft\Model\Elements\ElementStructureElement');
22+
$this->class = new ElementStructureElement();
23+
$this->baseSetUp($this->class);
2224
}
2325

2426
/**

src/PHPDraft/Model/Elements/Tests/EnumStructureElementTest.php

+4-7
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,24 @@ class EnumStructureElementTest extends LunrBaseTest
2525
*/
2626
public function setUp(): void
2727
{
28-
$this->class = new EnumStructureElement();
29-
$this->reflection = new \ReflectionClass('PHPDraft\Model\Elements\EnumStructureElement');
28+
$this->class = new EnumStructureElement();
29+
$this->baseSetUp($this->class);
3030
}
3131

3232
/**
3333
* Test if the value the class is initialized with is correct
3434
*/
3535
public function testSetupCorrectly(): void
3636
{
37-
$property = $this->reflection->getProperty('element');
38-
$property->setAccessible(true);
39-
$this->assertNull($property->getValue($this->class));
37+
$this->assertPropertyEquals('element', NULL);
4038
}
4139

4240
/**
4341
* Test setup of new instances
4442
*/
4543
public function testNewInstance(): void
4644
{
47-
$method = $this->reflection->getMethod('new_instance');
48-
$method->setAccessible(true);
45+
$method = $this->get_reflection_method('new_instance');
4946
$return = $method->invoke($this->class);
5047
$this->assertInstanceOf(EnumStructureElement::class, $return);
5148
}

src/PHPDraft/Model/Elements/Tests/ObjectStructureElementTest.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,17 @@
2323
*/
2424
class ObjectStructureElementTest extends LunrBaseTest
2525
{
26+
private ObjectStructureElement $class;
27+
2628
/**
2729
* Set up tests
2830
*
2931
* @return void
3032
*/
3133
public function setUp(): void
3234
{
33-
$this->class = new ObjectStructureElement();
34-
$this->reflection = new ReflectionClass('PHPDraft\Model\Elements\ObjectStructureElement');
35+
$this->class = new ObjectStructureElement();
36+
$this->baseSetUp($this->class);
3537
}
3638

3739
/**
@@ -41,8 +43,7 @@ public function setUp(): void
4143
*/
4244
public function testNewInstance(): void
4345
{
44-
$method = $this->reflection->getMethod('new_instance');
45-
$method->setAccessible(true);
46+
$method = $this->get_reflection_method('new_instance');
4647
$return = $method->invoke($this->class);
4748
$this->assertInstanceOf(ObjectStructureElement::class, $return);
4849
}
@@ -210,7 +211,7 @@ public function testEmptyParse(): void
210211
$deps = [];
211212
$return = $this->class->parse(null, $deps);
212213
$this->assertInstanceOf(ObjectStructureElement::class, $return);
213-
$object = new \stdClass();
214+
$object = (object)[];
214215
$object->key = 'key';
215216
$return = $this->class->parse($object, $deps);
216217
$this->assertInstanceOf(ObjectStructureElement::class, $return);

0 commit comments

Comments
 (0)