1212namespace Zenstruck \Tests \Filesystem \Symfony ;
1313
1414use Symfony \Bundle \FrameworkBundle \Test \KernelTestCase ;
15+ use Symfony \Component \HttpKernel \Kernel ;
1516use Zenstruck \Filesystem \Node \Path \Expression ;
1617use Zenstruck \Filesystem \Test \InteractsWithFilesystem ;
1718use Zenstruck \Filesystem \Test \ResetFilesystem ;
@@ -101,15 +102,29 @@ public function can_generate_urls(): void
101102 $ privateFile = $ this ->filesystem ()->write ('private://bar/file.png ' , 'content ' )->ensureImage ();
102103
103104 $ this ->assertStringContainsString ('http://localhost/private/bar/file.png ' , $ privateFile ->publicUrl ());
104- $ this ->assertStringContainsString ('http://localhost/private/bar/file.png ' , $ privateFile ->publicUrl (['expires ' => 'tomorrow ' ]));
105105 $ this ->assertSame ('/glide/bar/file.png?w=100&h=200 ' , $ privateFile ->transformUrl (['w ' => 100 , 'h ' => 200 ]));
106106 }
107107
108108 /**
109109 * @test
110110 */
111- public function can_generate_signed_and_temporary_urls (): void
111+ public function can_generate_signed_urls (): void
112112 {
113+ $ privateFile = $ this ->filesystem ()->write ('private://bar/file.png ' , 'content ' )->ensureImage ();
114+
115+ $ this ->assertStringContainsString ('_hash= ' , $ privateFile ->publicUrl ());
116+ $ this ->assertStringNotContainsString ('_expiration= ' , $ privateFile ->publicUrl ());
117+ }
118+
119+ /**
120+ * @test
121+ */
122+ public function can_generate_temporary_urls (): void
123+ {
124+ if (Kernel::VERSION_ID < 70100 ) {
125+ $ this ->markTestSkipped ('Temporary URLs are not supported in Symfony < 7.1. ' );
126+ }
127+
113128 $ publicFile = $ this ->filesystem ()->write ('public://foo/file.png ' , 'content ' )->ensureImage ();
114129
115130 $ this ->assertStringContainsString ('/temp/foo/file.png ' , $ publicFile ->temporaryUrl ('tomorrow ' ));
@@ -118,15 +133,26 @@ public function can_generate_signed_and_temporary_urls(): void
118133
119134 $ privateFile = $ this ->filesystem ()->write ('private://bar/file.png ' , 'content ' )->ensureImage ();
120135
121- $ this ->assertStringContainsString ('_hash= ' , $ privateFile ->publicUrl ());
122- $ this ->assertStringNotContainsString ('_expiration= ' , $ privateFile ->publicUrl ());
123- $ this ->assertStringContainsString ('_hash= ' , $ privateFile ->publicUrl (['expires ' => 'tomorrow ' ]));
124- $ this ->assertStringContainsString ('_expiration= ' , $ privateFile ->publicUrl (['expires ' => 'tomorrow ' ]));
125136 $ this ->assertStringContainsString ('/private/bar/file.png ' , $ privateFile ->temporaryUrl ('tomorrow ' ));
126137 $ this ->assertStringContainsString ('_hash= ' , $ privateFile ->temporaryUrl ('tomorrow ' ));
127138 $ this ->assertStringContainsString ('_expiration= ' , $ privateFile ->temporaryUrl ('tomorrow ' ));
128139 }
129140
141+ /**
142+ * @test
143+ */
144+ public function can_generate_expiring_public_urls (): void
145+ {
146+ if (Kernel::VERSION_ID < 70100 ) {
147+ $ this ->markTestSkipped ('Expiring URLs are not supported in Symfony < 7.1. ' );
148+ }
149+
150+ $ privateFile = $ this ->filesystem ()->write ('private://bar/file.png ' , 'content ' )->ensureImage ();
151+
152+ $ this ->assertStringContainsString ('_hash= ' , $ privateFile ->publicUrl (['expires ' => 'tomorrow ' ]));
153+ $ this ->assertStringContainsString ('_expiration= ' , $ privateFile ->publicUrl (['expires ' => 'tomorrow ' ]));
154+ }
155+
130156 /**
131157 * @test
132158 */
0 commit comments