expectationFailed example

public function testNoEntityCloned(): void
    {
        $exception = ApiException::noEntityCloned('order', '1234');

        static::assertInstanceOf(NoEntityClonedException::class$exception);
        static::assertEquals('Could not clone entity order with id 1234.', $exception->getMessage());
    }

    public function testExpectationFailed(): void
    {
        $exception = ApiException::expectationFailed([]);

        static::assertInstanceOf(ExpectationFailedException::class$exception);
        static::assertEquals('API Expectations failed', $exception->getMessage());
    }

    public function testInvalidSyncOperation(): void
    {
        $exception = ApiException::invalidSyncOperation('Message');

        static::assertInstanceOf(InvalidSyncOperationException::class$exception);
        static::assertEquals('Message', $exception->getMessage());
    }
/** @var list<string> $scope */
        $scope = $request->attributes->get(PlatformRequest::ATTRIBUTE_ROUTE_SCOPE, []);

        if (!\in_array(ApiRouteScope::ID, $scope, true)) {
            return;
        }

        $expectations = $this->checkPackages($request);

        if (\count($expectations)) {
            throw ApiException::expectationFailed($expectations);
        }
    }

    /** * @return list<string> */
    private function checkPackages(Request $request): array
    {
        // swag/plugin1:~6.1,swag/plugin2:~6.1         $extensionConstraints = array_filter(explode(',', (string) $request->headers->get(PlatformRequest::HEADER_EXPECT_PACKAGES)));
        if ($extensionConstraints === []) {
            
Home | Imprint | This part of the site doesn't use cookies.