Skip to content

Commit

Permalink
minor #32998 SCA: dropped unused mocks, duplicate import and a functi…
Browse files Browse the repository at this point in the history
…on alias usage (kalessil)

This PR was squashed before being merged into the 3.4 branch (closes #32998).

Discussion
----------

SCA: dropped unused mocks, duplicate import and a function alias usage

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

Commits
-------

484668f SCA: dropped unused mocks, duplicate import and a function alias usage
  • Loading branch information
nicolas-grekas committed Aug 7, 2019
2 parents 6af3c6b + 484668f commit 6d2e3ee
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 19 deletions.
Expand Up @@ -14,23 +14,22 @@
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Definition\Builder\FloatNodeDefinition;
use Symfony\Component\Config\Definition\Builder\IntegerNodeDefinition;
use Symfony\Component\Config\Definition\Builder\IntegerNodeDefinition as NumericNodeDefinition;

class NumericNodeDefinitionTest extends TestCase
{
public function testIncoherentMinAssertion()
{
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage('You cannot define a min(4) as you already have a max(3)');
$def = new NumericNodeDefinition('foo');
$def = new IntegerNodeDefinition('foo');
$def->max(3)->min(4);
}

public function testIncoherentMaxAssertion()
{
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage('You cannot define a max(2) as you already have a min(3)');
$node = new NumericNodeDefinition('foo');
$node = new IntegerNodeDefinition('foo');
$node->min(3)->max(2);
}

Expand Down Expand Up @@ -84,7 +83,7 @@ public function testCannotBeEmptyThrowsAnException()
{
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidDefinitionException');
$this->expectExceptionMessage('->cannotBeEmpty() is not applicable to NumericNodeDefinition.');
$def = new NumericNodeDefinition('foo');
$def = new IntegerNodeDefinition('foo');
$def->cannotBeEmpty();
}
}
Expand Up @@ -70,7 +70,6 @@ public function testCachedParseWithDeprecatedParserCacheInterface()
{
$cacheMock = $this->getMockBuilder('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface')->getMock();

$cacheItemMock = $this->getMockBuilder('Psr\Cache\CacheItemInterface')->getMock();
$savedParsedExpression = null;
$expressionLanguage = new ExpressionLanguage($cacheMock);

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Ldap/Tests/LdapTestCase.php
Expand Up @@ -14,7 +14,7 @@ protected function getLdapConfig()
$this->markTestSkipped('No server is listening on LDAP_HOST:LDAP_PORT');
}

ldap_close($h);
ldap_unbind($h);

return [
'host' => getenv('LDAP_HOST'),
Expand Down
Expand Up @@ -85,13 +85,6 @@ public function testHandleAuthenticationFailure()
*/
public function testHandleAuthenticationClearsToken($tokenClass, $tokenProviderKey, $actualProviderKey)
{
$token = $this->getMockBuilder($tokenClass)
->disableOriginalConstructor()
->getMock();
$token->expects($this->any())
->method('getProviderKey')
->willReturn($tokenProviderKey);

$this->tokenStorage->expects($this->never())
->method('setToken')
->with(null);
Expand Down
Expand Up @@ -74,8 +74,6 @@ public function testHandleWhenAuthenticationFails()
'PHP_AUTH_PW' => 'ThePassword',
]);

$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();

$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
$tokenStorage
->expects($this->any())
Expand Down
Expand Up @@ -124,7 +124,6 @@ public function testLoginSuccessIsNotProcessedWhenTokenDoesNotContainUserInterfa
$service = $this->getService(null, ['name' => 'foo', 'always_remember_me' => true, 'path' => null, 'domain' => null]);
$request = new Request();
$response = new Response();
$account = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$token
->expects($this->once())
Expand Down
Expand Up @@ -50,14 +50,11 @@ public function testProcessMissingAlias()
{
$this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException');
$this->expectExceptionMessage('The alias for the tag "translation.extractor" of service "foo.id" must be set.');
$definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->disableOriginalConstructor()->getMock();
$container = new ContainerBuilder();
$container->register('translation.extractor');
$container->register('foo.id')
->addTag('translation.extractor', []);

$definition->expects($this->never())->method('addMethodCall');

$translationDumperPass = new TranslationExtractorPass();
$translationDumperPass->process($container);
}
Expand Down

0 comments on commit 6d2e3ee

Please sign in to comment.