Skip to content
Snippets Groups Projects
Commit 892a67a5 authored by Tim van Dijen's avatar Tim van Dijen
Browse files

Fix TooManyArguments

parent db5dcdac
No related branches found
No related tags found
No related merge requests found
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace SimpleSAML\Test\Utils; namespace SimpleSAML\Test\Utils;
use InvalidArgumentException;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use SimpleSAML\Utils\Attributes; use SimpleSAML\Utils\Attributes;
...@@ -21,8 +22,8 @@ class AttributesTest extends TestCase ...@@ -21,8 +22,8 @@ class AttributesTest extends TestCase
// check with empty array as input // check with empty array as input
$attributes = 'string'; $attributes = 'string';
$expected = 'string'; $expected = 'string';
$this->expectException( $this->expectException(InvalidArgumentException::class);
\InvalidArgumentException::class, $this->expectExceptionMessage(
'The attributes array is not an array, it is: '.print_r($attributes, true).'.' 'The attributes array is not an array, it is: '.print_r($attributes, true).'.'
); );
Attributes::getExpectedAttribute($attributes, $expected); Attributes::getExpectedAttribute($attributes, $expected);
...@@ -38,8 +39,8 @@ class AttributesTest extends TestCase ...@@ -38,8 +39,8 @@ class AttributesTest extends TestCase
// check with invalid attribute name // check with invalid attribute name
$attributes = []; $attributes = [];
$expected = false; $expected = false;
$this->expectException( $this->expectException(InvalidArgumentException::class);
\InvalidArgumentException::class, $this->expectExceptionMessage(
'The expected attribute is not a string, it is: '.print_r($expected, true).'.' 'The expected attribute is not a string, it is: '.print_r($expected, true).'.'
); );
Attributes::getExpectedAttribute($attributes, $expected); Attributes::getExpectedAttribute($attributes, $expected);
...@@ -57,8 +58,8 @@ class AttributesTest extends TestCase ...@@ -57,8 +58,8 @@ class AttributesTest extends TestCase
'attribute' => 'value', 'attribute' => 'value',
]; ];
$expected = 'attribute'; $expected = 'attribute';
$this->expectException( $this->expectException(InvalidArgumentException::class);
\InvalidArgumentException::class, $this->expectExceptionMessage(
'The attributes array is not normalized, values should be arrays.' 'The attributes array is not normalized, values should be arrays.'
); );
Attributes::getExpectedAttribute($attributes, $expected); Attributes::getExpectedAttribute($attributes, $expected);
...@@ -76,10 +77,8 @@ class AttributesTest extends TestCase ...@@ -76,10 +77,8 @@ class AttributesTest extends TestCase
'attribute' => ['value'], 'attribute' => ['value'],
]; ];
$expected = 'missing'; $expected = 'missing';
$this->expectException( $this->expectException(SimpleSAML\Error\Exception::class);
\SimpleSAML\Error\Exception::class, $this->expectExceptionMessage("No such attribute '".$expected."' found.");
"No such attribute '".$expected."' found."
);
Attributes::getExpectedAttribute($attributes, $expected); Attributes::getExpectedAttribute($attributes, $expected);
} }
...@@ -95,10 +94,8 @@ class AttributesTest extends TestCase ...@@ -95,10 +94,8 @@ class AttributesTest extends TestCase
'attribute' => [], 'attribute' => [],
]; ];
$expected = 'attribute'; $expected = 'attribute';
$this->expectException( $this->expectException(SimpleSAML\Error\Exception::class);
\SimpleSAML\Error\Exception::class, $this->expectExceptionMessage("Empty attribute '".$expected."'.'");
"Empty attribute '".$expected."'.'"
);
Attributes::getExpectedAttribute($attributes, $expected); Attributes::getExpectedAttribute($attributes, $expected);
} }
...@@ -117,8 +114,8 @@ class AttributesTest extends TestCase ...@@ -117,8 +114,8 @@ class AttributesTest extends TestCase
], ],
]; ];
$expected = 'attribute'; $expected = 'attribute';
$this->expectException( $this->expectException(SimpleSAML\Error\Exception::class);
\SimpleSAML\Error\Exception::class, $this->expectExceptionMessage(
'More than one value found for the attribute, multiple values not allowed.' 'More than one value found for the attribute, multiple values not allowed.'
); );
Attributes::getExpectedAttribute($attributes, $expected); Attributes::getExpectedAttribute($attributes, $expected);
...@@ -155,7 +152,7 @@ class AttributesTest extends TestCase ...@@ -155,7 +152,7 @@ class AttributesTest extends TestCase
*/ */
public function testNormalizeAttributesArrayBadInput() public function testNormalizeAttributesArrayBadInput()
{ {
$this->expectException(\InvalidArgumentException::class); $this->expectException(InvalidArgumentException::class);
Attributes::normalizeAttributesArray('string'); Attributes::normalizeAttributesArray('string');
} }
...@@ -166,7 +163,7 @@ class AttributesTest extends TestCase ...@@ -166,7 +163,7 @@ class AttributesTest extends TestCase
*/ */
public function testNormalizeAttributesArrayBadKeys() public function testNormalizeAttributesArrayBadKeys()
{ {
$this->expectException(\InvalidArgumentException::class); $this->expectException(InvalidArgumentException::class);
Attributes::normalizeAttributesArray(['attr1' => 'value1', 1 => 'value2']); Attributes::normalizeAttributesArray(['attr1' => 'value1', 1 => 'value2']);
} }
...@@ -177,7 +174,7 @@ class AttributesTest extends TestCase ...@@ -177,7 +174,7 @@ class AttributesTest extends TestCase
*/ */
public function testNormalizeAttributesArrayBadValues() public function testNormalizeAttributesArrayBadValues()
{ {
$this->expectException(\InvalidArgumentException::class); $this->expectException(InvalidArgumentException::class);
Attributes::normalizeAttributesArray(['attr1' => 'value1', 'attr2' => 0]); Attributes::normalizeAttributesArray(['attr1' => 'value1', 'attr2' => 0]);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment