|
| 1 | +<?php |
| 2 | + |
| 3 | +/** |
| 4 | + * Copyright since 2007 PrestaShop SA and Contributors |
| 5 | + * PrestaShop is an International Registered Trademark & Property of PrestaShop SA |
| 6 | + * |
| 7 | + * NOTICE OF LICENSE |
| 8 | + * |
| 9 | + * This source file is subject to the Academic Free License version 3.0 |
| 10 | + * that is bundled with this package in the file LICENSE.md. |
| 11 | + * It is also available through the world-wide-web at this URL: |
| 12 | + * https://opensource.org/licenses/AFL-3.0 |
| 13 | + * If you did not receive a copy of the license and are unable to |
| 14 | + * obtain it through the world-wide-web, please send an email |
| 15 | + * to license@prestashop.com so we can send you a copy immediately. |
| 16 | + * |
| 17 | + * @author PrestaShop SA and Contributors <contact@prestashop.com> |
| 18 | + * @copyright Since 2007 PrestaShop SA and Contributors |
| 19 | + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 |
| 20 | + */ |
| 21 | + |
| 22 | +declare(strict_types=1); |
| 23 | + |
| 24 | +namespace PsApiResourcesTest\Integration\ApiPlatform; |
| 25 | + |
| 26 | +use Tests\Resources\DatabaseDump; |
| 27 | + |
| 28 | +class ShowcaseCardEndpointTest extends ApiTestCase |
| 29 | +{ |
| 30 | + protected const TEST_SHOWCASECARD = 'monitoring_card'; |
| 31 | + protected const TEST_EMPLOYEE_ID = 1; |
| 32 | + |
| 33 | + public static function setUpBeforeClass(): void |
| 34 | + { |
| 35 | + parent::setUpBeforeClass(); |
| 36 | + self::createApiClient(['showcase_card_read', 'showcase_card_write']); |
| 37 | + } |
| 38 | + |
| 39 | + public static function tearDownAfterClass(): void |
| 40 | + { |
| 41 | + parent::tearDownAfterClass(); |
| 42 | + // Reset DB as it was before this test |
| 43 | + DatabaseDump::restoreTables(['configuration']); |
| 44 | + } |
| 45 | + |
| 46 | + public static function getProtectedEndpoints(): iterable |
| 47 | + { |
| 48 | + yield 'get endpoint' => [ |
| 49 | + 'GET', |
| 50 | + '/showcase-cards/' . self::TEST_SHOWCASECARD . '/' . self::TEST_EMPLOYEE_ID, |
| 51 | + ]; |
| 52 | + yield 'put endpoint' => [ |
| 53 | + 'PUT', |
| 54 | + '/showcase-cards/' . self::TEST_SHOWCASECARD . '/' . self::TEST_EMPLOYEE_ID . '/close', |
| 55 | + ]; |
| 56 | + } |
| 57 | + |
| 58 | + public function testGetShowcard(): void |
| 59 | + { |
| 60 | + $showcaseCard = $this->getItem('/showcase-cards/' . self::TEST_SHOWCASECARD . '/' . self::TEST_EMPLOYEE_ID, ['showcase_card_read']); |
| 61 | + |
| 62 | + var_dump($showcaseCard); |
| 63 | + } |
| 64 | + |
| 65 | + /** |
| 66 | + * @depends testGetShowcard |
| 67 | + */ |
| 68 | + public function testCloseShowcard(): int |
| 69 | + { |
| 70 | + $this->updateItem('/showcase-cards/' . self::TEST_SHOWCASECARD . '/' . self::TEST_EMPLOYEE_ID . '/close', ['showcase_card_write'], Response::HTTP_NO_CONTENT); |
| 71 | + |
| 72 | + $showcaseCard = $this->getItem('/showcase-cards/' . self::TEST_SHOWCASECARD . '/' . self::TEST_EMPLOYEE_ID, ['showcase_card_read']); |
| 73 | + |
| 74 | + var_dump($showcaseCard); |
| 75 | + } |
| 76 | +} |
0 commit comments