15
15
use CodeIgniter \Files \Exceptions \FileNotFoundException ;
16
16
use CodeIgniter \Test \CIUnitTestCase ;
17
17
use Config \App ;
18
+ use Config \DocTypes ;
18
19
19
20
/**
20
21
* @internal
@@ -206,41 +207,48 @@ public function testIMGWithIndexpage(): void
206
207
207
208
public function testIMGXHTML (): void
208
209
{
209
- $ doctypes = config ('DocTypes ' );
210
- $ default = $ doctypes ->html5 ;
211
- $ doctypes ->html5 = false ;
210
+ $ this ->disableHtml5 ();
212
211
213
212
$ target = 'http://site.com/images/picture.jpg ' ;
214
213
$ expected = '<img src="http://site.com/images/picture.jpg" alt="" /> ' ;
215
214
$ this ->assertSame ($ expected , img ($ target ));
216
215
217
- $ doctypes -> html5 = $ default ;
216
+ $ this -> enableHtml5 () ;
218
217
}
219
218
220
- public function testIMGXHTMLWithoutProtocol (): void
219
+ private function disableHtml5 ()
221
220
{
222
- $ doctypes = config ('DocTypes ' );
223
- $ default = $ doctypes ->html5 ;
221
+ $ doctypes = new DocTypes ();
224
222
$ 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 ();
225
235
226
236
$ target = 'assets/mugshot.jpg ' ;
227
237
$ expected = '<img src="http://example.com/assets/mugshot.jpg" alt="" /> ' ;
228
238
$ this ->assertSame ($ expected , img ($ target ));
229
239
230
- $ doctypes -> html5 = $ default ;
240
+ $ this -> enableHtml5 () ;
231
241
}
232
242
233
243
public function testIMGXHTMLWithIndexpage (): void
234
244
{
235
- $ doctypes = config ('DocTypes ' );
236
- $ default = $ doctypes ->html5 ;
237
- $ doctypes ->html5 = false ;
245
+ $ this ->disableHtml5 ();
238
246
239
247
$ target = 'assets/mugshot.jpg ' ;
240
248
$ expected = '<img src="http://example.com/index.php/assets/mugshot.jpg" alt="" /> ' ;
241
249
$ this ->assertSame ($ expected , img ($ target , true ));
242
250
243
- $ doctypes -> html5 = $ default ;
251
+ $ this -> enableHtml5 () ;
244
252
}
245
253
246
254
public function testImgData (): void
@@ -355,16 +363,13 @@ public function testLinkTag(): void
355
363
356
364
public function testLinkTagXHTML (): void
357
365
{
358
- $ doctypes = config ('DocTypes ' );
359
- $ default = $ doctypes ->html5 ;
360
- $ doctypes ->html5 = false ;
366
+ $ this ->disableHtml5 ();
361
367
362
368
$ target = 'css/mystyles.css ' ;
363
369
$ expected = '<link href="http://example.com/css/mystyles.css" rel="stylesheet" type="text/css" /> ' ;
364
370
$ this ->assertSame ($ expected , link_tag ($ target ));
365
371
366
- // Reset
367
- $ doctypes ->html5 = $ default ;
372
+ $ this ->enableHtml5 ();
368
373
}
369
374
370
375
public function testLinkTagMedia (): void
@@ -509,9 +514,7 @@ public function testVideoWithTracks(): void
509
514
510
515
public function testVideoWithTracksXHTML (): void
511
516
{
512
- $ doctypes = config ('DocTypes ' );
513
- $ default = $ doctypes ->html5 ;
514
- $ doctypes ->html5 = false ;
517
+ $ this ->disableHtml5 ();
515
518
516
519
$ expected = <<<'EOH'
517
520
<video src="http://example.com/test.mp4" controls>
@@ -531,8 +534,7 @@ public function testVideoWithTracksXHTML(): void
531
534
$ video = video ($ target , $ message , 'controls ' , $ tracks );
532
535
$ this ->assertSame ($ expected , $ video );
533
536
534
- // Reset
535
- $ doctypes ->html5 = $ default ;
537
+ $ this ->enableHtml5 ();
536
538
}
537
539
538
540
public function testVideoWithTracksAndIndex (): void
@@ -581,9 +583,7 @@ public function testVideoMultipleSources(): void
581
583
582
584
public function testVideoMultipleSourcesXHTML (): void
583
585
{
584
- $ doctypes = config ('DocTypes ' );
585
- $ default = $ doctypes ->html5 ;
586
- $ doctypes ->html5 = false ;
586
+ $ this ->disableHtml5 ();
587
587
588
588
$ expected = <<<'EOH'
589
589
<video class="test" controls>
@@ -613,8 +613,7 @@ public function testVideoMultipleSourcesXHTML(): void
613
613
614
614
$ this ->assertSame ($ expected , $ video );
615
615
616
- // Reset
617
- $ doctypes ->html5 = $ default ;
616
+ $ this ->enableHtml5 ();
618
617
}
619
618
620
619
public function testAudio (): void
@@ -642,9 +641,7 @@ public function testAudio(): void
642
641
643
642
public function testAudioXHTML (): void
644
643
{
645
- $ doctypes = config ('DocTypes ' );
646
- $ default = $ doctypes ->html5 ;
647
- $ doctypes ->html5 = false ;
644
+ $ this ->disableHtml5 ();
648
645
649
646
$ expected = <<<'EOH'
650
647
<audio id="test" controls>
@@ -670,8 +667,7 @@ public function testAudioXHTML(): void
670
667
671
668
$ this ->assertSame ($ expected , $ audio );
672
669
673
- // Reset
674
- $ doctypes ->html5 = $ default ;
670
+ $ this ->enableHtml5 ();
675
671
}
676
672
677
673
public function testAudioSimple (): void
@@ -774,15 +770,12 @@ public function testSource(): void
774
770
775
771
public function testSourceXHTML (): void
776
772
{
777
- $ doctypes = config ('DocTypes ' );
778
- $ default = $ doctypes ->html5 ;
779
- $ doctypes ->html5 = false ;
773
+ $ this ->disableHtml5 ();
780
774
781
775
$ expected = '<source src="http://example.com/index.php/sound.mpeg" type="audio/mpeg" /> ' ;
782
776
$ this ->assertSame ($ expected , source ('sound.mpeg ' , 'audio/mpeg ' , '' , true ));
783
777
784
- // Reset
785
- $ doctypes ->html5 = $ default ;
778
+ $ this ->enableHtml5 ();
786
779
}
787
780
788
781
public function testEmbed (): void
@@ -799,9 +792,7 @@ public function testEmbed(): void
799
792
800
793
public function testEmbedXHTML (): void
801
794
{
802
- $ doctypes = config ('DocTypes ' );
803
- $ default = $ doctypes ->html5 ;
804
- $ doctypes ->html5 = false ;
795
+ $ this ->disableHtml5 ();
805
796
806
797
$ expected = <<<'EOH'
807
798
<embed src="http://example.com/movie.mov" type="video/quicktime" class="test" />
@@ -812,8 +803,7 @@ public function testEmbedXHTML(): void
812
803
$ embed = embed ('movie.mov ' , $ type , 'class="test" ' );
813
804
$ this ->assertSame ($ expected , $ embed );
814
805
815
- // Reset
816
- $ doctypes ->html5 = $ default ;
806
+ $ this ->enableHtml5 ();
817
807
}
818
808
819
809
public function testEmbedIndexed (): void
@@ -862,9 +852,7 @@ public function testObjectWithParams(): void
862
852
863
853
public function testObjectWithParamsXHTML (): void
864
854
{
865
- $ doctypes = config ('DocTypes ' );
866
- $ default = $ doctypes ->html5 ;
867
- $ doctypes ->html5 = false ;
855
+ $ this ->disableHtml5 ();
868
856
869
857
$ expected = <<<'EOH'
870
858
<object data="http://example.com/movie.swf" class="test">
@@ -882,8 +870,7 @@ public function testObjectWithParamsXHTML(): void
882
870
$ object = object ('movie.swf ' , $ type , 'class="test" ' , $ parms );
883
871
$ this ->assertSame ($ expected , $ object );
884
872
885
- // Reset
886
- $ doctypes ->html5 = $ default ;
873
+ $ this ->enableHtml5 ();
887
874
}
888
875
889
876
public function testObjectIndexed (): void
0 commit comments