Skip to content

Commit c18aa3d

Browse files
authored
Added test code for issue #28 and #29 (#30)
1 parent 3393fb2 commit c18aa3d

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

tests/Functional/Visitor/Php/Symfony/ContainerAwareTransTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@ public function testExtract()
2424
{
2525
$collection = $this->getSourceLocations(new ContainerAwareTrans(), Resources\Php\Symfony\ContainerAwareTrans::class);
2626

27-
$this->assertCount(4, $collection);
27+
$this->assertCount(6, $collection);
2828

2929
$this->assertEquals('trans0', $collection->get(0)->getMessage());
3030
$this->assertEquals('trans1', $collection->get(1)->getMessage());
3131
$this->assertEquals('trans_line', $collection->get(2)->getMessage());
3232
$this->assertEquals('variable', $collection->get(3)->getMessage());
33+
$this->assertEquals('my.pdf', $collection->get(4)->getMessage());
34+
$this->assertEquals('bar', $collection->get(5)->getMessage());
3335
}
3436
}

tests/Resources/Php/Symfony/ContainerAwareTrans.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,17 @@
22

33
namespace Translation\Extractor\Tests\Resources\Php\Symfony;
44

5+
use Symfony\Component\Translation\TranslatorInterface;
6+
57
class ContainerAwareTrans
68
{
9+
private $translator;
10+
11+
public function __construct(TranslatorInterface $translator)
12+
{
13+
$this->translator = $translator;
14+
}
15+
716
/**
817
* @return array
918
*/
@@ -36,4 +45,14 @@ public function getTranslatorVariable()
3645
$translator = $this->get('translator');
3746
$translator->trans('variable');
3847
}
48+
49+
public function getPdfFilename(string $locale)
50+
{
51+
return $this->translator->trans('my.pdf', [], 'generic', $locale);
52+
}
53+
54+
public function static()
55+
{
56+
$translator = static::$container->get('translator'); $foo = $translator->trans('bar');
57+
}
3958
}

0 commit comments

Comments
 (0)