Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 01db8f0

Browse files
committed
Use TestTrait::assertCommandIsSuccessful() instead of TestTrait::getStatusCode() when possible
1 parent 96ab8ff commit 01db8f0

File tree

11 files changed

+28
-28
lines changed

11 files changed

+28
-28
lines changed

src/Symfony/Bundle/FrameworkBundle/Tests/Command/XliffLintCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function testLintFilesFromBundleDirectory()
5151
['verbosity' => OutputInterface::VERBOSITY_VERBOSE, 'decorated' => false]
5252
);
5353

54-
$this->assertEquals(0, $tester->getStatusCode(), 'Returns 0 in case of success');
54+
$tester->assertCommandIsSuccessful('Returns 0 in case of success');
5555
$this->assertStringContainsString('[OK] All 0 XLIFF files contain valid syntax', trim($tester->getDisplay()));
5656
}
5757

src/Symfony/Bundle/FrameworkBundle/Tests/Command/YamlLintCommandTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function testLintCorrectFile()
4040
['verbosity' => OutputInterface::VERBOSITY_VERBOSE, 'decorated' => false]
4141
);
4242

43-
$this->assertEquals(0, $tester->getStatusCode(), 'Returns 0 in case of success');
43+
$tester->assertCommandIsSuccessful('Returns 0 in case of success');
4444
$this->assertStringContainsString('OK', trim($tester->getDisplay()));
4545
}
4646

@@ -88,7 +88,7 @@ public function testLintFilesFromBundleDirectory()
8888
['verbosity' => OutputInterface::VERBOSITY_VERBOSE, 'decorated' => false]
8989
);
9090

91-
$this->assertEquals(0, $tester->getStatusCode(), 'Returns 0 in case of success');
91+
$tester->assertCommandIsSuccessful('Returns 0 in case of success');
9292
$this->assertStringContainsString('[OK] All 0 YAML files contain valid syntax', trim($tester->getDisplay()));
9393
}
9494

src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public function testRunOnlyWarnsOnUnregistrableCommand()
147147
$tester->run(['command' => 'fine']);
148148
$output = $tester->getDisplay();
149149

150-
$this->assertSame(0, $tester->getStatusCode());
150+
$tester->assertCommandIsSuccessful();
151151
$this->assertStringContainsString('Some commands could not be registered:', $output);
152152
$this->assertStringContainsString('throwing', $output);
153153
$this->assertStringContainsString('fine', $output);
@@ -204,7 +204,7 @@ public function testRunOnlyWarnsOnUnregistrableCommandAtTheEnd()
204204
$tester = new ApplicationTester($application);
205205
$tester->run(['command' => 'list']);
206206

207-
$this->assertSame(0, $tester->getStatusCode());
207+
$tester->assertCommandIsSuccessful();
208208
$display = explode('List commands', $tester->getDisplay());
209209

210210
$this->assertStringContainsString(trim('[WARNING] Some commands could not be registered:'), trim($display[1]));

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolClearCommandTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function testClearPrivatePool()
3333
$tester = $this->createCommandTester();
3434
$tester->execute(['pools' => ['cache.private_pool']], ['decorated' => false]);
3535

36-
$this->assertSame(0, $tester->getStatusCode(), 'cache:pool:clear exits with 0 in case of success');
36+
$tester->assertCommandIsSuccessful('cache:pool:clear exits with 0 in case of success');
3737
$this->assertStringContainsString('Clearing cache pool: cache.private_pool', $tester->getDisplay());
3838
$this->assertStringContainsString('[OK] Cache was successfully cleared.', $tester->getDisplay());
3939
}
@@ -43,7 +43,7 @@ public function testClearPublicPool()
4343
$tester = $this->createCommandTester();
4444
$tester->execute(['pools' => ['cache.public_pool']], ['decorated' => false]);
4545

46-
$this->assertSame(0, $tester->getStatusCode(), 'cache:pool:clear exits with 0 in case of success');
46+
$tester->assertCommandIsSuccessful('cache:pool:clear exits with 0 in case of success');
4747
$this->assertStringContainsString('Clearing cache pool: cache.public_pool', $tester->getDisplay());
4848
$this->assertStringContainsString('[OK] Cache was successfully cleared.', $tester->getDisplay());
4949
}
@@ -53,7 +53,7 @@ public function testClearPoolWithCustomClearer()
5353
$tester = $this->createCommandTester();
5454
$tester->execute(['pools' => ['cache.pool_with_clearer']], ['decorated' => false]);
5555

56-
$this->assertSame(0, $tester->getStatusCode(), 'cache:pool:clear exits with 0 in case of success');
56+
$tester->assertCommandIsSuccessful('cache:pool:clear exits with 0 in case of success');
5757
$this->assertStringContainsString('Clearing cache pool: cache.pool_with_clearer', $tester->getDisplay());
5858
$this->assertStringContainsString('[OK] Cache was successfully cleared.', $tester->getDisplay());
5959
}
@@ -63,7 +63,7 @@ public function testCallClearer()
6363
$tester = $this->createCommandTester();
6464
$tester->execute(['pools' => ['cache.app_clearer']], ['decorated' => false]);
6565

