Skip to content

Commit 5bddaeb

Browse files
committed
CliParser: Update to latest Lunr.Halo
1 parent fe116ca commit 5bddaeb

13 files changed

+112
-112
lines changed

.github/workflows/php-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
phpstan-level: 9
1313
allow-style-failures: false
1414
allow-phpstan-failures: false
15-
codestyle-branch: '0.10.1'
15+
codestyle-branch: '0.10.2'
1616
phpcs-whitelist: tests/phan.config.php tests/phpstan.autoload.inc.php tests/test.bootstrap.inc.php
1717
php-extensions: uopz
1818
stable-php-versions: '["8.1"]'

src/Lunr/Shadow/Tests/GetoptCliParserBaseTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
* @covers Lunr\Shadow\GetoptCliParser
1717
*/
18-
class GetoptCliParserBaseTest extends GetoptCliParserTest
18+
class GetoptCliParserBaseTest extends GetoptCliParserTestCase
1919
{
2020

2121
/**
@@ -39,7 +39,7 @@ public function testLongOptsIsPassedCorrectly(): void
3939
*/
4040
public function testErrorIsFalseByDefault(): void
4141
{
42-
$this->assertFalse($this->get_reflection_property_value('error'));
42+
$this->assertFalse($this->getReflectionPropertyValue('error'));
4343
}
4444

4545
/**

src/Lunr/Shadow/Tests/GetoptCliParserParseTest.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
* @covers Lunr\Shadow\GetoptCliParser
1717
*/
18-
class GetoptCliParserParseTest extends GetoptCliParserTest
18+
class GetoptCliParserParseTest extends GetoptCliParserTestCase
1919
{
2020

2121
/**
@@ -25,7 +25,7 @@ class GetoptCliParserParseTest extends GetoptCliParserTest
2525
*/
2626
public function testWrapArgumentReturnsEmptyArrayForFalse(): void
2727
{
28-
$method = $this->get_accessible_reflection_method('wrap_argument');
28+
$method = $this->getReflectionMethod('wrap_argument');
2929

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

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

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

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

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

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

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

7777
$this->assertArrayEmpty($value);
78-
$this->unmock_function('getopt');
78+
$this->unmockFunction('getopt');
7979
}
8080

8181
/**
@@ -85,12 +85,12 @@ public function testParseReturnsEmptyArrayOnError(): void
8585
*/
8686
public function testParseSetsErrorTrueOnError(): void
8787
{
88-
$this->mock_function('getopt', function () { return FALSE; });
88+
$this->mockFunction('getopt', function () { return FALSE; });
8989

9090
$this->class->parse();
9191

92-
$this->assertTrue($this->get_reflection_property_value('error'));
93-
$this->unmock_function('getopt');
92+
$this->assertTrue($this->getReflectionPropertyValue('error'));
93+
$this->unmockFunction('getopt');
9494
}
9595

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

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

107107
$this->assertIsArray($value);
108108
$this->assertEquals([ 'a' => [], 'b' => [ 'arg' ] ], $value);
109-
$this->unmock_function('getopt');
109+
$this->unmockFunction('getopt');
110110
}
111111

112112
}

src/Lunr/Shadow/Tests/GetoptCliParserTest.php renamed to src/Lunr/Shadow/Tests/GetoptCliParserTestCase.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
namespace Lunr\Shadow\Tests;
1212

13-
use Lunr\Halo\LunrBaseTest;
13+
use Lunr\Halo\LunrBaseTestCase;
1414
use Lunr\Shadow\GetoptCliParser;
1515

1616
/**
@@ -19,7 +19,7 @@
1919
*
2020
* @covers Lunr\Shadow\GetoptCliParser
2121
*/
22-
abstract class GetoptCliParserTest extends LunrBaseTest
22+
abstract class GetoptCliParserTestCase extends LunrBaseTestCase
2323
{
2424

2525
/**

src/Lunr/Shadow/Tests/LunrCliParserBaseTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
* @covers Lunr\Shadow\LunrCliParser
1717
*/
18-
class LunrCliParserBaseTest extends LunrCliParserTest
18+
class LunrCliParserBaseTest extends LunrCliParserTestCase
1919
{
2020

2121
/**
@@ -39,7 +39,7 @@ public function testLongOptsIsPassedCorrectly(): void
3939
*/
4040
public function testArgsIsEmptyArrayByDefault(): void
4141
{
42-
$value = $this->get_reflection_property_value('args');
42+
$value = $this->getReflectionPropertyValue('args');
4343

4444
$this->assertArrayEmpty($value);
4545
}
@@ -49,7 +49,7 @@ public function testArgsIsEmptyArrayByDefault(): void
4949
*/
5050
public function testCheckedIsEmptyArrayByDefault(): void
5151
{
52-
$value = $this->get_reflection_property_value('checked');
52+
$value = $this->getReflectionPropertyValue('checked');
5353

5454
$this->assertArrayEmpty($value);
5555
}
@@ -59,7 +59,7 @@ public function testCheckedIsEmptyArrayByDefault(): void
5959
*/
6060
public function testASTisEmptyArrayByDefault(): void
6161
{
62-
$value = $this->get_reflection_property_value('ast');
62+
$value = $this->getReflectionPropertyValue('ast');
6363

6464
$this->assertArrayEmpty($value);
6565
}
@@ -69,7 +69,7 @@ public function testASTisEmptyArrayByDefault(): void
6969
*/
7070
public function testErrorIsFalseByDefault(): void
7171
{
72-
$this->assertFalse($this->get_reflection_property_value('error'));
72+
$this->assertFalse($this->getReflectionPropertyValue('error'));
7373
}
7474

7575
/**
@@ -79,7 +79,7 @@ public function testErrorIsFalseByDefault(): void
7979
*/
8080
public function testIsInvalidCommandLineReturnsError(): void
8181
{
82-
$value = $this->get_reflection_property_value('error');
82+
$value = $this->getReflectionPropertyValue('error');
8383

8484
$this->assertEquals($value, $this->class->is_invalid_commandline());
8585
}

src/Lunr/Shadow/Tests/LunrCliParserCheckArgumentTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
* @covers Lunr\Shadow\LunrCliParser
1717
*/
18-
class LunrCliParserCheckArgumentTest extends LunrCliParserTest
18+
class LunrCliParserCheckArgumentTest extends LunrCliParserTestCase
1919
{
2020

2121
/**
@@ -25,7 +25,7 @@ class LunrCliParserCheckArgumentTest extends LunrCliParserTest
2525
*/
2626
public function testCheckArgumentReturnsFalseForValidParameterWithoutArgs(): void
2727
{
28-
$method = $this->get_accessible_reflection_method('check_argument');
28+
$method = $this->getReflectionMethod('check_argument');
2929

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

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

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

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

src/Lunr/Shadow/Tests/LunrCliParserCheckObligatoryArgumentTest.php

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
* @covers Lunr\Shadow\LunrCliParser
1717
*/
18-
class LunrCliParserCheckObligatoryArgumentTest extends LunrCliParserTest
18+
class LunrCliParserCheckObligatoryArgumentTest extends LunrCliParserTestCase
1919
{
2020

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

0 commit comments

Comments
 (0)