8000 don't rely on internal sort implementation in test · symfony/symfony@3011fa0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3011fa0

Browse files
committed
don't rely on internal sort implementation in test
PHP does not guarantuee how array elements with the same value will be sorted when applying `asort()`. Since all namespaces used in the test produce the same Levenshtein value, we should only check for presence of these namespaces instead of comparing the exact order.
1 parent e610b41 commit 3011fa0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Symfony/Component/Console/Tests/ApplicationTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,10 @@ public function testFindAlternativeNamespace()
441441
$this->fail('->find() throws a CommandNotFoundException if namespace does not exist');
442442
} catch (\Exception $e) {
443443
$this->assertInstanceOf('Symfony\Component\Console\Exception\CommandNotFoundException', $e, '->find() throws a CommandNotFoundException if namespace does not exist');
444-
$this->assertSame(array('foo3', 'foo1', 'foo'), $e->getAlternatives());
444+
$this->assertCount(3, $e->getAlternatives());
445+
$this->assertContains('foo', $e->getAlternatives());
446+
$this->assertContains('foo1', $e->getAlternatives());
447+
$this->assertContains('foo3', $e->getAlternatives());
445448
$this->assertRegExp('/There are no commands defined in the "foo2" namespace./', $e->getMessage(), '->find() throws a CommandNotFoundException if namespace does not exist, with alternative');
446449
$this->assertRegExp('/foo/', $e->getMessage(), '->find() throws a CommandNotFoundException if namespace does not exist, with alternative : "foo"');
447450
$this->assertRegExp('/foo1/', $e->getMessage(), '->find() throws a CommandNotFoundException if namespace does not exist, with alternative : "foo1"');

0 commit comments

Comments
 (0)
0