1515use CodeIgniter \Files \Exceptions \FileNotFoundException ;
1616use CodeIgniter \Test \CIUnitTestCase ;
1717use Config \App ;
18+ use Config \DocTypes ;
1819
1920/**
2021 * @internal
@@ -206,41 +207,48 @@ public function testIMGWithIndexpage(): void
206207
207208 public function testIMGXHTML (): void
208209 {
209- $ doctypes = config ('DocTypes ' );
210- $ default = $ doctypes ->html5 ;
211- $ doctypes ->html5 = false ;
210+ $ this ->disableHtml5 ();
212211
213212 $ target = 'http://site.com/images/picture.jpg ' ;
214213 $ expected = '<img src="http://site.com/images/picture.jpg" alt="" /> ' ;
215214 $ this ->assertSame ($ expected , img ($ target ));
216215
217- $ doctypes -> html5 = $ default ;
216+ $ this -> enableHtml5 () ;
218217 }
219218
220- public function testIMGXHTMLWithoutProtocol (): void
219+ private function disableHtml5 ()
221220 {
222- $ doctypes = config ('DocTypes ' );
223- $ default = $ doctypes ->html5 ;
221+ $ doctypes = new DocTypes ();
224222 $ doctypes ->html5 = false ;
223+ _solidus ($ doctypes );
224+ }
225+
226+ private function enableHtml5 ()
227+ {
228+ $ doctypes = new DocTypes ();
229+ _solidus ($ doctypes );
230+ }
231+
232+ public function testIMGXHTMLWithoutProtocol (): void
233+ {
234+ $ this ->disableHtml5 ();
225235
226236 $ target = 'assets/mugshot.jpg ' ;
227237 $ expected = '<img src="http://example.com/assets/mugshot.jpg" alt="" /> ' ;
228238 $ this ->assertSame ($ expected , img ($ target ));
229239
230- $ doctypes -> html5 = $ default ;
240+ $ this -> enableHtml5 () ;
231241 }
232242
233243 public function testIMGXHTMLWithIndexpage (): void
234244 {
235- $ doctypes = config ('DocTypes ' );
236- $ default = $ doctypes ->html5 ;
237- $ doctypes ->html5 = false ;
245+ $ this ->disableHtml5 ();
238246
239247 $ target = 'assets/mugshot.jpg ' ;
240248 $ expected = '<img src="http://example.com/index.php/assets/mugshot.jpg" alt="" /> ' ;
241249 $ this ->assertSame ($ expected , img ($ target , true ));
242250
243- $ doctypes -> html5 = $ default ;
251+ $ this -> enableHtml5 () ;
244252 }
245253
246254 public function testImgData (): void
@@ -355,16 +363,13 @@ public function testLinkTag(): void
355363
356364 public function testLinkTagXHTML (): void
357365 {
358- $ doctypes = config ('DocTypes ' );
359- $ default = $ doctypes ->html5 ;
360- $ doctypes ->html5 = false ;
366+ $ this ->disableHtml5 ();
361367
362368 $ target = 'css/mystyles.css ' ;
363369 $ expected = '<link href="http://example.com/css/mystyles.css" rel="stylesheet" type="text/css" /> ' ;
364370 $ this ->assertSame ($ expected , link_tag ($ target ));
365371
366- // Reset
367- $ doctypes ->html5 = $ default ;
372+ $ this ->enableHtml5 ();
368373 }
369374
370375 public function testLinkTagMedia (): void
@@ -509,9 +514,7 @@ public function testVideoWithTracks(): void
509514
510515 public function testVideoWithTracksXHTML (): void
511516 {
512- $ doctypes = config ('DocTypes ' );
513- $ default = $ doctypes ->html5 ;
514- $ doctypes ->html5 = false ;
517+ $ this ->disableHtml5 ();
515518
516519 $ expected = <<<'EOH'
517520 <video src="http://example.com/test.mp4" controls>
@@ -531,8 +534,7 @@ public function testVideoWithTracksXHTML(): void
531534 $ video = video ($ target , $ message , 'controls ' , $ tracks );
532535 $ this ->assertSame ($ expected , $ video );
533536
534- // Reset
535- $ doctypes ->html5 = $ default ;
537+ $ this ->enableHtml5 ();
536538 }
537539
538540 public function testVideoWithTracksAndIndex (): void
@@ -581,9 +583,7 @@ public function testVideoMultipleSources(): void
581583
582584 public function testVideoMultipleSourcesXHTML (): void
583585 {
584- $ doctypes = config ('DocTypes ' );
585- $ default = $ doctypes ->html5 ;
586- $ doctypes ->html5 = false ;
586+ $ this ->disableHtml5 ();
587587
588588 $ expected = <<<'EOH'
589589 <video class="test" controls>
@@ -613,8 +613,7 @@ public function testVideoMultipleSourcesXHTML(): void
613613
614614 $ this ->assertSame ($ expected , $ video );
615615
616- // Reset
617- $ doctypes ->html5 = $ default ;
616+ $ this ->enableHtml5 ();
618617 }
619618
620619 public function testAudio (): void
@@ -642,9 +641,7 @@ public function testAudio(): void
642641
643642 public function testAudioXHTML (): void
644643 {
645- $ doctypes = config ('DocTypes ' );
646- $ default = $ doctypes ->html5 ;
647- $ doctypes ->html5 = false ;
644+ $ this ->disableHtml5 ();
648645
649646 $ expected = <<<'EOH'
650647 <audio id="test" controls>
@@ -670,8 +667,7 @@ public function testAudioXHTML(): void
670667
671668 $ this ->assertSame ($ expected , $ audio );
672669
673- // Reset
674- $ doctypes ->html5 = $ default ;
670+ $ this ->enableHtml5 ();
675671 }
676672
677673 public function testAudioSimple (): void
@@ -774,15 +770,12 @@ public function testSource(): void
774770
775771 public function testSourceXHTML (): void
776772 {
777- $ doctypes = config ('DocTypes ' );
778- $ default = $ doctypes ->html5 ;
779- $ doctypes ->html5 = false ;
773+ $ this ->disableHtml5 ();
780774
781775 $ expected = '<source src="http://example.com/index.php/sound.mpeg" type="audio/mpeg" /> ' ;
782776 $ this ->assertSame ($ expected , source ('sound.mpeg ' , 'audio/mpeg ' , '' , true ));
783777
784- // Reset
785- $ doctypes ->html5 = $ default ;
778+ $ this ->enableHtml5 ();
786779 }
787780
788781 public function testEmbed (): void
@@ -799,9 +792,7 @@ public function testEmbed(): void
799792
800793 public function testEmbedXHTML (): void
801794 {
802- $ doctypes = config ('DocTypes ' );
803- $ default = $ doctypes ->html5 ;
804- $ doctypes ->html5 = false ;
795+ $ this ->disableHtml5 ();
805796
806797 $ expected = <<<'EOH'
807798 <embed src="http://example.com/movie.mov" type="video/quicktime" class="test" />
@@ -812,8 +803,7 @@ public function testEmbedXHTML(): void
812803 $ embed = embed ('movie.mov ' , $ type , 'class="test" ' );
813804 $ this ->assertSame ($ expected , $ embed );
814805
815- // Reset
816- $ doctypes ->html5 = $ default ;
806+ $ this ->enableHtml5 ();
817807 }
818808
819809 public function testEmbedIndexed (): void
@@ -862,9 +852,7 @@ public function testObjectWithParams(): void
862852
863853 public function testObjectWithParamsXHTML (): void
864854 {
865- $ doctypes = config ('DocTypes ' );
866- $ default = $ doctypes ->html5 ;
867- $ doctypes ->html5 = false ;
855+ $ this ->disableHtml5 ();
868856
869857 $ expected = <<<'EOH'
870858 <object data="http://example.com/movie.swf" class="test">
@@ -882,8 +870,7 @@ public function testObjectWithParamsXHTML(): void
882870 $ object = object ('movie.swf ' , $ type , 'class="test" ' , $ parms );
883871 $ this ->assertSame ($ expected , $ object );
884872
885- // Reset
886- $ doctypes ->html5 = $ default ;
873+ $ this ->enableHtml5 ();
887874 }
888875
889876 public function testObjectIndexed (): void
0 commit comments