getCountryData example

$this->connection->fetchAllAssociative('SELECT id FROM country WHERE iso = \'DE\'')[0]['id']
        );

        $this->countryStateController = $this->getContainer()->get(CountryStateController::class);

        $this->salesChannelContext = $this->getContainer()->get(SalesChannelContextFactory::class)
            ->create(Uuid::randomHex(), TestDefaults::SALES_CHANNEL);
    }

    public function testGetCountryData(): void
    {
        $response = $this->countryStateController->getCountryData(new Request([]['countryId' => $this->countryIdDE])$this->salesChannelContext);

        static::assertCount(16, \json_decode((string) $response->getContent(), true, 512, \JSON_THROW_ON_ERROR)['states']);
    }

    public function testEmptyCountryId(): void
    {
        static::expectException(RoutingException::class);
        static::expectExceptionMessage('Parameter "countryId" is missing.');
        $this->countryStateController->getCountryData(new Request([]['countryId' => null])$this->salesChannelContext);
    }

    
Home | Imprint | This part of the site doesn't use cookies.