Skip to content

Commit ceae6bb

Browse files
committed
Merge branch '4.4' into 5.1
* 4.4: Use ::class keyword when possible
2 parents c5a4609 + 096c4d3 commit ceae6bb

22 files changed

+116
-116
lines changed

Tests/ApplicationTest.php

Lines changed: 57 additions & 57 deletions
Large diffs are not rendered by default.

Tests/CommandLoader/ContainerCommandLoaderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function testGet()
4343

4444
public function testGetUnknownCommandThrows()
4545
{
46-
$this->expectException('Symfony\Component\Console\Exception\CommandNotFoundException');
46+
$this->expectException(\Symfony\Component\Console\Exception\CommandNotFoundException::class);
4747
(new ContainerCommandLoader(new ServiceLocator([]), []))->get('unknown');
4848
}
4949

Tests/CommandLoader/FactoryCommandLoaderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function testGet()
4242

4343
public function testGetUnknownCommandThrows()
4444
{
45-
$this->expectException('Symfony\Component\Console\Exception\CommandNotFoundException');
45+
$this->expectException(\Symfony\Component\Console\Exception\CommandNotFoundException::class);
4646
(new FactoryCommandLoader([]))->get('unknown');
4747
}
4848

Tests/DependencyInjection/AddConsoleCommandPassTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public function visibilityProvider()
120120

121121
public function testProcessThrowAnExceptionIfTheServiceIsAbstract()
122122
{
123-
$this->expectException('InvalidArgumentException');
123+
$this->expectException(\InvalidArgumentException::class);
124124
$this->expectExceptionMessage('The service "my-command" tagged "console.command" must not be abstract.');
125125
$container = new ContainerBuilder();
126126
$container->setResourceTracking(false);
@@ -136,7 +136,7 @@ public function testProcessThrowAnExceptionIfTheServiceIsAbstract()
136136

137137
public function testProcessThrowAnExceptionIfTheServiceIsNotASubclassOfCommand()
138138
{
139-
$this->expectException('InvalidArgumentException');
139+
$this->expectException(\InvalidArgumentException::class);
140140
$this->expectExceptionMessage('The service "my-command" tagged "console.command" must be a subclass of "Symfony\Component\Console\Command\Command".');
141141
$container = new ContainerBuilder();
142142
$container->setResourceTracking(false);
@@ -221,7 +221,7 @@ public function testProcessOnChildDefinitionWithParentClass()
221221

222222
public function testProcessOnChildDefinitionWithoutClass()
223223
{
224-
$this->expectException('RuntimeException');
224+
$this->expectException(\RuntimeException::class);
225225
$this->expectExceptionMessage('The definition for "my-child-command" has no class.');
226226
$container = new ContainerBuilder();
227227
$container->addCompilerPass(new AddConsoleCommandPass(), PassConfig::TYPE_BEFORE_REMOVING);

Tests/Formatter/OutputFormatterStyleStackTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function testPopNotLast()
6161

6262
public function testInvalidPop()
6363
{
64-
$this->expectException('InvalidArgumentException');
64+
$this->expectException(\InvalidArgumentException::class);
6565
$stack = new OutputFormatterStyleStack();
6666
$stack->push(new OutputFormatterStyle('white', 'black'));
6767
$stack->pop(new OutputFormatterStyle('yellow', 'blue'));

Tests/Formatter/OutputFormatterStyleTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function testForeground()
4141
$style->setForeground('default');
4242
$this->assertEquals("\033[39mfoo\033[39m", $style->apply('foo'));
4343

44-
$this->expectException('InvalidArgumentException');
44+
$this->expectException(\InvalidArgumentException::class);
4545
$style->setForeground('undefined-color');
4646
}
4747

@@ -58,7 +58,7 @@ public function testBackground()
5858
$style->setBackground('default');
5959
$this->assertEquals("\033[49mfoo\033[49m", $style->apply('foo'));
6060

61-
$this->expectException('InvalidArgumentException');
61+
$this->expectException(\InvalidArgumentException::class);
6262
$style->setBackground('undefined-color');
6363
}
6464

Tests/Helper/HelperSetTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function testGet()
6868
$this->fail('->get() throws InvalidArgumentException when helper not found');
6969
} catch (\Exception $e) {
7070
$this->assertInstanceOf(\InvalidArgumentException::class, $e, '->get() throws InvalidArgumentException when helper not found');
71-
$this->assertInstanceOf('Symfony\Component\Console\Exception\ExceptionInterface', $e, '->get() throws domain specific exception when helper not found');
71+
$this->assertInstanceOf(\Symfony\Component\Console\Exception\ExceptionInterface::class, $e, '->get() throws domain specific exception when helper not found');
7272
$this->assertStringContainsString('The helper "foo" is not defined.', $e->getMessage(), '->get() throws InvalidArgumentException when helper not found');
7373
}
7474
}

Tests/Helper/ProgressIndicatorTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,14 @@ public function testCustomIndicatorValues()
102102

103103
public function testCannotSetInvalidIndicatorCharacters()
104104
{
105-
$this->expectException('InvalidArgumentException');
105+
$this->expectException(\InvalidArgumentException::class);
106106
$this->expectExceptionMessage('Must have at least 2 indicator value characters.');
107107
new ProgressIndicator($this->getOutputStream(), null, 100, ['1']);
108108
}
109109

110110
public function testCannotStartAlreadyStartedIndicator()
111111
{
112-
$this->expectException('LogicException');
112+
$this->expectException(\LogicException::class);
113113
$this->expectExceptionMessage('Progress indicator already started.');
114114
$bar = new ProgressIndicator($this->getOutputStream());
115115
$bar->start('Starting...');
@@ -118,15 +118,15 @@ public function testCannotStartAlreadyStartedIndicator()
118118

119119
public function testCannotAdvanceUnstartedIndicator()
120120
{
121-
$this->expectException('LogicException');
121+
$this->expectException(\LogicException::class);
122122
$this->expectExceptionMessage('Progress indicator has not yet been started.');
123123
$bar = new ProgressIndicator($this->getOutputStream());
124124
$bar->advance();
125125
}
126126

127127
public function testCannotFinishUnstartedIndicator()
128128
{
129-
$this->expectException('LogicException');
129+
$this->expectException(\LogicException::class);
130130
$this->expectExceptionMessage('Progress indicator has not yet been started.');
131131
$bar = new ProgressIndicator($this->getOutputStream());
132132
$bar->finish('Finished');

Tests/Helper/QuestionHelperTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ public function testSelectChoiceFromChoiceList($providedAnswer, $expectedValue)
633633

634634
public function testAmbiguousChoiceFromChoicelist()
635635
{
636-
$this->expectException('InvalidArgumentException');
636+
$this->expectException(\InvalidArgumentException::class);
637637
$this->expectExceptionMessage('The provided answer is ambiguous. Value should be one of "env_2" or "env_3".');
638638
$possibleChoices = [
639639
'env_1' => 'My first environment',
@@ -700,23 +700,23 @@ public function testChoiceOutputFormattingQuestionForUtf8Keys()
700700

701701
public function testAskThrowsExceptionOnMissingInput()
702702
{
703-
$this->expectException('Symfony\Component\Console\Exception\MissingInputException');
703+
$this->expectException(\Symfony\Component\Console\Exception\MissingInputException::class);
704704
$this->expectExceptionMessage('Aborted.');
705705
$dialog = new QuestionHelper();
706706
$dialog->ask($this->createStreamableInputInterfaceMock($this->getInputStream('')), $this->createOutputInterface(), new Question('What\'s your name?'));
707707
}
708708

709709
public function testAskThrowsExceptionOnMissingInputForChoiceQuestion()
710710
{
711-
$this->expectException('Symfony\Component\Console\Exception\MissingInputException');
711+
$this->expectException(\Symfony\Component\Console\Exception\MissingInputException::class);
712712
$this->expectExceptionMessage('Aborted.');
713713
$dialog = new QuestionHelper();
714714
$dialog->ask($this->createStreamableInputInterfaceMock($this->getInputStream('')), $this->createOutputInterface(), new ChoiceQuestion('Choice', ['a', 'b']));
715715
}
716716

717717
public function testAskThrowsExceptionOnMissingInputWithValidator()
718718
{
719-
$this->expectException('Symfony\Component\Console\Exception\MissingInputException');
719+
$this->expectException(\Symfony\Component\Console\Exception\MissingInputException::class);
720720
$this->expectExceptionMessage('Aborted.');
721721
$dialog = new QuestionHelper();
722722

@@ -764,7 +764,7 @@ public function testQuestionValidatorRepeatsThePrompt()
764764

765765
public function testEmptyChoices()
766766
{
767-
$this->expectException('LogicException');
767+
$this->expectException(\LogicException::class);
768768
$this->expectExceptionMessage('Choice question must have at least 1 choice available.');
769769
new ChoiceQuestion('Question', [], 'irrelevant');
770770
}
@@ -897,7 +897,7 @@ protected function createOutputInterface()
897897

898898
protected function createInputInterfaceMock($interactive = true)
899899
{
900-
$mock = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock();
900+
$mock = $this->getMockBuilder(\Symfony\Component\Console\Input\InputInterface::class)->getMock();
901901
$mock->expects($this->any())
902902
->method('isInteractive')
903903
->willReturn($interactive);

Tests/Helper/SymfonyQuestionHelperTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public function testLabelTrailingBackslash()
124124

125125
public function testAskThrowsExceptionOnMissingInput()
126126
{
127-
$this->expectException('Symfony\Component\Console\Exception\RuntimeException');
127+
$this->expectException(\Symfony\Component\Console\Exception\RuntimeException::class);
128128
$this->expectExceptionMessage('Aborted.');
129129
$dialog = new SymfonyQuestionHelper();
130130
$dialog->ask($this->createStreamableInputInterfaceMock($this->getInputStream('')), $this->createOutputInterface(), new Question('What\'s your name?'));
@@ -192,7 +192,7 @@ protected function createOutputInterface()
192192

193193
protected function createInputInterfaceMock($interactive = true)
194194
{
195-
$mock = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock();
195+
$mock = $this->getMockBuilder(\Symfony\Component\Console\Input\InputInterface::class)->getMock();
196196
$mock->expects($this->any())
197197
->method('isInteractive')
198198
->willReturn($interactive);

0 commit comments

Comments
 (0)