10000 bug #42243 [Translation] [Lokalise] Fix `base_uri` (welcoMattic, Nyholm) · YaFou/symfony@a734b90 · GitHub
[go: up one dir, main page]

Skip to content

Commit a734b90

Browse files
committed
bug symfony#42243 [Translation] [Lokalise] Fix base_uri (welcoMattic, Nyholm)
This PR was squashed before being merged into the 5.3 branch. Discussion ---------- [Translation] [Lokalise] Fix `base_uri` | Q | A | ------------- | --- | Branch? | 5.3 | Bug fix? | yes | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | Fix symfony#42234 <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead --> | License | MIT | Doc PR | It fixes the Lokalise `base_uri` value. Commits ------- 7390dc2 [Translation] [Lokalise] Fix `base_uri`
2 parents 2a4e95d + 7390dc2 commit a734b90

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