Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(deps-dev): bump lunr/halo from 0.8.1 to 0.10.0 #634

Merged
merged 2 commits into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"rize/uri-template": "*"
},
"require-dev": {
"lunr/halo": "~0.8.0",
"lunr/halo": "~0.10.0",
"phpunit/phpunit": "~10.0",
"theseer/autoload": "~1.0",
"phing/phing": "~3.0",
Expand Down
14 changes: 7 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 16 additions & 25 deletions src/PHPDraft/In/Tests/ApibFileParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,18 @@
*/
class ApibFileParserTest extends LunrBaseTest
{

private ApibFileParser $class;

/**
* Set up tests.
*
* @return void Test is now set up.
*/
public function setUp(): void
{
$this->class = new ApibFileParser(__DIR__ . '/ApibFileParserTest.php');
$this->reflection = new ReflectionClass('PHPDraft\In\ApibFileParser');
$this->class = new ApibFileParser(__DIR__ . '/ApibFileParserTest.php');
$this->baseSetUp($this->class);
}

/**
Expand All @@ -36,9 +39,7 @@ public function setUp(): void
*/
public function testLocationSetup(): void
{
$property = $this->reflection->getProperty('location');
$property->setAccessible(true);
$this->assertSame(__DIR__ . '/', $property->getValue($this->class));
$this->assertPropertyEquals('location', __DIR__ . '/');
}

/**
Expand All @@ -47,9 +48,7 @@ public function testLocationSetup(): void
*/
public function testFilenameSetup(): void
{
$property = $this->reflection->getProperty('filename');
$property->setAccessible(true);
$this->assertSame(__DIR__ . '/ApibFileParserTest.php', $property->getValue($this->class));
$this->assertPropertySame('filename', __DIR__ . '/ApibFileParserTest.php');
}

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

$property = $this->reflection->getProperty('filename');
$property->setAccessible(true);
$property->setValue($this->class, TEST_STATICS . '/drafter/non_existing_including_apib');
$this->set_reflection_property_value('filename', TEST_STATICS . '/drafter/non_existing_including_apib');
$this->class->parse();
}

Expand All @@ -75,21 +72,15 @@ public function testFilenameSetupWrong(): void
*/
public function testParseBasic(): void
{
$property = $this->reflection->getProperty('filename');
$property->setAccessible(true);
$property->setValue($this->class, TEST_STATICS . '/drafter/apib/including.apib');
$loc_property = $this->reflection->getProperty('location');
$loc_property->setAccessible(true);
$loc_property->setValue($this->class, TEST_STATICS . '/drafter/apib/');

$this->mock_function('curl_exec', function () {
return 'hello';
});
$this->set_reflection_property_value('filename', TEST_STATICS . '/drafter/apib/including.apib');
$this->set_reflection_property_value('location', TEST_STATICS . '/drafter/apib/');


$this->mock_function('curl_exec', fn() => 'hello');

$this->class->parse();
$this->unmock_function('curl_exec');

$full_property = $this->reflection->getProperty('full_apib');
$full_property->setAccessible(true);
$this->unmock_function('curl_exec');

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

$this->assertSame($text, $full_property->getValue($this->class));
$this->assertPropertyEquals('full_apib', $text);
$this->assertSame($text, $this->class->__toString());
}

Expand Down
2 changes: 1 addition & 1 deletion src/PHPDraft/Model/Elements/ArrayStructureElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
$desc = MarkdownExtra::defaultTransform($this->description);
}

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

Check warning on line 67 in src/PHPDraft/Model/Elements/ArrayStructureElement.php

View check run for this annotation

Codecov / codecov/patch

src/PHPDraft/Model/Elements/ArrayStructureElement.php#L67

Added line #L67 was not covered by tests
}

$return = '';
Expand Down
4 changes: 2 additions & 2 deletions src/PHPDraft/Model/Elements/BasicStructureElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ abstract class BasicStructureElement implements StructureElement
*
* @var string|null
*/
public ?string $type;
public ?string $type = null;
/**
* Object description.
*
Expand Down Expand Up @@ -65,7 +65,7 @@ abstract class BasicStructureElement implements StructureElement
*
* @var string[]|null
*/
public ?array $deps;
public ?array $deps = null;

/**
* Parse a JSON object to a structure.
Expand Down
4 changes: 2 additions & 2 deletions src/PHPDraft/Model/Elements/ElementStructureElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ public function __toString(): string
{
$type = $this->get_element_as_html($this->type);

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

Expand Down
2 changes: 1 addition & 1 deletion src/PHPDraft/Model/Elements/EnumStructureElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function __toString(): string
$type = $this->get_element_as_html($this->element);
$desc = $this->description === null ? '' : MarkdownExtra::defaultTransform($this->description);

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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ class ArrayStructureElementTest extends LunrBaseTest
*/
public function setUp(): void
{
$this->class = new ArrayStructureElement();
$this->reflection = new \ReflectionClass('PHPDraft\Model\Elements\ArrayStructureElement');
$this->class = new ArrayStructureElement();
$this->baseSetUp($this->class);
}

