Skip to content

Commit

Permalink
replaced assertType by the new assertInstanceOf in unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pborreli authored and fabpot committed Apr 26, 2010
1 parent 9eb3607 commit 7065957
Show file tree
Hide file tree
Showing 33 changed files with 113 additions and 113 deletions.
14 changes: 7 additions & 7 deletions tests/Symfony/Tests/Components/Console/ApplicationTest.php
Expand Up @@ -111,7 +111,7 @@ public function testHasGetCommand()
}
catch (\Exception $e)
{
$this->assertType('\InvalidArgumentException', $e, '->getCommand() throws an \InvalidArgumentException if the command does not exist');
$this->assertInstanceOf('\InvalidArgumentException', $e, '->getCommand() throws an \InvalidArgumentException if the command does not exist');
$this->assertEquals('The command "foofoo" does not exist.', $e->getMessage(), '->getCommand() throws an \InvalidArgumentException if the command does not exist');
}

Expand Down Expand Up @@ -145,7 +145,7 @@ public function testFindNamespace()
}
catch (\Exception $e)
{
$this->assertType('\InvalidArgumentException', $e, '->findNamespace() throws an \InvalidArgumentException if the abbreviation is ambiguous');
$this->assertInstanceOf('\InvalidArgumentException', $e, '->findNamespace() throws an \InvalidArgumentException if the abbreviation is ambiguous');
$this->assertEquals('The namespace "f" is ambiguous (foo, foo1).', $e->getMessage(), '->findNamespace() throws an \InvalidArgumentException if the abbreviation is ambiguous');
}

Expand All @@ -156,7 +156,7 @@ public function testFindNamespace()
}
catch (\Exception $e)
{
$this->assertType('\InvalidArgumentException', $e, '->findNamespace() throws an \InvalidArgumentException if no command is in the given namespace');
$this->assertInstanceOf('\InvalidArgumentException', $e, '->findNamespace() throws an \InvalidArgumentException if no command is in the given namespace');
$this->assertEquals('There are no commands defined in the "bar" namespace.', $e->getMessage(), '->findNamespace() throws an \InvalidArgumentException if no command is in the given namespace');
}
}
Expand All @@ -181,7 +181,7 @@ public function testFindCommand()
}
catch (\Exception $e)
{
$this->assertType('\InvalidArgumentException', $e, '->findCommand() throws an \InvalidArgumentException if the abbreviation is ambiguous for a namespace');
$this->assertInstanceOf('\InvalidArgumentException', $e, '->findCommand() throws an \InvalidArgumentException if the abbreviation is ambiguous for a namespace');
$this->assertEquals('Command "f" is not defined.', $e->getMessage(), '->findCommand() throws an \InvalidArgumentException if the abbreviation is ambiguous for a namespace');
}

Expand All @@ -192,7 +192,7 @@ public function testFindCommand()
}
catch (\Exception $e)
{
$this->assertType('\InvalidArgumentException', $e, '->findCommand() throws an \InvalidArgumentException if the abbreviation is ambiguous for an alias');
$this->assertInstanceOf('\InvalidArgumentException', $e, '->findCommand() throws an \InvalidArgumentException if the abbreviation is ambiguous for an alias');
$this->assertEquals('Command "a" is ambiguous (afoobar, afoobar1 and 1 more).', $e->getMessage(), '->findCommand() throws an \InvalidArgumentException if the abbreviation is ambiguous for an alias');
}

