Skip to content

Commit 5d4052c

Browse files
committed
Fix review
1 parent c2d9130 commit 5d4052c

File tree

2 files changed

+63
-7
lines changed

2 files changed

+63
-7
lines changed

src/ApiPlatform/Resources/Discount/DiscountType.php renamed to src/ApiPlatform/Resources/DiscountType/DiscountTypeList.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
1919
*/
2020

21-
namespace PrestaShop\Module\APIResources\ApiPlatform\Resources\Discount;
21+
namespace PrestaShop\Module\APIResources\ApiPlatform\Resources\DiscountType;
2222

2323
use ApiPlatform\Metadata\ApiProperty;
2424
use ApiPlatform\Metadata\ApiResource;
@@ -31,20 +31,20 @@
3131
new CQRSGetCollection(
3232
uriTemplate: '/discount-types',
3333
CQRSQuery: GetDiscountTypes::class,
34-
scopes: [],
34+
scopes: ['discount_read'],
3535
CQRSQueryMapping: [],
3636
ApiResourceMapping: [
3737
'[type]' => '[type]',
3838
'[localizedNames]' => '[names]',
3939
'[localizedDescriptions]' => '[descriptions]',
40-
'[isCore]' => '[isCore]',
41-
'[active]' => '[active]',
40+
'[core]' => '[core]',
41+
'[enabled]' => '[enabled]',
4242
],
4343
),
4444
],
4545
normalizationContext: ['skip_null_values' => false],
4646
)]
47-
class DiscountType
47+
class DiscountTypeList
4848
{
4949
#[ApiProperty(identifier: true)]
5050
public int $discountTypeId;
@@ -57,7 +57,7 @@ class DiscountType
5757
#[LocalizedValue]
5858
public array $descriptions;
5959

60-
public bool $isCore;
60+
public bool $core;
6161

62-
public bool $active;
62+
public bool $enabled;
6363
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
/**
3+
* Copyright since 2007 PrestaShop SA and Contributors
4+
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
5+
*
6+
* NOTICE OF LICENSE
7+
*
8+
* This source file is subject to the Academic Free License version 3.0
9+
* that is bundled with this package in the file LICENSE.md.
10+
* It is also available through the world-wide-web at this URL:
11+
* https://opensource.org/licenses/AFL-3.0
12+
* If you did not receive a copy of the license and are unable to
13+
* obtain it through the world-wide-web, please send an email
14+
* to [email protected] so we can send you a copy immediately.
15+
*
16+
* @author PrestaShop SA and Contributors <[email protected]>
17+
* @copyright Since 2007 PrestaShop SA and Contributors
18+
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
19+
*/
20+
21+
namespace PsApiResourcesTest\Integration\ApiPlatform;
22+
23+
class DiscountTypeEndpointTest extends ApiTestCase
24+
{
25+
public static function setUpBeforeClass(): void
26+
{
27+
parent::setUpBeforeClass();
28+
self::createApiClient();
29+
}
30+
31+
public static function getProtectedEndpoints(): iterable
32+
{
33+
yield 'get endpoint' => [
34+
'GET',
35+
'/discount-types',
36+
];
37+
}
38+
39+
public function testGetDiscountTypes(): void
40+
{
41+
$discountTypes = $this->getItem('/discount-types', ['discount_read']);
42+
$this->assertIsArray($discountTypes);
43+
44+
$this->assertGreaterThanOrEqual(1, count($discountTypes));
45+
46+
if (count($discountTypes) > 0) {
47+
$firstType = $discountTypes[0];
48+
$this->assertArrayHasKey('discountTypeId', $firstType);
49+
$this->assertArrayHasKey('type', $firstType);
50+
$this->assertArrayHasKey('names', $firstType);
51+
$this->assertArrayHasKey('descriptions', $firstType);
52+
$this->assertArrayHasKey('core', $firstType);
53+
$this->assertArrayHasKey('enabled', $firstType);
54+
}
55+
}
56+
}

0 commit comments

Comments
 (0)