2222class TranslationsDumperTest extends TestCase
2323{
2424 protected static $ translationsDumpDir ;
25- private TranslationsDumper $ translationsDumper ;
2625
2726 public static function setUpBeforeClass (): void
2827 {
@@ -34,20 +33,17 @@ public static function tearDownAfterClass(): void
3433 @rmdir (self ::$ translationsDumpDir );
3534 }
3635
37- protected function setUp (): void
36+ public function testDump ()
3837 {
39- $ this -> translationsDumper = new TranslationsDumper (
38+ $ translationsDumper = new TranslationsDumper (
4039 self ::$ translationsDumpDir ,
40+ true ,
4141 new MessageParametersExtractor (),
4242 new IntlMessageParametersExtractor (),
4343 new TypeScriptMessageParametersPrinter (),
4444 new Filesystem (),
4545 );
46- }
47-
48- public function testDump ()
49- {
50- $ this ->translationsDumper ->dump (...self ::getMessageCatalogues ());
46+ $ translationsDumper ->dump (...self ::getMessageCatalogues ());
5147
5248 $ this ->assertFileExists (self ::$ translationsDumpDir .'/index.js ' );
5349 $ this ->assertFileExists (self ::$ translationsDumpDir .'/index.d.ts ' );
@@ -114,19 +110,53 @@ public function testDump()
114110 TS);
115111 }
116112
113+ public function testShouldNotDumpTypeScriptTypes ()
114+ {
115+ $ translationsDumper = new TranslationsDumper (
116+ self ::$ translationsDumpDir ,
117+ false ,
118+ new MessageParametersExtractor (),
119+ new IntlMessageParametersExtractor (),
120+ new TypeScriptMessageParametersPrinter (),
121+ new Filesystem (),
122+ );
123+ $ translationsDumper ->dump (...self ::getMessageCatalogues ());
124+
125+ $ this ->assertFileExists (self ::$ translationsDumpDir .'/index.js ' );
126+ $ this ->assertFileDoesNotExist (self ::$ translationsDumpDir .'/index.d.ts ' );
127+ }
128+
117129 public function testDumpWithExcludedDomains ()
118130 {
119- $ this ->translationsDumper ->addExcludedDomain ('foobar ' );
120- $ this ->translationsDumper ->dump (...$ this ->getMessageCatalogues ());
131+ $ translationsDumper = new TranslationsDumper (
132+ self ::$ translationsDumpDir ,
133+ true ,
134+ new MessageParametersExtractor (),
135+ new IntlMessageParametersExtractor (),
136+ new TypeScriptMessageParametersPrinter (),
137+ new Filesystem (),
138+ );
139+ $ translationsDumper ->addExcludedDomain ('foobar ' );
140+
141+ $ translationsDumper ->dump (...self ::getMessageCatalogues ());
121142
122143 $ this ->assertFileExists (self ::$ translationsDumpDir .'/index.js ' );
123144 $ this ->assertStringNotContainsString ('foobar ' , file_get_contents (self ::$ translationsDumpDir .'/index.js ' ));
124145 }
125146
126147 public function testDumpIncludedDomains ()
127148 {
128- $ this ->translationsDumper ->addIncludedDomain ('messages ' );
129- $ this ->translationsDumper ->dump (...$ this ->getMessageCatalogues ());
149+ $ translationsDumper = new TranslationsDumper (
150+ self ::$ translationsDumpDir ,
151+ true ,
152+ new MessageParametersExtractor (),
153+ new IntlMessageParametersExtractor (),
154+ new TypeScriptMessageParametersPrinter (),
155+ new Filesystem (),
156+ );
157+ $ translationsDumper ->addIncludedDomain ('messages ' );
158+
159+ $ translationsDumper ->dump (...self ::getMessageCatalogues ());
130160
131161 $ this ->assertFileExists (self ::$ translationsDumpDir .'/index.js ' );
132162 $ this ->assertStringNotContainsString ('foobar ' , file_get_contents (self ::$ translationsDumpDir .'/index.js ' ));
@@ -136,16 +166,35 @@ public function testSetBothIncludedAndExcludedDomains()
136166 {
137167 $ this ->expectException (\LogicException::class);
138168 $ this ->expectExceptionMessage ('You cannot set both "excluded_domains" and "included_domains" at the same time. ' );
139- $ this ->translationsDumper ->addIncludedDomain ('foobar ' );
140- $ this ->translationsDumper ->addExcludedDomain ('messages ' );
169+
170+ $ translationsDumper = new TranslationsDumper (
171+ self ::$ translationsDumpDir ,
172+ true ,
173+ new MessageParametersExtractor (),
174+ new IntlMessageParametersExtractor (),
175+ new TypeScriptMessageParametersPrinter (),
176+ new Filesystem (),
177+ );
178+
179+ $ translationsDumper ->addIncludedDomain ('foobar ' );
180+ $ translationsDumper ->addExcludedDomain ('messages ' );
141181 }
142182
143183 public function testSetBothExcludedAndIncludedDomains ()
144184 {
145185 $ this ->expectException (\LogicException::class);
146186 $ this ->expectExceptionMessage ('You cannot set both "excluded_domains" and "included_domains" at the same time. ' );
147- $ this ->translationsDumper ->addExcludedDomain ('foobar ' );
148- $ this ->translationsDumper ->addIncludedDomain ('messages ' );
187+
188+ $ translationsDumper = new TranslationsDumper (
189+ self ::$ translationsDumpDir ,
190+ true ,
191+ new MessageParametersExtractor (),
192+ new IntlMessageParametersExtractor (),
193+ new TypeScriptMessageParametersPrinter (),
194+ new Filesystem (),
195+ );
196+ $ translationsDumper ->addExcludedDomain ('foobar ' );
197+ $ translationsDumper ->addIncludedDomain ('messages ' );
149198 }
150199
151200 /**
0 commit comments