Skip to content
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 .github/workflows/php-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
phpstan-level: 9
allow-style-failures: false
allow-phpstan-failures: false
codestyle-branch: '0.10.1'
codestyle-branch: '0.10.2'
phpcs-whitelist: tests/phan.config.php tests/phpstan.autoload.inc.php tests/test.bootstrap.inc.php
php-extensions: uopz
stable-php-versions: '["8.1"]'
Expand Down
4 changes: 2 additions & 2 deletions src/Lunr/Shadow/Tests/GetoptCliParserBaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
* @covers Lunr\Shadow\GetoptCliParser
*/
class GetoptCliParserBaseTest extends GetoptCliParserTest
class GetoptCliParserBaseTest extends GetoptCliParserTestCase
{

/**
Expand All @@ -39,7 +39,7 @@ public function testLongOptsIsPassedCorrectly(): void
*/
public function testErrorIsFalseByDefault(): void
{
$this->assertFalse($this->get_reflection_property_value('error'));
$this->assertFalse($this->getReflectionPropertyValue('error'));
}

/**
Expand Down
22 changes: 11 additions & 11 deletions src/Lunr/Shadow/Tests/GetoptCliParserParseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
* @covers Lunr\Shadow\GetoptCliParser
*/
class GetoptCliParserParseTest extends GetoptCliParserTest
class GetoptCliParserParseTest extends GetoptCliParserTestCase
{

/**
Expand All @@ -25,7 +25,7 @@ class GetoptCliParserParseTest extends GetoptCliParserTest
*/
public function testWrapArgumentReturnsEmptyArrayForFalse(): void
{
$method = $this->get_accessible_reflection_method('wrap_argument');
$method = $this->getReflectionMethod('wrap_argument');

$value = $method->invokeArgs($this->class, [ FALSE ]);

Expand All @@ -42,7 +42,7 @@ public function testWrapArgumentReturnsEmptyArrayForFalse(): void
*/
public function testWrapArgumentReturnsValueWrappedInArray($cli_value): void
{
$method = $this->get_accessible_reflection_method('wrap_argument');
$method = $this->getReflectionMethod('wrap_argument');

$value = $method->invokeArgs($this->class, [ $cli_value ]);

Expand All @@ -56,7 +56,7 @@ public function testWrapArgumentReturnsValueWrappedInArray($cli_value): void
*/
public function testWrapArgumentDoesNotRewrapArguments(): void
{
$method = $this->get_accessible_reflection_method('wrap_argument');
$method = $this->getReflectionMethod('wrap_argument');

$value = $method->invokeArgs($this->class, [ [ 'param1', 'param2' ] ]);

Expand All @@ -70,12 +70,12 @@ public function testWrapArgumentDoesNotRewrapArguments(): void
*/
public function testParseReturnsEmptyArrayOnError(): void
{
$this->mock_function('getopt', function () { return FALSE; });
$this->mockFunction('getopt', function () { return FALSE; });

$value = $this->class->parse();

$this->assertArrayEmpty($value);
$this->unmock_function('getopt');
$this->unmockFunction('getopt');
}

/**
Expand All @@ -85,12 +85,12 @@ public function testParseReturnsEmptyArrayOnError(): void
*/
public function testParseSetsErrorTrueOnError(): void
{
$this->mock_function('getopt', function () { return FALSE; });
$this->mockFunction('getopt', function () { return FALSE; });

$this->class->parse();

$this->assertTrue($this->get_reflection_property_value('error'));
$this->unmock_function('getopt');
$this->assertTrue($this->getReflectionPropertyValue('error'));
$this->unmockFunction('getopt');
}

/**
Expand All @@ -100,13 +100,13 @@ public function testParseSetsErrorTrueOnError(): void
*/
public function testParseReturnsAstOnSuccess(): void
{
$this->mock_function('getopt', function () { return [ 'a' => FALSE, 'b' => 'arg' ]; });
$this->mockFunction('getopt', function () { return [ 'a' => FALSE, 'b' => 'arg' ]; });

$value = $this->class->parse();

$this->assertIsArray($value);
$this->assertEquals([ 'a' => [], 'b' => [ 'arg' ] ], $value);
$this->unmock_function('getopt');
$this->unmockFunction('getopt');
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace Lunr\Shadow\Tests;

use Lunr\Halo\LunrBaseTest;
use Lunr\Halo\LunrBaseTestCase;
use Lunr\Shadow\GetoptCliParser;

/**
Expand All @@ -19,7 +19,7 @@
*
* @covers Lunr\Shadow\GetoptCliParser
*/
abstract class GetoptCliParserTest extends LunrBaseTest
abstract class GetoptCliParserTestCase extends LunrBaseTestCase
{

/**
Expand Down
12 changes: 6 additions & 6 deletions src/Lunr/Shadow/Tests/LunrCliParserBaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
* @covers Lunr\Shadow\LunrCliParser
*/
class LunrCliParserBaseTest extends LunrCliParserTest
class LunrCliParserBaseTest extends LunrCliParserTestCase
{

/**
Expand All @@ -39,7 +39,7 @@ public function testLongOptsIsPassedCorrectly(): void
*/
public function testArgsIsEmptyArrayByDefault(): void
{
$value = $this->get_reflection_property_value('args');
$value = $this->getReflectionPropertyValue('args');

$this->assertArrayEmpty($value);
}
Expand All @@ -49,7 +49,7 @@ public function testArgsIsEmptyArrayByDefault(): void
*/
public function testCheckedIsEmptyArrayByDefault(): void
{
$value = $this->get_reflection_property_value('checked');
$value = $this->getReflectionPropertyValue('checked');

$this->assertArrayEmpty($value);
}
Expand All @@ -59,7 +59,7 @@ public function testCheckedIsEmptyArrayByDefault(): void
*/
public function testASTisEmptyArrayByDefault(): void
{
$value = $this->get_reflection_property_value('ast');
$value = $this->getReflectionPropertyValue('ast');

$this->assertArrayEmpty($value);
}
Expand All @@ -69,7 +69,7 @@ public function testASTisEmptyArrayByDefault(): void
*/
public function testErrorIsFalseByDefault(): void
{
$this->assertFalse($this->get_reflection_property_value('error'));
$this->assertFalse($this->getReflectionPropertyValue('error'));
}

/**
Expand All @@ -79,7 +79,7 @@ public function testErrorIsFalseByDefault(): void
*/
public function testIsInvalidCommandLineReturnsError(): void
{
$value = $this->get_reflection_property_value('error');
$value = $this->getReflectionPropertyValue('error');

$this->assertEquals($value, $this->class->is_invalid_commandline());
}
Expand Down
8 changes: 4 additions & 4 deletions src/Lunr/Shadow/Tests/LunrCliParserCheckArgumentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
* @covers Lunr\Shadow\LunrCliParser
*/
class LunrCliParserCheckArgumentTest extends LunrCliParserTest
class LunrCliParserCheckArgumentTest extends LunrCliParserTestCase
{

/**
Expand All @@ -25,7 +25,7 @@ class LunrCliParserCheckArgumentTest extends LunrCliParserTest
*/
public function testCheckArgumentReturnsFalseForValidParameterWithoutArgs(): void
{
$method = $this->get_accessible_reflection_method('check_argument');
$method = $this->getReflectionMethod('check_argument');

$value = $method->invokeArgs($this->class, [ 'a', 1, 0, 'a' ]);

Expand All @@ -39,9 +39,9 @@ public function testCheckArgumentReturnsFalseForValidParameterWithoutArgs(): voi
*/
public function testCheckArgumentReturnsTrueForSuperfluousArgument(): void
{
$this->set_reflection_property_value('args', [ 'test.php', '-a', 'arg' ]);
$this->setReflectionPropertyValue('args', [ 'test.php', '-a', 'arg' ]);

$method = $this->get_accessible_reflection_method('check_argument');
$method = $this->getReflectionMethod('check_argument');

$this->expectUserNotice('Superfluous argument: arg');

Expand Down
42 changes: 21 additions & 21 deletions src/Lunr/Shadow/Tests/LunrCliParserCheckObligatoryArgumentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
* @covers Lunr\Shadow\LunrCliParser
*/
class LunrCliParserCheckObligatoryArgumentTest extends LunrCliParserTest
class LunrCliParserCheckObligatoryArgumentTest extends LunrCliParserTestCase
{

/**
Expand All @@ -25,11 +25,11 @@ class LunrCliParserCheckObligatoryArgumentTest extends LunrCliParserTest
*/
public function testCheckArgumentReturnsTrueForValidParameterWithOneArg(): void
{
$this->set_reflection_property_value('args', [ 'test.php', '-b', 'arg' ]);
$this->setReflectionPropertyValue('args', [ 'test.php', '-b', 'arg' ]);

$this->set_reflection_property_value('ast', [ 'b' => [] ]);
$this->setReflectionPropertyValue('ast', [ 'b' => [] ]);

$method = $this->get_accessible_reflection_method('check_argument');
$method = $this->getReflectionMethod('check_argument');

$value = $method->invokeArgs($this->class, [ 'b', 1, 0, 'b:' ]);

Expand All @@ -43,11 +43,11 @@ public function testCheckArgumentReturnsTrueForValidParameterWithOneArg(): void
*/
public function testCheckArgumentReturnsTrueForValidParameterWithTwoArgs(): void
{
$this->set_reflection_property_value('args', [ 'test.php', '-e', 'arg1', 'arg2' ]);
$this->setReflectionPropertyValue('args', [ 'test.php', '-e', 'arg1', 'arg2' ]);

$this->set_reflection_property_value('ast', [ 'e' => [] ]);
$this->setReflectionPropertyValue('ast', [ 'e' => [] ]);

$method = $this->get_accessible_reflection_method('check_argument');
$method = $this->getReflectionMethod('check_argument');

$value = $method->invokeArgs($this->class, [ 'e', 1, 0, 'e::' ]);

Expand All @@ -61,15 +61,15 @@ public function testCheckArgumentReturnsTrueForValidParameterWithTwoArgs(): void
*/
public function testCheckArgumentAppendsFirstArgumentToAst(): void
{
$this->set_reflection_property_value('args', [ 'test.php', '-b', 'arg' ]);
$this->setReflectionPropertyValue('args', [ 'test.php', '-b', 'arg' ]);

$this->set_reflection_property_value('ast', [ 'b' => [] ]);
$this->setReflectionPropertyValue('ast', [ 'b' => [] ]);

$method = $this->get_accessible_reflection_method('check_argument');
$method = $this->getReflectionMethod('check_argument');

$method->invokeArgs($this->class, [ 'b', 1, 0, 'b:' ]);

$value = $this->get_reflection_property_value('ast');
$value = $this->getReflectionPropertyValue('ast');

$this->assertCount(1, $value['b']);
$this->assertEquals([ 'arg' ], $value['b']);
Expand All @@ -82,15 +82,15 @@ public function testCheckArgumentAppendsFirstArgumentToAst(): void
*/
public function testCheckArgumentAppendsSecondArgumentToAst(): void
{
$this->set_reflection_property_value('args', [ 'test.php', '-e', 'arg1', 'arg2' ]);
$this->setReflectionPropertyValue('args', [ 'test.php', '-e', 'arg1', 'arg2' ]);

$this->set_reflection_property_value('ast', [ 'e' => [] ]);
$this->setReflectionPropertyValue('ast', [ 'e' => [] ]);

$method = $this->get_accessible_reflection_method('check_argument');
$method = $this->getReflectionMethod('check_argument');

$method->invokeArgs($this->class, [ 'e', 1, 0, 'e::' ]);

$value = $this->get_reflection_property_value('ast');
$value = $this->getReflectionPropertyValue('ast');

$this->assertCount(2, $value['e']);
$this->assertEquals([ 'arg1', 'arg2' ], $value['e']);
Expand All @@ -103,11 +103,11 @@ public function testCheckArgumentAppendsSecondArgumentToAst(): void
*/
public function testCheckArgumentReturnsFalseForArgumentMissing(): void
{
$this->set_reflection_property_value('args', [ 'test.php', '-b' ]);
$this->setReflectionPropertyValue('args', [ 'test.php', '-b' ]);

$this->set_reflection_property_value('ast', [ 'b' => [] ]);
$this->setReflectionPropertyValue('ast', [ 'b' => [] ]);

$method = $this->get_accessible_reflection_method('check_argument');
$method = $this->getReflectionMethod('check_argument');

$this->expectUserWarning('Missing argument for -b');

Expand All @@ -123,11 +123,11 @@ public function testCheckArgumentReturnsFalseForArgumentMissing(): void
*/
public function testCheckArgumentReturnsFalseForArgumentMissingWithAnotherParameterAfter(): void
{
$this->set_reflection_property_value('args', [ 'test.php', '-b', '-c' ]);
$this->setReflectionPropertyValue('args', [ 'test.php', '-b', '-c' ]);

$this->set_reflection_property_value('ast', [ 'b' => [] ]);
$this->setReflectionPropertyValue('ast', [ 'b' => [] ]);

$method = $this->get_accessible_reflection_method('check_argument');
$method = $this->getReflectionMethod('check_argument');

$this->expectUserWarning('Missing argument for -b');

Expand Down
Loading