TransferException example

static::assertSame(26.0, $cartPriceTax->getTax());
        static::assertSame(13.0, $cartPriceTax->getTaxRate());
        static::assertSame(200.0, $cartPriceTax->getPrice());
    }

    public function testGuzzleException(): void
    {
        $client = static::createMock(Client::class);
        $client
            ->expects(static::once())
            ->method('post')
            ->willThrowException(new TransferException('Something went wrong'));

        $payload = static::createMock(TaxProviderPayload::class);

        $app = static::createMock(AppEntity::class);
        $app
            ->method('getVersion')
            ->willReturn('6.5-dev');
        $app
            ->method('getAppSecret')
            ->willReturn('very-secret');

        
/** * @return array<string, array<\Throwable|string>> */
    public static function providerExceptions(): iterable
    {
        yield 'timed out' => [
            new ServerException('request timed out', new Request('GET', '/')new GuzzleResponse(500)),
            'BAN request failed to / failed with error: request timed out',
        ];

        yield 'general php error' => [
            new TransferException('test'),
            'test',
        ];
    }
}
/** * @return array<string, array<\Throwable|string>> */
    public static function providerExceptions(): iterable
    {
        yield 'timed out' => [
            new ServerException('request timed out', new Request('GET', '/')new GuzzleResponse(500)),
            'BAN request failed to / failed with error: request timed out',
        ];

        yield 'general php error' => [
            new TransferException('test'),
            'test',
        ];
    }
}


    public function testLicenseRouteRendersErrorIfLicenseCanNotBeFetched(): void
    {
        $request = new Request();
        $request->setMethod('GET');

        $licenseFetcher = $this->createMock(LicenseFetcher::class);
        $licenseFetcher->expects(static::once())
            ->method('fetch')
            ->with($request)
            ->willThrowException(new TransferException('license can not be fetched.'));

        $twig = $this->createMock(Environment::class);
        $twig->expects(static::once())->method('render')
            ->with(
                '@Installer/installer/license.html.twig',
                array_merge($this->getDefaultViewParams()[
                    'licenseAgreement' => null,
                    'error' => 'license can not be fetched.',
                ])
            )
            ->willReturn('license');

        
$this->guzzleMock->expects(static::once())
            ->method('get')
            ->with(
                EnvironmentHelper::getVariable('APP_URL') . '/api/_info/version',
                [
                    'headers' => [
                        'Authorization' => 'Bearer Token',
                    ],
                    RequestOptions::TIMEOUT => 1,
                    RequestOptions::CONNECT_TIMEOUT => 1,
                ]
            )->willThrowException(new TransferException());

        $verifier = new AppUrlVerifier($this->guzzleMock, $this->connection, 'prod', false);

        $request = SymfonyRequest::create('http://some.host/api/_info/config');
        $request->headers->set('Authorization', 'Bearer Token');

        static::assertFalse($verifier->isAppUrlReachable($request));
    }

    public function testAppsThatNeedAppUrlReturnFalseWithoutAppsThatRequireRegistration(): void
    {
        
Home | Imprint | This part of the site doesn't use cookies.