feat: JSON API
This commit is contained in:
parent
618fb8416a
commit
74505cea57
4 changed files with 84 additions and 1 deletions
|
@ -147,7 +147,7 @@ class FrontControllerTest extends TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* Assert that calling controller function with these parameters returns an HTTP redirect.
|
||||
* Assert that calling controller function with these parameters returns an HTTP 500 error.
|
||||
*
|
||||
* @param string $request Controller function to call
|
||||
* @param array $params Query parameters
|
||||
|
@ -160,6 +160,20 @@ class FrontControllerTest extends TestCase
|
|||
$this->assertTrue($this->getRequestResult($request, $params, $config)->isServerError());
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert that calling controller function with these parameters returns an HTTP 400 error.
|
||||
*
|
||||
* @param string $request Controller function to call
|
||||
* @param array $params Query parameters
|
||||
* @param Config $config Custom config
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function assertRequestIsClientError($request, array $params = [], Config $config = null)
|
||||
{
|
||||
$this->assertTrue($this->getRequestResult($request, $params, $config)->isClientError());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the constructor.
|
||||
*
|
||||
|
@ -539,6 +553,36 @@ class FrontControllerTest extends TestCase
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the json() function without the URL parameter.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testJsonWithoutUrl()
|
||||
{
|
||||
$this->assertRequestIsClientError('json');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the json() function.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testJson()
|
||||
{
|
||||
$this->assertRequestIsOk('json', ['url' => 'https://www.youtube.com/watch?v=M7IpKCZ47pU']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the json() function with an error.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testJsonWithError()
|
||||
{
|
||||
$this->assertRequestIsServerError('json', ['url' => 'http://example.com/foo']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the locale() function.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue