-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix:
getString()
behaviour for non-scalar values (#22)
- Loading branch information
Showing
4 changed files
with
59 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the zenstruck/uri package. | ||
* | ||
* (c) Kevin Bond <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Zenstruck\Uri\Tests; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Zenstruck\Uri\Parameters; | ||
|
||
/** | ||
* @author Kevin Bond <[email protected]> | ||
*/ | ||
final class ParametersTest extends TestCase | ||
{ | ||
/** | ||
* @test | ||
*/ | ||
public function get_string_on_other_types(): void | ||
{ | ||
$this->assertSame('', (new Parameters(['foo' => ['bar']]))->getString('foo')); | ||
$this->assertSame('', (new Parameters(['foo' => null]))->getString('foo')); | ||
|
||
$this->expectException(\RuntimeException::class); | ||
|
||
(new Parameters(['foo' => []]))->getString('foo', new \RuntimeException()); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function get_int_on_other_types(): void | ||
{ | ||
$this->assertSame(1, (new Parameters(['foo' => ['bar']]))->getInt('foo')); | ||
$this->assertSame(0, (new Parameters(['foo' => null]))->getInt('foo')); | ||
} | ||
} |