66-
$this->assertSame(0, $tester->getStatusCode(), 'cache:pool:clear exits with 0 in case of success');
66+
$tester->assertCommandIsSuccessful('cache:pool:clear exits with 0 in case of success');
6767
$this->assertStringContainsString('Calling cache clearer: cache.app_clearer', $tester->getDisplay());
6868
$this->assertStringContainsString('[OK] Cache was successfully cleared.', $tester->getDisplay());
6969
}

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolListCommandTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function testListPools()
3030
$tester = $this->createCommandTester(['cache.app', 'cache.system']);
3131
$tester->execute([]);
3232

33-
$this->assertSame(0, $tester->getStatusCode(), 'cache:pool:list exits with 0 in case of success');
33+
$tester->assertCommandIsSuccessful('cache:pool:list exits with 0 in case of success');
3434
$this->assertStringContainsString('cache.app', $tester->getDisplay());
3535
$this->assertStringContainsString('cache.system', $tester->getDisplay());
3636
}
@@ -40,7 +40,7 @@ public function testEmptyList()
4040
$tester = $this->createCommandTester([]);
4141
$tester->execute([]);
4242

43-
$this->assertSame(0, $tester->getStatusCode(), 'cache:pool:list exits with 0 in case of success');
43+
$tester->assertCommandIsSuccessful('cache:pool:list exits with 0 in case of success');
4444
}
4545

4646
private function createCommandTester(array $poolNames)

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ContainerDebugCommandTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public function testGetDeprecation()
161161
$tester = new ApplicationTester($application);
162162
$tester->run(['command' => 'debug:container', '--deprecations' => true]);
163163

164-
$this->assertSame(0, $tester->getStatusCode());
164+
$tester->assertCommandIsSuccessful();
165165
$this->assertStringContainsString('Symfony\Bundle\FrameworkBundle\Controller\Controller', $tester->getDisplay());
166166
$this->assertStringContainsString('/home/hamza/projet/contrib/sf/vendor/symfony/framework-bundle/Controller/Controller.php', $tester->getDisplay());
167167
}
@@ -181,7 +181,7 @@ public function testGetDeprecationNone()
181181
$tester = new ApplicationTester($application);
182182
$tester->run(['command' => 'debug:container', '--deprecations' => true]);
183183

184-
$this->assertSame(0, $tester->getStatusCode());
184+
$tester->assertCommandIsSuccessful();
185185
$this->assertStringContainsString('[OK] There are no deprecations in the logs!', $tester->getDisplay());
186186
}
187187

@@ -199,7 +199,7 @@ public function testGetDeprecationNoFile()
199199
$tester = new ApplicationTester($application);
200200
$tester->run(['command' => 'debug:container', '--deprecations' => true]);
201201

202-
$this->assertSame(0, $tester->getStatusCode());
202+
$tester->assertCommandIsSuccessful();
203203
$this->assertStringContainsString('[WARNING] The deprecation file does not exist', $tester->getDisplay());
204204
}
205205

src/Symfony/Component/Console/Tests/Tester/ApplicationTesterTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,13 @@ public function testSetInputs()
8282
$tester->setInputs(['I1', 'I2', 'I3']);
8383
$tester->run(['command' => 'foo']);
8484

85-
$this->assertSame(0, $tester->getStatusCode());
85+
$tester->assertCommandIsSuccessful();
8686
$this->assertEquals('Q1Q2Q3', $tester->getDisplay(true));
8787
}
8888

8989
public function testGetStatusCode()
9090
{
91-
$this->assertSame(0, $this->tester->getStatusCode(), '->getStatusCode() returns the status code');
91+
$this->tester->assertCommandIsSuccessful('->getStatusCode() returns the status code');
9292
}
9393

9494
public function testErrorOutput()

src/Symfony/Component/Console/Tests/Tester/CommandTesterTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function testGetDisplayWithoutCallingExecuteBefore()
7979

8080
public function testGetStatusCode()
8181
{
82-
$this->assertSame(0, $this->tester->getStatusCode(), '->getStatusCode() returns the status code');
82+
$this->tester->assertCommandIsSuccessful('->getStatusCode() returns the status code');
8383
}
8484

8585
public function testGetStatusCodeWithoutCallingExecuteBefore()
@@ -129,7 +129,7 @@ public function testCommandWithInputs()
129129
$tester->setInputs(['Bobby', 'Fine', 'France']);
130130
$tester->execute([]);
131131

132-
$this->assertEquals(0, $tester->getStatusCode());
132+
$tester->assertCommandIsSuccessful();
133133
$this->assertEquals(implode('', $questions), $tester->getDisplay(true));
134134
}
135135

