generated from rich-id/bundle-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from rich-id/v0.1.3
Fix the json bad handling when making a request
- Loading branch information
Showing
11 changed files
with
114 additions
and
58 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace RichCongress\WebTestBundle\Exception; | ||
|
||
abstract class AbstractException extends \LogicException | ||
{ | ||
/** @var string */ | ||
protected static $error; | ||
|
||
public function __construct() | ||
{ | ||
$message = static::$error; | ||
$message .= "\n"; | ||
$message .= 'Check the documentation: '; | ||
$message .= 'https://github.com/richcongress/web-test-bundle/blob/master/Docs/Exceptions.md#'; | ||
$message .= static::class; | ||
|
||
parent::__construct($message); | ||
} | ||
|
||
public static function throw(): void | ||
{ | ||
throw new static(); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -9,22 +9,8 @@ | |
* @author Nicolas Guilloux <[email protected]> | ||
* @copyright 2014 - 2020 RichCongress (https://www.richcongress.com) | ||
*/ | ||
final class CsrfTokenManagerMissingException extends \Exception | ||
final class CsrfTokenManagerMissingException extends AbstractException | ||
{ | ||
/** @var string */ | ||
protected static $error = 'The Security\'s CSRF Token Manager is missing from the container.'; | ||
|
||
/** @var string */ | ||
protected static $documentation = 'https://github.com/richcongress/web-test-bundle/blob/master/Docs/Exceptions.md#CsrfTokenManagerMissingException'; | ||
|
||
/** | ||
* CsrfTokenManagerMissingException constructor. | ||
*/ | ||
public function __construct() | ||
{ | ||
$message = self::$error; | ||
$message .= "\nCheck the documentation: " . self::$documentation; | ||
|
||
parent::__construct($message); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -8,25 +8,9 @@ | |
* @package RichCongress\WebTestBundle\Exception | ||
* @author Nicolas Guilloux <[email protected]> | ||
* @copyright 2014 - 2020 RichCongress (https://www.richcongress.com) | ||
* | ||
* @covers \RichCongress\WebTestBundle\Exception\EntityManagerNotFoundException | ||
*/ | ||
final class EntityManagerNotFoundException extends \Exception | ||
final class EntityManagerNotFoundException extends AbstractException | ||
{ | ||
/** @var string */ | ||
protected static $error = 'The Entity manager cannot be found. Check your Doctrine documentation.'; | ||
|
||
/** @var string */ | ||
protected static $documentation = 'https://github.com/richcongress/web-test-bundle/blob/master/Docs/Exceptions.md#EntityManagerNotFoundException'; | ||
|
||
/** | ||
* EntityManagerNotFoundException constructor. | ||
*/ | ||
public function __construct() | ||
{ | ||
$message = self::$error; | ||
$message .= "\nCheck the documentation: " . self::$documentation; | ||
|
||
parent::__construct($message); | ||
} | ||
} |
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,9 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace RichCongress\WebTestBundle\Exception; | ||
|
||
class JsonRequestWithContentException extends AbstractException | ||
{ | ||
/** @var string */ | ||
protected static $error = 'You cannot make a json request with both parameters and content set.'; | ||
} |
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 |
---|---|---|
|
@@ -9,22 +9,8 @@ | |
* @author Nicolas Guilloux <[email protected]> | ||
* @copyright 2014 - 2020 RichCongress (https://www.richcongress.com) | ||
*/ | ||
final class KernelNotInitializedException extends \Exception | ||
final class KernelNotInitializedException extends AbstractException | ||
{ | ||
/** @var string */ | ||
protected static $error = 'The kernel was not initialized. Did you add the annotation `@TestConfig("kernel")` to your method or class?'; | ||
|
||
/** @var string */ | ||
protected static $documentation = 'https://github.com/richcongress/web-test-bundle/blob/master/Docs/Exceptions.md#KernelNotInitializedException'; | ||
|
||
/** | ||
* KernelNotInitializedException constructor. | ||
*/ | ||
public function __construct() | ||
{ | ||
$message = self::$error; | ||
$message .= "\nCheck the documentation: " . self::$documentation; | ||
|
||
parent::__construct($message); | ||
} | ||
} |
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,23 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace RichCongress\WebTestBundle\Tests\Exceptions; | ||
|
||
use RichCongress\WebTestBundle\Exception\JsonRequestWithContentException; | ||
use RichCongress\WebTestBundle\TestCase\TestCase; | ||
|
||
/** | ||
* @covers \RichCongress\WebTestBundle\Exception\JsonRequestWithContentException | ||
* @covers \RichCongress\WebTestBundle\Exception\AbstractException | ||
*/ | ||
final class JsonRequestWithContentExceptionTest extends TestCase | ||
{ | ||
public function testException(): void | ||
{ | ||
$exception = new JsonRequestWithContentException(); | ||
|
||
self::assertStringContainsString( | ||
'You cannot make a json request with both parameters and content set.', | ||
$exception->getMessage() | ||
); | ||
} | ||
} |
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