File tree Expand file tree Collapse file tree 4 files changed +28
-4
lines changed Expand file tree Collapse file tree 4 files changed +28
-4
lines changed Original file line number Diff line number Diff line change @@ -52,8 +52,13 @@ public function __construct(array $values)
52
52
Assert::keyExists ($ values , 'filename ' );
53
53
$ this ->url = TrimmedNonEmptyString::fromString ($ values ['filename ' ])->toString ();
54
54
55
- Assert::keyExists ($ values , 'is_external_url ' );
56
- $ this ->isExternalUrl = true === $ values ['is_external_url ' ];
55
+ $ isExternalUrl = false ;
56
+
57
+ if (\array_key_exists ('is_external_url ' , $ values )) {
58
+ $ isExternalUrl = true === $ values ['is_external_url ' ];
59
+ }
60
+
61
+ $ this ->isExternalUrl = $ isExternalUrl ;
57
62
58
63
$ alt = null ;
59
64
Original file line number Diff line number Diff line change 20
20
use Webmozart \Assert \Assert ;
21
21
use function Safe \json_decode ;
22
22
use function Safe \json_encode ;
23
- use function Symfony \Component \String \u ;
24
23
25
24
/**
26
25
* @experimental This class is experimental and may change in future versions.
Original file line number Diff line number Diff line change 20
20
21
21
/**
22
22
* @experimental This class is experimental and may change in future versions.
23
- *
23
+ *
24
24
* @author Silas Joisten <[email protected] >
25
25
*/
26
26
final readonly class MultiLink
Original file line number Diff line number Diff line change @@ -308,4 +308,24 @@ public static function orientationProvider(): iterable
308
308
yield 'landscape ' => [Orientation::Landscape, 1920 , 1080 ];
309
309
yield 'portrait ' => [Orientation::Portrait, 1080 , 1920 ];
310
310
}
311
+
312
+ #[Test]
313
+ public function isExternalUrl (): void
314
+ {
315
+ $ faker = self ::faker ();
316
+ $ response = $ faker ->storyAssetResponse ([
317
+ 'is_external_url ' => $ expected = $ faker ->boolean (),
318
+ ]);
319
+
320
+ self ::assertSame ($ expected , (new Asset ($ response ))->isExternalUrl );
321
+ }
322
+
323
+ #[Test]
324
+ public function isExternalUrlKeyIsOptional (): void
325
+ {
326
+ $ response = self ::faker ()->storyAssetResponse ();
327
+ unset($ response ['is_external_url ' ]);
328
+
329
+ self ::assertFalse ((new Asset ($ response ))->isExternalUrl );
330
+ }
311
331
}
You can’t perform that action at this time.
0 commit comments