@@ -15,6 +15,9 @@ public function setUp(): void
1515 parent ::setUp ();
1616
1717 $ this ->app = $ this ->app ->clone ([
18+ 'roots ' => [
19+ 'index ' => self ::TMP
20+ ],
1821 'options ' => [
1922 'content.salt ' => 'test '
2023 ]
@@ -23,8 +26,8 @@ public function setUp(): void
2326
2427 public function testMediaHash (): void
2528 {
26- F::write ($ file = static ::TMP . '/content/test.jpg ' , 'test ' );
27- touch ($ file , 5432112345 );
29+ F::write ($ root = static ::TMP . '/content/test.jpg ' , 'test ' );
30+ touch ($ root , 5432112345 );
2831
2932 $ file = new File ([
3033 'filename ' => 'test.jpg ' ,
@@ -34,6 +37,33 @@ public function testMediaHash(): void
3437 $ this ->assertSame ('08756f3115-5432112345 ' , $ file ->mediaHash ());
3538 }
3639
40+ public function testMediaPath (): void
41+ {
42+ F::write ($ root = static ::TMP . '/content/test.jpg ' , 'test ' );
43+ touch ($ root , 5432112345 );
44+
45+ $ file = new File ([
46+ 'filename ' => 'test.jpg ' ,
47+ 'parent ' => $ this ->app ->site ()
48+ ]);
49+
50+ $ this ->assertSame (self ::TMP . '/media/site/08756f3115-5432112345/test.jpg ' , $ file ->mediaPath ());
51+ $ this ->assertSame (self ::TMP . '/media/site/08756f3115-5432112345/test-120x.jpg ' , $ file ->mediaPath ('test-120x.jpg ' ));
52+ }
53+
54+ public function testMediaRoot (): void
55+ {
56+ F::write ($ root = static ::TMP . '/content/test.jpg ' , 'test ' );
57+ touch ($ root , 5432112345 );
58+
59+ $ file = new File ([
60+ 'filename ' => 'test.jpg ' ,
61+ 'parent ' => $ this ->app ->site ()
62+ ]);
63+
64+ $ this ->assertSame (self ::TMP . '/media/site/08756f3115-5432112345 ' , $ file ->mediaRoot ());
65+ }
66+
3767 public function testMediaToken (): void
3868 {
3969 $ file = new File ([
@@ -43,4 +73,18 @@ public function testMediaToken(): void
4373
4474 $ this ->assertSame ('08756f3115 ' , $ file ->mediaToken ());
4575 }
76+
77+ public function testMediaUrl (): void
78+ {
79+ F::write ($ root = static ::TMP . '/content/test.jpg ' , 'test ' );
80+ touch ($ root , 5432112345 );
81+
82+ $ file = new File ([
83+ 'filename ' => 'test.jpg ' ,
84+ 'parent ' => $ this ->app ->site ()
85+ ]);
86+
87+ $ this ->assertSame ('/media/site/08756f3115-5432112345/test.jpg ' , $ file ->mediaUrl ());
88+ $ this ->assertSame ('/media/site/08756f3115-5432112345/test-120x.jpg ' , $ file ->mediaUrl ('test-120x.jpg ' ));
89+ }
4690}
0 commit comments