mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-09-06 01:31:22 +02:00
* New shortcode providers, update config, docs * Use new ImageShortcodeProvider * Move tests * New shortcodes namespace * Move file and image shortcode registrations from framework to assets
64 lines
1.3 KiB
PHP
64 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace SilverStripe\View\Tests\Shortcodes;
|
|
|
|
use Embed\Http\DispatcherInterface;
|
|
use Embed\Http\ImageResponse;
|
|
use Embed\Http\Response;
|
|
use Embed\Http\Url;
|
|
use InvalidArgumentException;
|
|
|
|
class MockResolver implements DispatcherInterface
|
|
{
|
|
protected $url = null;
|
|
|
|
protected $expectedContent = null;
|
|
|
|
/**
|
|
* Constructor. Sets the url.
|
|
*
|
|
* @param string $url The url value
|
|
* @param array $config The resolver configuration
|
|
*/
|
|
public function __construct($url, array $config)
|
|
{
|
|
$this->url = $url;
|
|
if (empty($config['expectedContent'])) {
|
|
throw new InvalidArgumentException("Mock resolvers need expectedContent");
|
|
}
|
|
$this->expectedContent = $config['expectedContent'];
|
|
}
|
|
|
|
/**
|
|
* Dispatch an url.
|
|
*
|
|
* @param Url $url
|
|
*
|
|
* @return Response
|
|
*/
|
|
public function dispatch(Url $url)
|
|
{
|
|
return new Response(
|
|
$url,
|
|
$url,
|
|
200,
|
|
'application/json',
|
|
$this->expectedContent,
|
|
[],
|
|
[]
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Resolve multiple image urls at once.
|
|
*
|
|
* @param Url[] $urls
|
|
*
|
|
* @return ImageResponse[]
|
|
*/
|
|
public function dispatchImages(array $urls)
|
|
{
|
|
return [];
|
|
}
|
|
}
|