11<?php namespace de \thekid \dialog \unittest ;
22
3- use de \thekid \dialog \processing \{Files , Images };
3+ use de \thekid \dialog \processing \{Files , Images , ResizeTo , Processing };
44use test \{Assert , Expect , Test , Values };
55
66class FilesTest {
77
8+ /** Returns a fixture with a given processing instance */
9+ private function fixtureWith (Processing $ processing ): Files {
10+ return new Files ()->matching (['.jpg ' , '.jpeg ' ], $ processing );
11+ }
12+
813 #[Test]
914 public function can_create () {
1015 new Files ();
@@ -13,16 +18,18 @@ public function can_create() {
1318 #[Test, Values(['test.jpg ' , 'IMG_1234.JPG ' , '20221119-iOS.jpeg ' ])]
1419 public function matching_jpeg_files ($ filename ) {
1520 $ processing = new Images ();
16- $ fixture = new Files ()->matching (['.jpg ' , '.jpeg ' ], $ processing );
17-
18- Assert::equals ($ processing , $ fixture ->processing ($ filename ));
21+ Assert::equals ($ processing , $ this ->fixtureWith ($ processing )->processing ($ filename ));
1922 }
2023
2124 #[Test, Values(['test-jpg ' , 'IMG_1234JPG ' , 'jpeg ' , '.jpeg-file ' ])]
2225 public function unmatched_jpeg_files ($ filename ) {
2326 $ processing = new Images ();
24- $ fixture = new Files ()->matching (['.jpg ' , '.jpeg ' ], $ processing );
27+ Assert::null ($ this ->fixtureWith ($ processing )->processing ($ filename ));
28+ }
2529
26- Assert::null ($ fixture ->processing ($ filename ));
30+ #[Test]
31+ public function processed_pattern () {
32+ $ processing = new Images ()->targeting ('preview ' , new ResizeTo (720 , 'jpg ' ));
33+ Assert::equals ('/^(preview)-/ ' , $ this ->fixtureWith ($ processing )->processed ());
2734 }
2835}
0 commit comments