Skip to content

Commit

Permalink
[CatalogPromotion][API] Minor fixes to creating simple catalog promotion
Browse files Browse the repository at this point in the history
  • Loading branch information
GSadee committed Aug 24, 2021
1 parent 597c353 commit f046abb
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ public function iCreateANewCatalogPromotionWithCodeAndName(string $code, string
*/
public function thereShouldBeNewCatalogPromotionOnTheList(int $amount): void
{
$x = $this->client->index();


Assert::count($this->responseChecker->getCollection($this->client->index()), $amount);
}

Expand All @@ -56,10 +53,9 @@ public function thereShouldBeNewCatalogPromotionOnTheList(int $amount): void
*/
public function itShouldHaveCodeAndName(string $code, string $name): void
{
$expectedValues = ['code' => $code, 'name' => $name];
Assert::true(
$this->responseChecker->hasItemWithValues($this->client->index(), $expectedValues),
sprintf('Cannot find catalog promotions with %s in the list', implode(',', $expectedValues))
$this->responseChecker->hasItemWithValues($this->client->index(), ['code' => $code, 'name' => $name]),
sprintf('Cannot find catalog promotions with code "%s" and name "%s" in the list', $code, $name)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Sylius\Bundle\ResourceBundle\Form\Type\DefaultResourceType;
use Sylius\Bundle\ResourceBundle\SyliusResourceBundle;
use Sylius\Component\Promotion\Model\CatalogPromotion;
use Sylius\Component\Promotion\Model\CatalogPromotionInterface;
use Sylius\Component\Promotion\Model\Promotion;
use Sylius\Component\Promotion\Model\PromotionAction;
use Sylius\Component\Promotion\Model\PromotionActionInterface;
Expand All @@ -31,7 +32,6 @@
use Sylius\Component\Promotion\Model\PromotionRule;
use Sylius\Component\Promotion\Model\PromotionRuleInterface;
use Sylius\Component\Resource\Factory\Factory;
use Sylius\Component\Resource\Model\ResourceInterface;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
Expand Down Expand Up @@ -101,7 +101,7 @@ private function addResourcesSection(ArrayNodeDefinition $node): void
->addDefaultsIfNotSet()
->children()
->scalarNode('model')->defaultValue(CatalogPromotion::class)->cannotBeEmpty()->end()
->scalarNode('interface')->defaultValue(ResourceInterface::class)->cannotBeEmpty()->end()
->scalarNode('interface')->defaultValue(CatalogPromotionInterface::class)->cannotBeEmpty()->end()
->scalarNode('controller')->defaultValue(ResourceController::class)->cannotBeEmpty()->end()
->scalarNode('repository')->cannotBeEmpty()->end()
->scalarNode('factory')->defaultValue(Factory::class)->end()
Expand Down
2 changes: 1 addition & 1 deletion tests/Api/Admin/CatalogPromotionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ public function it_allows_admin_to_get_catalog_promotions(): void

$response = $this->client->getResponse();

$this->assertResponse($response, 'admin/get_catalog_promotions_admin_response', Response::HTTP_OK);
$this->assertResponse($response, 'admin/get_catalog_promotions_response', Response::HTTP_OK);
}
}
4 changes: 2 additions & 2 deletions tests/Api/DataFixtures/ORM/catalog_promotion.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Sylius\Component\Promotion\Model\CatalogPromotion:
catalog_promotion:
name: "catalog promotion"
code: "catalog_promotion"
name: "Mugs discount"
code: "mugs_discount"
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"@id": "\/api\/v2\/admin\/catalog-promotions\/catalog_promotion",
"@type": "CatalogPromotion",
"id": @integer@,
"name": "catalog promotion",
"code": "catalog_promotion"
"name": "Mugs discount",
"code": "mugs_discount"
}
],
"hydra:totalItems": 1
Expand Down

0 comments on commit f046abb

Please sign in to comment.