Expand All @@ -203,7 +203,7 @@ public function testFindCommand()
}
catch (\Exception $e)
{
$this->assertType('\InvalidArgumentException', $e, '->findCommand() throws an \InvalidArgumentException if the abbreviation is ambiguous for a command');
$this->assertInstanceOf('\InvalidArgumentException', $e, '->findCommand() throws an \InvalidArgumentException if the abbreviation is ambiguous for a command');
$this->assertEquals('Command "foo:b" is ambiguous (foo:bar, foo:bar1).', $e->getMessage(), '->findCommand() throws an \InvalidArgumentException if the abbreviation is ambiguous for a command');
}
}
Expand All @@ -226,7 +226,7 @@ public function testSetCatchExceptions()
}
catch (\Exception $e)
{
$this->assertType('\Exception', $e, '->setCatchExceptions() sets the catch exception flag');
$this->assertInstanceOf('\Exception', $e, '->setCatchExceptions() sets the catch exception flag');
$this->assertEquals('Command "foo" is not defined.', $e->getMessage(), '->setCatchExceptions() sets the catch exception flag');
}
}
Expand Down
10 changes: 5 additions & 5 deletions tests/Symfony/Tests/Components/Console/Command/CommandTest.php
Expand Up @@ -43,7 +43,7 @@ public function testConstructor()
}
catch (\Exception $e)
{
$this->assertType('\LogicException', $e, '__construct() throws a \LogicException if the name is null');
$this->assertInstanceOf('\LogicException', $e, '__construct() throws a \LogicException if the name is null');
$this->assertEquals('The command name cannot be empty.', $e->getMessage(), '__construct() throws a \LogicException if the name is null');
}
$command = new Command('foo:bar');
Expand Down Expand Up @@ -111,7 +111,7 @@ public function testGetNamespaceGetNameGetFullNameSetName()
}
catch (\Exception $e)
{
$this->assertType('\InvalidArgumentException', $e, '->setName() throws an \InvalidArgumentException if the name is empty');
$this->assertInstanceOf('\InvalidArgumentException', $e, '->setName() throws an \InvalidArgumentException if the name is empty');
$this->assertEquals('A command name cannot be empty.', $e->getMessage(), '->setName() throws an \InvalidArgumentException if the name is empty');
}

Expand All @@ -122,7 +122,7 @@ public function testGetNamespaceGetNameGetFullNameSetName()
}
catch (\Exception $e)
{
$this->assertType('\InvalidArgumentException', $e, '->setName() throws an \InvalidArgumentException if the name is empty');
$this->assertInstanceOf('\InvalidArgumentException', $e, '->setName() throws an \InvalidArgumentException if the name is empty');
$this->assertEquals('A command name cannot be empty.', $e->getMessage(), '->setName() throws an \InvalidArgumentException if the name is empty');
}
}
Expand Down Expand Up @@ -214,7 +214,7 @@ public function testRun()
}
catch (\Exception $e)
{
$this->assertType('\InvalidArgumentException', $e, '->run() throws a \InvalidArgumentException when the input does not validate the current InputDefinition');
$this->assertInstanceOf('\InvalidArgumentException', $e, '->run() throws a \InvalidArgumentException when the input does not validate the current InputDefinition');
$this->assertEquals('The "--bar" option does not exist.', $e->getMessage(), '->run() throws a \InvalidArgumentException when the input does not validate the current InputDefinition');
}

Expand All @@ -229,7 +229,7 @@ public function testRun()
}
catch (\Exception $e)
{
$this->assertType('\LogicException', $e, '->run() throws a \LogicException if the execute() method has not been overriden and no code has been provided');
$this->assertInstanceOf('\LogicException', $e, '->run() throws a \LogicException if the execute() method has not been overriden and no code has been provided');
$this->assertEquals('You must override the execute() method in the concrete command class.', $e->getMessage(), '->run() throws a \LogicException if the execute() method has not been overriden and no code has been provided');
}
}
Expand Down
12 changes: 6 additions & 6 deletions tests/Symfony/Tests/Components/Console/Input/ArgvInputTest.php
Expand Up @@ -53,7 +53,7 @@ public function testParser()
}
catch (\Exception $e)
{
$this->assertType('\RuntimeException', $e, '->parse() throws a \RuntimeException if no parameter is passed to an option when it is required');
$this->assertInstanceOf('\RuntimeException', $e, '->parse() throws a \RuntimeException if no parameter is passed to an option when it is required');
$this->assertEquals('The "--foo" option requires a value.', $e->getMessage(), '->parse() throws a \RuntimeException if no parameter is passed to an option when it is required');
}

