Signed-off-by: Christian Wolf <github@christianwolf.email>
This commit is contained in:
Christian Wolf 2023-10-09 23:41:13 +02:00
Родитель a4d7138fd7
Коммит eadf339e9b
2 изменённых файлов: 8 добавлений и 24 удалений

Просмотреть файл

@ -2,25 +2,10 @@
namespace OCA\Cookbook\Helper\Filter; namespace OCA\Cookbook\Helper\Filter;
use OCA\Cookbook\Helper\Filter\JSON\CleanCategoryFilter;
use OCA\Cookbook\Helper\Filter\JSON\ExtractImageUrlFilter;
use OCA\Cookbook\Helper\Filter\JSON\FixDescriptionFilter;
use OCA\Cookbook\Helper\Filter\JSON\FixDurationsFilter;
use OCA\Cookbook\Helper\Filter\JSON\FixImageSchemeFilter;
use OCA\Cookbook\Helper\Filter\JSON\FixIngredientsFilter;
use OCA\Cookbook\Helper\Filter\JSON\FixInstructionsFilter;
use OCA\Cookbook\Helper\Filter\JSON\FixKeywordsFilter;
use OCA\Cookbook\Helper\Filter\JSON\FixNutritionFilter;
use OCA\Cookbook\Helper\Filter\JSON\FixRecipeYieldFilter;
use OCA\Cookbook\Helper\Filter\JSON\FixToolsFilter;
use OCA\Cookbook\Helper\Filter\JSON\FixUrlFilter;
use OCA\Cookbook\Helper\Filter\JSON\RecipeIdCopyFilter; use OCA\Cookbook\Helper\Filter\JSON\RecipeIdCopyFilter;
use OCA\Cookbook\Helper\Filter\JSON\RecipeIdTypeFilter; use OCA\Cookbook\Helper\Filter\JSON\RecipeIdTypeFilter;
use OCA\Cookbook\Helper\Filter\JSON\RecipeNameFilter;
use OCA\Cookbook\Helper\Filter\JSON\SchemaConformityFilter;
class RecipeStubFilter class RecipeStubFilter {
{
/** @var AbstractJSONFilter[] */ /** @var AbstractJSONFilter[] */
private $filters; private $filters;
@ -34,8 +19,7 @@ class RecipeStubFilter
]; ];
} }
public function apply(array $json): array public function apply(array $json): array {
{
foreach ($this->filters as $filter) { foreach ($this->filters as $filter) {
$filter->apply($json); $filter->apply($json);
} }

Просмотреть файл

@ -7,12 +7,10 @@ use OCA\Cookbook\Helper\Filter\RecipeStubFilter;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
class RecipeFixIdsTest extends TestCase { class RecipeFixIdsTest extends TestCase {
/** @var RecipeStubFilter */ /** @var RecipeStubFilter */
private $dut; private $dut;
protected function setUp(): void protected function setUp(): void {
{
parent::setUp(); parent::setUp();
$app = new Application(); $app = new Application();
@ -20,7 +18,7 @@ class RecipeFixIdsTest extends TestCase {
$this->dut = $container->get(RecipeStubFilter::class); $this->dut = $container->get(RecipeStubFilter::class);
} }
public function dp(){ public function dp() {
$stub = [ $stub = [
'name' => 'The name of te recipe', 'name' => 'The name of te recipe',
'date' => '1970-01-12', 'date' => '1970-01-12',
@ -28,7 +26,7 @@ class RecipeFixIdsTest extends TestCase {
$src = $stub; $src = $stub;
$src['recipe_id'] = 123; $src['recipe_id'] = 123;
$expected = $stub; $expected = $stub;
$expected['recipe_id'] = 123; $expected['recipe_id'] = 123;
$expected['id'] = '123'; $expected['id'] = '123';
@ -41,8 +39,10 @@ class RecipeFixIdsTest extends TestCase {
/** /**
* @dataProvider dp * @dataProvider dp
* @param mixed $original
* @param mixed $expected
*/ */
public function testRecipeStubs($original, $expected){ public function testRecipeStubs($original, $expected) {
$ret = $this->dut->apply($original); $ret = $this->dut->apply($original);
$this->assertSame($expected, $ret); $this->assertSame($expected, $ret);
} }