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

Skip to content

[SCA] Minor fixes on tests #37592

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 23, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function testEncodeNoPasswordNoInteraction()
], ['interactive' => false]);

$this->assertStringContainsString('[ERROR] The password must not be empty.', $this->passwordEncoderCommandTester->getDisplay());
$this->assertEquals($statusCode, 1);
$this->assertEquals(1, $statusCode);
}

public function testEncodePasswordBcrypt()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ public function testPreviousError()

$flattened = FlattenException::create($exception)->getPrevious();

$this->assertEquals($flattened->getMessage(), 'Parse error: Oh noes!', 'The message is copied from the original exception.');
$this->assertEquals($flattened->getCode(), 42, 'The code is copied from the original exception.');
$this->assertEquals($flattened->getClass(), 'Symfony\Component\Debug\Exception\FatalThrowableError', 'The class is set to the class of the original exception');
$this->assertEquals('Parse error: Oh noes!', $flattened->getMessage(), 'The message is copied from the original exception.');
$this->assertEquals(42, $flattened->getCode(), 'The code is copied from the original exception.');
$this->assertEquals('Symfony\Component\Debug\Exception\FatalThrowableError', $flattened->getClass(), 'The class is set to the class of the original exception');
}

/**
Expand Down Expand Up @@ -259,7 +259,7 @@ function () {},
$this->assertSame(['float', INF], $array[$i++]);

// assertEquals() does not like NAN values.
$this->assertEquals($array[$i][0], 'float');
$this->assertEquals('float', $array[$i][0]);
$this->assertNan($array[$i][1]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -846,12 +846,12 @@ public function testfindTaggedServiceIds()
->addTag('bar', ['bar' => 'bar'])
->addTag('foo', ['foofoo' => 'foofoo'])
;
$this->assertEquals($builder->findTaggedServiceIds('foo'), [
$this->assertEquals([
'foo' => [
['foo' => 'foo'],
['foofoo' => 'foofoo'],
],
], '->findTaggedServiceIds() returns an array of service ids and its tag attributes');
], $builder->findTaggedServiceIds('foo'), '->findTaggedServiceIds() returns an array of service ids and its tag attributes');
$this->assertEquals([], $builder->findTaggedServiceIds('foobar'), '->findTaggedServiceIds() returns an empty array if there is annotated services');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,10 @@ public function testTags()
$def->addTag('foo', ['foo' => 'bar']);
$this->assertEquals([[], ['foo' => 'bar']], $def->getTag('foo'), '->addTag() can adds the same tag several times');
$def->addTag('bar', ['bar' => 'bar']);
$this->assertEquals($def->getTags(), [
$this->assertEquals([
'foo' => [[], ['foo' => 'bar']],
'bar' => [['bar' => 'bar']],
], '->getTags() returns all tags');
], $def->getTags(), '->getTags() returns all tags');
}

public function testSetArgument()
Expand Down
25 changes: 14 additions & 11 deletions src/Symfony/Component/DomCrawler/Tests/FormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,25 +170,28 @@ public function testMultiValuedFields()
');

$this->assertEquals(
array_keys($form->all()),
['foo[2]', 'foo[3]', 'bar[foo][0]', 'bar[foo][foobar]']
['foo[2]', 'foo[3]', 'bar[foo][0]', 'bar[foo][foobar]'],
array_keys($form->all())
);

$this->assertEquals($form->get('foo[2]')->getValue(), 'foo');
$this->assertEquals($form->get('foo[3]')->getValue(), 'foo');
$this->assertEquals($form->get('bar[foo][0]')->getValue(), 'foo');
$this->assertEquals($form->get('bar[foo][foobar]')->getValue(), 'foo');
$this->assertEquals('foo', $form->get('foo[2]')->getValue());
$this->assertEquals('foo', $form->get('foo[3]')->getValue());
$this->assertEquals('foo', $form->get('bar[foo][0]')->getValue());
$this->assertEquals('foo', $form->get('bar[foo][foobar]')->getValue());

$form['foo[2]'] = 'bar';
$form['foo[3]'] = 'bar';

$this->assertEquals($form->get('foo[2]')->getValue(), 'bar');
$this->assertEquals($form->get('foo[3]')->getValue(), 'bar');
$this->assertEquals('bar', $form->get('foo[2]')->getValue());
$this->assertEquals('bar', $form->get('foo[3]')->getValue());

$form['bar'] = ['foo' => ['0' => 'bar', 'foobar' => 'foobar']];

$this->assertEquals($form->get('bar[foo][0]')->getValue(), 'bar');
$this->assertEquals($form->get('bar[foo][foobar]')->getValue(), 'foobar');
$this->assertEquals('bar', $form->get('bar[foo][0]')->getValue());
$this->assertEquals(
'foobar',
$form->get('bar[foo][foobar]')->getValue()
);
}

/**
Expand Down Expand Up @@ -967,7 +970,7 @@ public function testGetPhpValuesWithEmptyTextarea()

$nodes = $dom->getElementsByTagName('form');
$form = new Form($nodes->item(0), 'http://example.com');
$this->assertEquals($form->getPhpValues(), ['example' => '']);
$this->assertEquals(['example' => ''], $form->getPhpValues());
}

public function testGetReturnTypes()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public function testGetItem()

$cacheItem = $parserCacheAdapter->getItem($key);

$this->assertEquals($cacheItem->get(), $value);
$this->assertEquals($cacheItem->isHit(), true);
$this->assertEquals($value, $cacheItem->get());
$this->assertTrue($cacheItem->isHit());
}

public function testSave()
Expand Down
8 changes: 4 additions & 4 deletions src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -592,20 +592,20 @@ public function testSetCache()

$options = ['etag' => '"whatever"'];
$response->setCache($options);
$this->assertEquals($response->getEtag(), '"whatever"');
$this->assertEquals('"whatever"', $response->getEtag());

$now = $this->createDateTimeNow();
$options = ['last_modified' => $now];
$response->setCache($options);
$this->assertEquals($response->getLastModified()->getTimestamp(), $now->getTimestamp());
$this->assertEquals($now->getTimestamp(), $response->getLastModified()->getTimestamp());

$options = ['max_age' => 100];
$response->setCache($options);
$this->assertEquals($response->getMaxAge(), 100);
$this->assertEquals(100, $response->getMaxAge());

$options = ['s_maxage' => 200];
$response->setCache($options);
$this->assertEquals($response->getMaxAge(), 200);
$this->assertEquals(200, $response->getMaxAge());

$this->assertTrue($response->headers->hasCacheControlDirective('public'));
$this->assertFalse($response->headers->hasCacheControlDirective('private'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function testRead()
->method('findOne')
->willReturnCallback(function ($criteria) use ($testTimeout) {
$this->assertArrayHasKey($this->options['id_field'], $criteria);
$this->assertEquals($criteria[$this->options['id_field']], 'foo');
$this->assertEquals('foo', $criteria[$this->options['id_field']]);

$this->assertArrayHasKey($this->options['expiry_field'], $criteria);
$this->assertArrayHasKey('$gte', $criteria[$this->options['expiry_field']]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ public function testClear()
$_SESSION['drak'] = 'loves symfony';
$storage->getBag('attributes')->set('symfony', 'greatness');
$key = $storage->getBag('attributes')->getStorageKey();
$this->assertEquals($_SESSION[$key], ['symfony' => 'greatness']);
$this->assertEquals($_SESSION['drak'], 'loves symfony');
$this->assertEquals(['symfony' => 'greatness'], $_SESSION[$key]);
$this->assertEquals('loves symfony', $_SESSION['drak']);
$storage->clear();
$this->assertEquals($_SESSION[$key], []);
$this->assertEquals($_SESSION['drak'], 'loves symfony');
$this->assertEquals([], $_SESSION[$key]);
$this->assertEquals('loves symfony', $_SESSION['drak']);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ class FilterControllerArgumentsEventTest extends TestCase
public function testFilterControllerArgumentsEvent()
{
$filterController = new FilterControllerArgumentsEvent(new TestHttpKernel(), function () {}, ['test'], new Request(), 1);
$this->assertEquals($filterController->getArguments(), ['test']);
$this->assertEquals(['test'], $filterController->getArguments());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,9 @@ public function testStoreTime()

$records = $this->storage->find('', '', 3, 'GET', $start, time() + 3 * 60);
$this->assertCount(3, $records, '->find() returns all previously added records');
$this->assertEquals($records[0]['token'], 'time_2', '->find() returns records ordered by time in descendant order');
$this->assertEquals($records[1]['token'], 'time_1', '->find() returns records ordered by time in descendant order');
$this->assertEquals($records[2]['token'], 'time_0', '->find() returns records ordered by time in descendant order');
$this->assertEquals('time_2', $records[0]['token'], '->find() returns records ordered by time in descendant order');
$this->assertEquals('time_1', $records[1]['token'], '->find() returns records ordered by time in descendant order');
$this->assertEquals('time_0', $records[2]['token'], '->find() returns records ordered by time in descendant order');

$records = $this->storage->find('', '', 3, 'GET', $start, time() + 2 * 60);
$this->assertCount(2, $records, '->find() should return only first two of the previously added records');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ public function testLdapQueryScopeBase()
$ldap->getConnection()->bind('cn=admin,dc=symfony,dc=com', 'symfony');

$query = $ldap->createQuery('cn=Fabien Potencier,dc=symfony,dc=com', '(objectclass=*)', [
'scope' => Query::SCOPE_BASE,
'scope' => Query::SCOPE_BASE,
]);
$result = $query->execute();

$entry = $result[0];
$this->assertEquals($result->count(), 1);
$this->assertEquals(1, $result->count());
$this->assertEquals(['Fabien Potencier'], $entry->getAttribute('cn'));
}

Expand All @@ -109,7 +109,7 @@ public function testLdapQueryScopeOneLevel()
$subtree_count = $ldap->createQuery('ou=Components,dc=symfony,dc=com', '(objectclass=*)')->execute()->count();

$this->assertNotEquals($one_level_result->count(), $subtree_count);
$this->assertEquals($one_level_result->count(), 1);
$this->assertEquals($one_level_result[0]->getAttribute('ou'), ['Ldap']);
$this->assertEquals(1, $one_level_result->count());
$this->assertEquals(['Ldap'], $one_level_result[0]->getAttribute('ou'));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public function testLdapRename()

$result = $this->executeSearchQuery(1);
$renamedEntry = $result[0];
$this->assertEquals($renamedEntry->getAttribute('cn')[0], 'Kevin');
$this->assertEquals('Kevin', $renamedEntry->getAttribute('cn')[0]);

$oldRdn = $entry->getAttribute('cn')[0];
$entryManager->rename($renamedEntry, 'cn='.$oldRdn);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ public function testFindArguments()
$f = new PhpExecutableFinder();

if (\defined('HHVM_VERSION')) {
$this->assertEquals($f->findArguments(), ['--php'], '::findArguments() returns HHVM arguments');
$this->assertEquals(['--php'], $f->findArguments(), '::findArguments() returns HHVM arguments');
} elseif ('phpdbg' === \PHP_SAPI) {
$this->assertEquals($f->findArguments(), ['-qrr'], '::findArguments() returns phpdbg arguments');
$this->assertEquals(['-qrr'], $f->findArguments(), '::findArguments() returns phpdbg arguments');
} else {
$this->assertEquals($f->findArguments(), [], '::findArguments() returns no arguments');
$this->assertEquals([], $f->findArguments(), '::findArguments() returns no arguments');
}
}
}
4 changes: 2 additions & 2 deletions src/Symfony/Component/Templating/Tests/PhpEngineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,9 @@ public function testGlobalsGetPassedToTemplate()

$this->loader->setTemplate('global.php', '<?php echo $global; ?>');

$this->assertEquals($engine->render('global.php'), 'global variable');
$this->assertEquals('global variable', $engine->render('global.php'));

$this->assertEquals($engine->render('global.php', ['global' => 'overwritten']), 'overwritten');
$this->assertEquals('overwritten', $engine->render('global.php', ['global' => 'overwritten']));
}

public function testGetLoader()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ protected function validateMatrix($nplural, $matrix, $expectSuccess = true)
foreach ($matrix as $langCode => $data) {
$indexes = array_flip($data);
if ($expectSuccess) {
$this->assertEquals($nplural, \count($indexes), "Langcode '$langCode' has '$nplural' plural forms.");
$this->assertCount((int) $nplural, $indexes, "Langcode '$langCode' has '$nplural' plural forms.");
} else {
$this->assertNotEquals((int) $nplural, \count($indexes), "Langcode '$langCode' has '$nplural' plural forms.");
$this->assertNotCount((int) $nplural, $indexes, "Langcode '$langCode' has '$nplural' plural forms.");
}
}
}
Expand Down