зеркало из https://github.com/nextcloud/cookbook.git
Register output filters for stubs as well
Signed-off-by: Christian Wolf <github@christianwolf.email>
This commit is contained in:
Родитель
7051868bb4
Коммит
a77e03228c
|
@ -6,6 +6,7 @@ use OCA\Cookbook\Exception\NoRecipeNameGivenException;
|
|||
use OCA\Cookbook\Exception\RecipeExistsException;
|
||||
use OCA\Cookbook\Helper\AcceptHeaderParsingHelper;
|
||||
use OCA\Cookbook\Helper\Filter\Output\RecipeJSONOutputFilter;
|
||||
use OCA\Cookbook\Helper\Filter\Output\RecipeStubFilter;
|
||||
use OCA\Cookbook\Helper\RestParameterParser;
|
||||
use OCA\Cookbook\Service\DbCacheService;
|
||||
use OCA\Cookbook\Service\RecipeService;
|
||||
|
@ -28,6 +29,8 @@ class RecipeImplementation {
|
|||
private $restParser;
|
||||
/** @var RecipeJSONOutputFilter */
|
||||
private $outputFilter;
|
||||
/** @var RecipeStubFilter */
|
||||
private $stubFilter;
|
||||
/** @var AcceptHeaderParsingHelper */
|
||||
private $acceptHeaderParser;
|
||||
/** @var IRequest */
|
||||
|
@ -35,6 +38,7 @@ class RecipeImplementation {
|
|||
/** @var IL10N */
|
||||
private $l;
|
||||
|
||||
|
||||
public function __construct(
|
||||
IRequest $request,
|
||||
RecipeService $recipeService,
|
||||
|
@ -42,6 +46,7 @@ class RecipeImplementation {
|
|||
IURLGenerator $iURLGenerator,
|
||||
RestParameterParser $restParameterParser,
|
||||
RecipeJSONOutputFilter $recipeJSONOutputFilter,
|
||||
RecipeStubFilter $stubFilter,
|
||||
AcceptHeaderParsingHelper $acceptHeaderParsingHelper,
|
||||
IL10N $iL10N
|
||||
) {
|
||||
|
@ -51,6 +56,7 @@ class RecipeImplementation {
|
|||
$this->urlGenerator = $iURLGenerator;
|
||||
$this->restParser = $restParameterParser;
|
||||
$this->outputFilter = $recipeJSONOutputFilter;
|
||||
$this->stubFilter = $stubFilter;
|
||||
$this->acceptHeaderParser = $acceptHeaderParsingHelper;
|
||||
$this->l = $iL10N;
|
||||
}
|
||||
|
@ -69,6 +75,8 @@ class RecipeImplementation {
|
|||
foreach ($recipes as $i => $recipe) {
|
||||
$recipes[$i]['imageUrl'] = $this->urlGenerator->linkToRoute('cookbook.recipe.image', ['id' => $recipe['recipe_id'], 'size' => 'thumb']);
|
||||
$recipes[$i]['imagePlaceholderUrl'] = $this->urlGenerator->linkToRoute('cookbook.recipe.image', ['id' => $recipe['recipe_id'], 'size' => 'thumb16']);
|
||||
|
||||
$recipes[$i] = $this->stubFilter->apply($recipes[$i]);
|
||||
}
|
||||
return new JSONResponse($recipes, Http::STATUS_OK);
|
||||
}
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
namespace OCA\Cookbook\Helper\Filter\Output;
|
||||
|
||||
use OCP\Files\File;
|
||||
use OCA\Cookbook\Helper\Filter\JSON\AbstractJSONFilter;
|
||||
use OCP\Files\File;
|
||||
|
||||
class RecipeJSONOutputFilter {
|
||||
/** @var array */
|
||||
|
|
|
@ -8,6 +8,7 @@ use OCA\Cookbook\Exception\NoRecipeNameGivenException;
|
|||
use OCA\Cookbook\Exception\RecipeExistsException;
|
||||
use OCA\Cookbook\Helper\AcceptHeaderParsingHelper;
|
||||
use OCA\Cookbook\Helper\Filter\Output\RecipeJSONOutputFilter;
|
||||
use OCA\Cookbook\Helper\Filter\Output\RecipeStubFilter;
|
||||
use OCA\Cookbook\Helper\RestParameterParser;
|
||||
use OCA\Cookbook\Service\DbCacheService;
|
||||
use OCA\Cookbook\Service\RecipeService;
|
||||
|
@ -41,6 +42,8 @@ class RecipeImplementationTest extends TestCase {
|
|||
private $restParser;
|
||||
/** @var RecipeJSONOutputFilter|MockObject */
|
||||
private $recipeFilter;
|
||||
/** @var RecipeStubFilter|MockObject */
|
||||
private $stubFilter;
|
||||
/** @var AcceptHeaderParsingHelper|MockObject */
|
||||
private $acceptHeaderParser;
|
||||
|
||||
|
@ -58,6 +61,7 @@ class RecipeImplementationTest extends TestCase {
|
|||
$this->urlGenerator = $this->createMock(IURLGenerator::class);
|
||||
$this->restParser = $this->createMock(RestParameterParser::class);
|
||||
$this->recipeFilter = $this->createMock(RecipeJSONOutputFilter::class);
|
||||
$this->stubFilter = $this->createMock(RecipeStubFilter::class);
|
||||
$this->acceptHeaderParser = $this->createMock(AcceptHeaderParsingHelper::class);
|
||||
|
||||
/** @var IL10N|Stub */
|
||||
|
@ -71,6 +75,7 @@ class RecipeImplementationTest extends TestCase {
|
|||
$this->urlGenerator,
|
||||
$this->restParser,
|
||||
$this->recipeFilter,
|
||||
$this->stubFilter,
|
||||
$this->acceptHeaderParser,
|
||||
$l
|
||||
);
|
||||
|
@ -685,6 +690,8 @@ class RecipeImplementationTest extends TestCase {
|
|||
return "/path/to/controller/$id/$size";
|
||||
}));
|
||||
|
||||
$this->stubFilter->method('apply')->willReturnArgument(0);
|
||||
|
||||
/**
|
||||
* @var JSONResponse $ret
|
||||
*/
|
||||
|
|
Загрузка…
Ссылка в новой задаче