Expand Down Expand Up @@ -81,7 +81,7 @@ public function testParser()
}
catch (\Exception $e)
{
$this->assertType('\RuntimeException', $e, '->parse() throws a \RuntimeException if no parameter is passed to an option when it is required');
$this->assertInstanceOf('\RuntimeException', $e, '->parse() throws a \RuntimeException if no parameter is passed to an option when it is required');
$this->assertEquals('The "--foo" option requires a value.', $e->getMessage(), '->parse() throws a \RuntimeException if no parameter is passed to an option when it is required');
}

Expand All @@ -93,7 +93,7 @@ public function testParser()
}
catch (\Exception $e)
{
$this->assertType('\RuntimeException', $e, '->parse() throws a \RuntimeException if a value is passed to an option which does not take one');
$this->assertInstanceOf('\RuntimeException', $e, '->parse() throws a \RuntimeException if a value is passed to an option which does not take one');
$this->assertEquals('The "-o" option does not exist.', $e->getMessage(), '->parse() throws a \RuntimeException if a value is passed to an option which does not take one');
}

Expand All @@ -105,7 +105,7 @@ public function testParser()
}
catch (\Exception $e)
{
$this->assertType('\RuntimeException', $e, '->parse() throws a \RuntimeException if too many arguments are passed');
$this->assertInstanceOf('\RuntimeException', $e, '->parse() throws a \RuntimeException if too many arguments are passed');
$this->assertEquals('Too many arguments.', $e->getMessage(), '->parse() throws a \RuntimeException if too many arguments are passed');
}

Expand All @@ -117,7 +117,7 @@ public function testParser()
}
catch (\Exception $e)
{
$this->assertType('\RuntimeException', $e, '->parse() throws a \RuntimeException if an unknown long option is passed');
$this->assertInstanceOf('\RuntimeException', $e, '->parse() throws a \RuntimeException if an unknown long option is passed');
$this->assertEquals('The "--foo" option does not exist.', $e->getMessage(), '->parse() throws a \RuntimeException if an unknown long option is passed');
}

Expand All @@ -129,7 +129,7 @@ public function testParser()
}
catch (\Exception $e)
{
$this->assertType('\RuntimeException', $e, '->parse() throws a \RuntimeException if an unknown short option is passed');
$this->assertInstanceOf('\RuntimeException', $e, '->parse() throws a \RuntimeException if an unknown short option is passed');
$this->assertEquals('The "-f" option does not exist.', $e->getMessage(), '->parse() throws a \RuntimeException if an unknown short option is passed');
}

Expand Down
Expand Up @@ -49,7 +49,7 @@ public function testParse()
}
catch (\Exception $e)
{
$this->assertType('\InvalidArgumentException', $e, '->parse() throws an \InvalidArgumentException exception if an invalid argument is passed');
$this->assertInstanceOf('\InvalidArgumentException', $e, '->parse() throws an \InvalidArgumentException exception if an invalid argument is passed');
$this->assertEquals('The "foo" argument does not exist.', $e->getMessage(), '->parse() throws an \InvalidArgumentException exception if an invalid argument is passed');
}

Expand All @@ -69,7 +69,7 @@ public function testParse()
}
catch (\Exception $e)
{
$this->assertType('\InvalidArgumentException', $e, '->parse() throws an \InvalidArgumentException exception if a required option is passed without a value');
$this->assertInstanceOf('\InvalidArgumentException', $e, '->parse() throws an \InvalidArgumentException exception if a required option is passed without a value');
$this->assertEquals('The "--foo" option requires a value.', $e->getMessage(), '->parse() throws an \InvalidArgumentException exception if a required option is passed without a value');
}

Expand All @@ -80,7 +80,7 @@ public function testParse()
}
catch (\Exception $e)
{
$this->assertType('\InvalidArgumentException', $e, '->parse() throws an \InvalidArgumentException exception if an invalid option is passed');
$this->assertInstanceOf('\InvalidArgumentException', $e, '->parse() throws an \InvalidArgumentException exception if an invalid option is passed');
$this->assertEquals('The "--foo" option does not exist.', $e->getMessage(), '->parse() throws an \InvalidArgumentException exception if an invalid option is passed');
}

