8000 Merge branch '5.3' into 5.4 · YaFou/symfony@7d5feac · GitHub
[go: up one dir, main page]

Skip to content

Commit 7d5feac

Browse files
committed
Merge branch '5.3' into 5.4
* 5.3: [Translation] [Lokalise] Fix `base_uri`
2 parents f5bc4a1 + a734b90 commit 7d5feac

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/Symfony/Component/Translation/Bridge/Lokalise/LokaliseProviderFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function create(Dsn $dsn): ProviderInterface
5454
$endpoint .= $dsn->getPort() ? ':'.$dsn->getPort() : '';
5555

5656
$client = $this->client->withOptions([
57-
'base_uri' => 'https://'.$endpoint.'/projects/'.$this->getUser($dsn).'/api2/',
57+
'base_uri' => 'https://'.$endpoint.'/api2/projects/'.$this->getUser($dsn).'/',
5858
'headers' => [
5959
'X-Api-Token' => $this->getPassword($dsn),
6060
],

src/Symfony/Component/Translation/Bridge/Lokalise/Tests/LokaliseProviderFactoryTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
namespace Symfony\Component\Translation\Bridge\Lokalise\Tests;
44

5+
use Symfony\Component\HttpClient\MockHttpClient;
6+
use Symfony\Component\HttpClient\Response\MockResponse;
57
use Symfony\Component\Translation\Bridge\Lokalise\LokaliseProviderFactory;
8+
use Symfony\Component\Translation\Provider\Dsn;
69
use Symfony\Component\Translation\Provider\ProviderFactoryInterface;
710
use Symfony\Component\Translation\Test\ProviderFactoryTestCase;
811

@@ -32,6 +35,19 @@ public function incompleteDsnProvider(): iterable
3235
yield ['lokalise://default'];
3336
}
3437

38+
public function testBaseUri()
39+
{
40+
$response = new MockResponse(json_encode(['files' => []]));
41+
$httpClient = new MockHttpClient([$response]);
42+
$factory = new LokaliseProviderFactory($httpClient, $this->getLogger(), $this->getDefaultLocale(), $this->getLoader());
43+
$provider = $factory->create(new Dsn('lokalise://PROJECT_ID:API_KEY@default'));
44+
45+
// Make a real HTTP request.
46+
$provider->read(['messages'], ['en']);
47+
48+
$this->assertMatchesRegularExpression('/https:\/\/api.lokalise.com\/api2\/projects\/PROJECT_ID\/*/', $response->getRequestUrl());
49+
}
50+
3551
public function createFactory(): ProviderFactoryInterface
3652
{
3753
return new LokaliseProviderFactory($this->getClient(), $this->getLogger(), $this->getDefaultLocale(), $this->getLoader());

0 commit comments

Comments
 (0)
0