File tree Expand file tree Collapse file tree 9 files changed +30
-10
lines changed Expand file tree Collapse file tree 9 files changed +30
-10
lines changed Original file line number Diff line number Diff line change 22
22
"require-dev" : {
23
23
"nyholm/symfony-bundle-test" : " ^1.4" ,
24
24
"phpunit/phpunit" : " ~7.5" ,
25
- "symfony/templating" : " ^4.3" ,
26
25
"symfony/twig-bundle" : " ^4.3" ,
27
26
"scrutinizer/ocular" : " ^1.5"
28
27
},
Original file line number Diff line number Diff line change @@ -9,6 +9,10 @@ services:
9
9
n2w_standard_dictionary :
10
10
class : PHPViet\NumberToWords\Dictionary
11
11
public : true
12
+ n2w_twig_extension :
13
+ class : PHPViet\Symfony\NumberToWords\Twig\Extension\N2WExtension
14
+ arguments : ['@n2w']
15
+ tags :
16
+ - { name: twig.extension }
12
17
PHPViet\NumberToWords\DictionaryInterface :
13
18
class : PHPViet\NumberToWords\Dictionary
14
- public : true
Original file line number Diff line number Diff line change @@ -29,11 +29,11 @@ class N2WExtension extends AbstractExtension
29
29
/**
30
30
* Khởi tạo extension
31
31
*
32
- * @param Service $helper Phone number helper.
32
+ * @param Service $service
33
33
*/
34
- public function __construct (Service $ helper )
34
+ public function __construct (Service $ service )
35
35
{
36
- $ this ->service = $ helper ;
36
+ $ this ->service = $ service ;
37
37
}
38
38
39
39
/**
Original file line number Diff line number Diff line change 1
1
twig :
2
- default_path : ' %kernel.project_dir%/templates '
2
+ default_path : ' %kernel.project_dir%/Resources/twig-template '
3
3
debug : ' %kernel.debug%'
4
4
strict_variables : ' %kernel.debug%'
Original file line number Diff line number Diff line change
1
+ {{ 1000 | n2w(' south' ) }}
Original file line number Diff line number Diff line change
1
+ {{ 123.3 | n2c([' vàng' , ' bạc' ]) }}
Original file line number Diff line number Diff line change
1
+ {{ 123 | n2w }}
Original file line number Diff line number Diff line change @@ -20,19 +20,33 @@ class TwigTest extends TestCase
20
20
21
21
protected function setUp (): void
22
22
{
23
+ $ this ->addCompilerPass (new PublicServicePass ());
23
24
$ kernel = $ this ->createKernel ();
24
25
$ kernel ->addBundle (TwigBundle::class);
25
- $ this ->addCompilerPass (new PublicServicePass ());
26
+ $ kernel ->setProjectDir (__DIR__ );
27
+ $ kernel ->addConfigFile (__DIR__ . '/Resources/twig-config.yaml ' );
26
28
$ this ->bootKernel ();
27
29
}
28
30
29
- public function testFilters ()
31
+ public function testTransformFilter (): void
30
32
{
33
+ $ container = $ this ->getContainer ();
34
+ $ twig = $ container ->get ('twig ' );
35
+ $ this ->assertEquals ('một trăm hai mươi ba ' , trim ($ twig ->render ('words.twig ' )));
36
+ }
31
37
38
+ public function testCurrencyTransformFilter (): void
39
+ {
32
40
$ container = $ this ->getContainer ();
41
+ $ twig = $ container ->get ('twig ' );
42
+ $ this ->assertEquals ('một trăm hai mươi ba vàng ba bạc ' , trim ($ twig ->render ('currency.twig ' )));
43
+ }
33
44
34
- var_dump ($ container ->get ('twig ' )->render (__DIR__ .'/Resources/test.twig ' ));
35
- die;
45
+ public function testChangeDictionary (): void
46
+ {
47
+ $ container = $ this ->getContainer ();
48
+ $ twig = $ container ->get ('twig ' );
49
+ $ this ->assertEquals ('một ngàn ' , trim ($ twig ->render ('change-dictionary.twig ' )));
36
50
}
37
51
38
52
}
You can’t perform that action at this time.
0 commit comments