Expand All @@ -94,7 +94,7 @@ public function testParse()
}
catch (\Exception $e)
{
$this->assertType('\InvalidArgumentException', $e, '->parse() throws an \InvalidArgumentException exception if an invalid option is passed');
$this->assertInstanceOf('\InvalidArgumentException', $e, '->parse() throws an \InvalidArgumentException exception if an invalid option is passed');
$this->assertEquals('The "-o" option does not exist.', $e->getMessage(), '->parse() throws an \InvalidArgumentException exception if an invalid option is passed');
}
}
Expand Down
Expand Up @@ -40,7 +40,7 @@ public function testConstructor()
}
catch (\Exception $e)
{
$this->assertType('\Exception', $e, '__construct() throws an Exception if the mode is not valid');
$this->assertInstanceOf('\Exception', $e, '__construct() throws an Exception if the mode is not valid');
$this->assertEquals('Argument mode "ANOTHER_ONE" is not valid.', $e->getMessage());
}
}
Expand Down Expand Up @@ -87,7 +87,7 @@ public function testSetDefault()
}
catch (\Exception $e)
{
$this->assertType('\Exception', $e, '->parse() throws an \InvalidArgumentException exception if an invalid option is passed');
$this->assertInstanceOf('\Exception', $e, '->parse() throws an \InvalidArgumentException exception if an invalid option is passed');
$this->assertEquals('Cannot set a default value except for Parameter::OPTIONAL mode.', $e->getMessage());
}

Expand All @@ -99,7 +99,7 @@ public function testSetDefault()
}
catch (\Exception $e)
{
$this->assertType('\Exception', $e, '->setDefault() throws an Exception if you give a default value which is not an array for a IS_ARRAY option');
$this->assertInstanceOf('\Exception', $e, '->setDefault() throws an Exception if you give a default value which is not an array for a IS_ARRAY option');
$this->assertEquals('A default value for an array argument must be an array.', $e->getMessage());
}
}
Expand Down
Expand Up @@ -86,7 +86,7 @@ public function testAddArgument()
}
catch (\Exception $e)
{
$this->assertType('\Exception', $e, '->addArgument() throws a Exception if another argument is already registered with the same name');
$this->assertInstanceOf('\Exception', $e, '->addArgument() throws a Exception if another argument is already registered with the same name');
$this->assertEquals('An argument with name "foo" already exist.', $e->getMessage());
}

Expand All @@ -99,7 +99,7 @@ public function testAddArgument()
}
catch (\Exception $e)
{
$this->assertType('\Exception', $e, '->addArgument() throws a Exception if there is an array parameter already registered');
$this->assertInstanceOf('\Exception', $e, '->addArgument() throws a Exception if there is an array parameter already registered');
$this->assertEquals('Cannot add an argument after an array argument.', $e->getMessage());
}