@@ -154,7 +154,7 @@ public function testCommandWithDefaultInputs()
154154
$tester->setInputs(['', '', '']);
155155
$tester->execute([]);
156156

157-
$this->assertEquals(0, $tester->getStatusCode());
157+
$tester->assertCommandIsSuccessful();
158158
$this->assertEquals(implode('', $questions), $tester->getDisplay(true));
159159
}
160160

@@ -227,7 +227,7 @@ public function testSymfonyStyleCommandWithInputs()
227227
$tester->setInputs(['Bobby', 'Fine', 'France']);
228228
$tester->execute([]);
229229

230-
$this->assertEquals(0, $tester->getStatusCode());
230+
$tester->assertCommandIsSuccessful();
231231
}
232232

233233
public function testErrorOutput()

src/Symfony/Component/Form/Tests/Command/DebugCommandTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function testDebugDateTimeType()
7171
$tester = $this->createCommandTester();
7272
$tester->execute(['class' => 'DateTime'], ['decorated' => false, 'interactive' => false]);
7373

74-
$this->assertEquals(0, $tester->getStatusCode(), 'Returns 0 in case of success');
74+
$tester->assertCommandIsSuccessful('Returns 0 in case of success');
7575
$this->assertStringContainsString('Symfony\Component\Form\Extension\Core\Type\DateTimeType (Block prefix: "datetime")', $tester->getDisplay());
7676
}
7777

@@ -123,7 +123,7 @@ public function testDebugAmbiguousFormTypeInteractive()
123123
$tester->setInputs([0]);
124124
$tester->execute(['class' => 'AmbiguousType'], ['decorated' => false, 'interactive' => true]);
125125

126-
$this->assertEquals(0, $tester->getStatusCode(), 'Returns 0 in case of success');
126+
$tester->assertCommandIsSuccessful('Returns 0 in case of success');
127127
$output = $tester->getDisplay(true);
128128
$this->assertStringMatchesFormat(<<<TXT
129129

src/Symfony/Component/Messenger/Tests/Command/ConsumeMessagesCommandTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function testBasicRun()
6363
'--limit' => 1,
6464
]);
6565

66-
$this->assertSame(0, $tester->getStatusCode());
66+
$tester->assertCommandIsSuccessful();
6767
$this->assertStringContainsString('[OK] Consuming messages from transports "dummy-receiver"', $tester->getDisplay());
6868
}
6969

@@ -96,7 +96,7 @@ public function testRunWithBusOption()
9696
'--limit' => 1,
9797
]);
9898

99-
$this->assertSame(0, $tester->getStatusCode());
99+
$tester->assertCommandIsSuccessful();
100100
$this->assertStringContainsString('[OK] Consuming messages from transports "dummy-receiver"', $tester->getDisplay());
101101
}
102102
}

src/Symfony/Component/Translation/Tests/Command/XliffLintCommandTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function testLintCorrectFile()
3636
['verbosity' => OutputInterface::VERBOSITY_VERBOSE, 'decorated' => false]
3737
);
3838

39-
$this->assertEquals(0, $tester->getStatusCode(), 'Returns 0 in case of success');
39+
$tester->assertCommandIsSuccessful('Returns 0 in case of success');
4040
$this->assertStringContainsString('OK', trim($tester->getDisplay()));
4141
}
4242

@@ -51,7 +51,7 @@ public function testLintCorrectFiles()
5151
['verbosity' => OutputInterface::VERBOSITY_VERBOSE, 'decorated' => false]
5252
);
5353

54-
$this->assertEquals(0, $tester->getStatusCode(), 'Returns 0 in case of success');
54+
$tester->assertCommandIsSuccessful('Returns 0 in case of success');
5555
$this->assertStringContainsString('OK', trim($tester->getDisplay()));
5656
}
5757

@@ -101,7 +101,7 @@ public function testLintTargetLanguageIsCaseInsensitive()
101101

102102
$tester->execute(['filename' => $filename], ['decorated' => false]);
103103

104-
$this->assertEquals(0, $tester->getStatusCode());
104+
$tester->assertCommandIsSuccessful();
105105
$this->assertStringContainsString('[OK] All 1 XLIFF files contain valid syntax.', trim($tester->getDisplay()));
106106
}
107107

@@ -112,7 +112,7 @@ public function testLintSucceedsWhenLocaleInFileAndInTargetLanguageNameUsesDashe
112112

113113
$tester->execute(['filename' => $filename], ['decorated' => false]);
114114

115-
$this->assertSame(0, $tester->getStatusCode());
115+
$tester->assertCommandIsSuccessful();
116116
$this->assertStringContainsString('[OK] All 1 XLIFF files contain valid syntax.', trim($tester->getDisplay()));
117117
}
118118

0 commit comments

Comments
 (0)