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 2222 "require-dev" : {
2323 "nyholm/symfony-bundle-test" : " ^1.4" ,
2424 "phpunit/phpunit" : " ~7.5" ,
25- "symfony/templating" : " ^4.3" ,
2625 "symfony/twig-bundle" : " ^4.3" ,
2726 "scrutinizer/ocular" : " ^1.5"
2827 },
Original file line number Diff line number Diff line change @@ -9,6 +9,10 @@ services:
99 n2w_standard_dictionary :
1010 class : PHPViet\NumberToWords\Dictionary
1111 public : true
12+ n2w_twig_extension :
13+ class : PHPViet\Symfony\NumberToWords\Twig\Extension\N2WExtension
14+ arguments : ['@n2w']
15+ tags :
16+ - { name: twig.extension }
1217 PHPViet\NumberToWords\DictionaryInterface :
1318 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
2929 /**
3030 * Khởi tạo extension
3131 *
32- * @param Service $helper Phone number helper.
32+ * @param Service $service
3333 */
34- public function __construct (Service $ helper )
34+ public function __construct (Service $ service )
3535 {
36- $ this ->service = $ helper ;
36+ $ this ->service = $ service ;
3737 }
3838
3939 /**
Original file line number Diff line number Diff line change 11twig :
2- default_path : ' %kernel.project_dir%/templates '
2+ default_path : ' %kernel.project_dir%/Resources/twig-template '
33 debug : ' %kernel.debug%'
44 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
2020
2121 protected function setUp (): void
2222 {
23+ $ this ->addCompilerPass (new PublicServicePass ());
2324 $ kernel = $ this ->createKernel ();
2425 $ kernel ->addBundle (TwigBundle::class);
25- $ this ->addCompilerPass (new PublicServicePass ());
26+ $ kernel ->setProjectDir (__DIR__ );
27+ $ kernel ->addConfigFile (__DIR__ . '/Resources/twig-config.yaml ' );
2628 $ this ->bootKernel ();
2729 }
2830
29- public function testFilters ()
31+ public function testTransformFilter (): void
3032 {
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+ }
3137
38+ public function testCurrencyTransformFilter (): void
39+ {
3240 $ 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+ }
3344
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 ' )));
3650 }
3751
3852}
You can’t perform that action at this time.
0 commit comments