Expand All @@ -114,7 +114,7 @@ public function testAddArgument()
}
catch (\Exception $e)
{
$this->assertType('\Exception', $e, '->addArgument() throws an exception if you try to add a required argument after an optional one');
$this->assertInstanceOf('\Exception', $e, '->addArgument() throws an exception if you try to add a required argument after an optional one');
$this->assertEquals('Cannot add a required argument after an optional one.', $e->getMessage());
}
}
Expand All @@ -133,7 +133,7 @@ public function testGetArgument()
}
catch (\Exception $e)
{
$this->assertType('\Exception', $e, '->getArgument() throws an exception if the InputArgument name does not exist');
$this->assertInstanceOf('\Exception', $e, '->getArgument() throws an exception if the InputArgument name does not exist');
$this->assertEquals('The "bar" argument does not exist.', $e->getMessage());
}
}
Expand Down Expand Up @@ -201,7 +201,7 @@ public function testSetOptions()
}
catch (\Exception $e)
{
$this->assertType('\Exception', $e, '->setOptions() clears all InputOption objects');
$this->assertInstanceOf('\Exception', $e, '->setOptions() clears all InputOption objects');
$this->assertEquals('The "-f" option does not exist.', $e->getMessage());
}
}
Expand Down Expand Up @@ -232,7 +232,7 @@ public function testAddOption()
}
catch (\Exception $e)
{
$this->assertType('\Exception', $e, '->addOption() throws a Exception if the another option is already registered with the same name');
$this->assertInstanceOf('\Exception', $e, '->addOption() throws a Exception if the another option is already registered with the same name');
$this->assertEquals('An option named "foo" already exist.', $e->getMessage());
}
try
Expand All @@ -242,7 +242,7 @@ public function testAddOption()
}
catch (\Exception $e)
{
$this->assertType('\Exception', $e, '->addOption() throws a Exception if the another option is already registered with the same shortcut');
$this->assertInstanceOf('\Exception', $e, '->addOption() throws a Exception if the another option is already registered with the same shortcut');
$this->assertEquals('An option with shortcut "f" already exist.', $e->getMessage());
}
}
Expand All @@ -260,7 +260,7 @@ public function testGetOption()
}
catch (\Exception $e)
{
$this->assertType('\Exception', $e, '->getOption() throws an exception if the option name does not exist');
$this->assertInstanceOf('\Exception', $e, '->getOption() throws an exception if the option name does not exist');
$this->assertEquals('The "--bar" option does not exist.', $e->getMessage());
}
}
Expand Down Expand Up @@ -296,7 +296,7 @@ public function testGetOptionForShortcut()
}
catch (\Exception $e)
{
$this->assertType('\Exception', $e, '->getOption() throws an exception if the shortcut does not exist');
$this->assertInstanceOf('\Exception', $e, '->getOption() throws an exception if the shortcut does not exist');
$this->assertEquals('The "-l" option does not exist.', $e->getMessage());
}
}
Expand Down
Expand Up @@ -29,7 +29,7 @@ public function testConstructor()
}
catch (\Exception $e)
{
$this->assertType('\Exception', $e, '->setDefault() throws an Exception if PARAMETER_IS_ARRAY option is used when an option does not accept a value');
$this->assertInstanceOf('\Exception', $e, '->setDefault() throws an Exception if PARAMETER_IS_ARRAY option is used when an option does not accept a value');
$this->assertEquals('Impossible to have an option mode PARAMETER_IS_ARRAY if the option does not accept a parameter.', $e->getMessage());
}

Expand Down Expand Up @@ -72,7 +72,7 @@ public function testConstructor()
}
catch (\Exception $e)
{
$this->assertType('\Exception', $e, '__construct() throws an Exception if the mode is not valid');
$this->assertInstanceOf('\Exception', $e, '__construct() throws an Exception if the mode is not valid');
$this->assertEquals('Option mode "ANOTHER_ONE" is not valid.', $e->getMessage());
}
}
Expand Down Expand Up @@ -129,7 +129,7 @@ public function testSetDefault()
}
catch (\Exception $e)
{
$this->assertType('\Exception', $e, '->setDefault() throws an Exception if you give a default value for a PARAMETER_NONE option');
$this->assertInstanceOf('\Exception', $e, '->setDefault() throws an Exception if you give a default value for a PARAMETER_NONE option');
$this->assertEquals('Cannot set a default value when using Option::PARAMETER_NONE mode.', $e->getMessage());
}

Expand All @@ -141,7 +141,7 @@ public function testSetDefault()
}
catch (\Exception $e)
{
$this->assertType('\Exception', $e, '->setDefault() throws an Exception if you give a default value which is not an array for a PARAMETER_IS_ARRAY option');
$this->assertInstanceOf('\Exception', $e, '->setDefault() throws an Exception if you give a default value which is not an array for a PARAMETER_IS_ARRAY option');
$this->assertEquals('A default value for an array option must be an array.', $e->getMessage());
}
}
Expand Down

0 comments on commit 7065957

Please sign in to comment.