/**
Expand Down Expand Up @@ -179,8 +179,7 @@ public static function parseObjectProvider(): array
*/
public function testNewInstance(): void
{
$method = $this->reflection->getMethod('new_instance');
$method->setAccessible(true);
$method = $this->get_reflection_method('new_instance');
$return = $method->invoke($this->class);
$this->assertInstanceOf(ArrayStructureElement::class, $return);
}
Expand Down
14 changes: 6 additions & 8 deletions src/PHPDraft/Model/Elements/Tests/BasicStructureElementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,27 @@
*/
class BasicStructureElementTest extends LunrBaseTest
{
private BasicStructureElement $class;

/**
* Set up tests
*
* @return void
* @throws \ReflectionException
*/
public function setUp(): void
{
$this->class = $this->getMockBuilder('\PHPDraft\Model\Elements\BasicStructureElement')
->disableOriginalConstructor()
->getMockForAbstractClass();
$this->reflection = new ReflectionClass($this->class);
$this->baseSetUp($this->class);
}

/**
* Test if the value the class is initialized with is correct
*/
public function testSetupCorrectly(): void
{
$property = $this->reflection->getProperty('element');
$property->setAccessible(true);
$this->assertNull($property->getValue($this->class));
$this->assertPropertyEquals('element', NULL);
}

/**
Expand Down Expand Up @@ -102,8 +101,7 @@ public function testParseCommonDeps(): void
$answer->type = 'cat';
$answer->description = null;

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

$this->assertEquals($answer->key, $this->class->key);
Expand All @@ -124,7 +122,7 @@ public function testParseCommonDeps(): void
public function testParseCommon($value, BasicStructureElement $expected_value): void
{
$dep = [];
$method = $this->get_accessible_reflection_method('parse_common');
$method = $this->get_reflection_method('parse_common');
$method->invokeArgs($this->class, [$value, &$dep]);

$this->assertEquals($expected_value->key, $this->class->key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
*/
class ElementStructureElementTest extends LunrBaseTest
{
private ElementStructureElement $class;

/**
* Set up
*/
public function setUp(): void
{
$this->class = new ElementStructureElement();
$this->reflection = new ReflectionClass('PHPDraft\Model\Elements\ElementStructureElement');
$this->class = new ElementStructureElement();
$this->baseSetUp($this->class);
}

/**
Expand Down
11 changes: 4 additions & 7 deletions src/PHPDraft/Model/Elements/Tests/EnumStructureElementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,24 @@ class EnumStructureElementTest extends LunrBaseTest
*/
public function setUp(): void
{
$this->class = new EnumStructureElement();
$this->reflection = new \ReflectionClass('PHPDraft\Model\Elements\EnumStructureElement');
$this->class = new EnumStructureElement();
$this->baseSetUp($this->class);
}

/**
* Test if the value the class is initialized with is correct
*/
public function testSetupCorrectly(): void
{
$property = $this->reflection->getProperty('element');
$property->setAccessible(true);
$this->assertNull($property->getValue($this->class));
$this->assertPropertyEquals('element', NULL);
}

/**
* Test setup of new instances
*/
public function testNewInstance(): void
{
$method = $this->reflection->getMethod('new_instance');
$method->setAccessible(true);
$method = $this->get_reflection_method('new_instance');
$return = $method->invoke($this->class);
$this->assertInstanceOf(EnumStructureElement::class, $return);
}
Expand Down
11 changes: 6 additions & 5 deletions src/PHPDraft/Model/Elements/Tests/ObjectStructureElementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,17 @@
*/
class ObjectStructureElementTest extends LunrBaseTest
{
private ObjectStructureElement $class;

/**
* Set up tests
*
* @return void
*/
public function setUp(): void
{
$this->class = new ObjectStructureElement();
$this->reflection = new ReflectionClass('PHPDraft\Model\Elements\ObjectStructureElement');
$this->class = new ObjectStructureElement();
$this->baseSetUp($this->class);
}

/**
Expand All @@ -41,8 +43,7 @@ public function setUp(): void
*/
public function testNewInstance(): void
{
$method = $this->reflection->getMethod('new_instance');
$method->setAccessible(true);
$method = $this->get_reflection_method('new_instance');
$return = $method->invoke($this->class);
$this->assertInstanceOf(ObjectStructureElement::class, $return);
}
Expand Down Expand Up @@ -210,7 +211,7 @@ public function testEmptyParse(): void
$deps = [];
$return = $this->class->parse(null, $deps);
$this->assertInstanceOf(ObjectStructureElement::class, $return);
$object = new \stdClass();
$object = (object)[];
$object->key = 'key';
$return = $this->class->parse($object, $deps);
$this->assertInstanceOf(ObjectStructureElement::class, $return);
Expand Down
Loading
Loading