@@ -110,6 +110,43 @@ public function testCrossOrigin(string $expected, ?string $crossOrigin): void
110110 $ this ->assertSame ($ expected , (string )Link::tag ()->crossOrigin ($ crossOrigin ));
111111 }
112112
113+ public function dataTestAs (): array
114+ {
115+ return [
116+ ['<link> ' , null ],
117+ ['<link as=""> ' , '' ],
118+ ['<link as="video"> ' , 'video ' ],
119+ ];
120+ }
121+
122+ /**
123+ * @dataProvider dataTestAs
124+ */
125+ public function testAs (string $ expected , ?string $ as ): void
126+ {
127+ $ this ->assertSame ($ expected , (string )Link::tag ()->as ($ as ));
128+ }
129+
130+ public function dataPreload (): array
131+ {
132+ return [
133+ ['<link href="/main.css" rel="preload"> ' , '/main.css ' ],
134+ ['<link href="/main.css" rel="preload" as="style"> ' , '/main.css ' , 'style ' ],
135+ ];
136+ }
137+
138+ /**
139+ * @dataProvider dataPreload
140+ */
141+ public function testPreload (string $ expected , string $ url , string $ as = null ): void
142+ {
143+ $ tag = $ as === null
144+ ? Link::tag ()->preload ($ url )
145+ : Link::tag ()->preload ($ url , $ as );
146+
147+ $ this ->assertSame ($ expected , $ tag ->render ());
148+ }
149+
113150 public function testImmutability (): void
114151 {
115152 $ link = Link::tag ();
@@ -119,5 +156,7 @@ public function testImmutability(): void
119156 $ this ->assertNotSame ($ link , $ link ->type (null ));
120157 $ this ->assertNotSame ($ link , $ link ->title (null ));
121158 $ this ->assertNotSame ($ link , $ link ->crossOrigin (null ));
159+ $ this ->assertNotSame ($ link , $ link ->as (null ));
160+ $ this ->assertNotSame ($ link , $ link ->preload ('' ));
122161 }
123162}
0 commit comments