@@ -135,4 +135,33 @@ function provideEncodablePathStrings () : \Generator {
135135 yield '/foo%2Fbar/baz/ ' => ['/foo%2Fbar/baz/ ' , '/foo%2fbar/baz/ ' ];
136136 }
137137
138+ /**
139+ * @param string $expectedPath
140+ * @param string $initialPath
141+ * @param string ...$concatPaths
142+ *
143+ * @dataProvider provideConcatPaths
144+ */
145+ function testExpectsPathsToBeConcatenated (string $ expectedPath , string $ expectedFileExtension , bool $ expectedIsAbsolute , bool $ expectedHasTail , string $ initialPath , string ...$ concatPaths ) {
146+ $ path = Path::createFromString ($ initialPath );
147+ foreach ($ concatPaths as $ concatPath ) {
148+ $ path = $ path ->concat (Path::createFromString ($ concatPath ));
149+ }
150+
151+ $ this ->assertSame ($ expectedPath , $ path ->compose ());
152+ $ this ->assertSame ($ expectedFileExtension , $ path ->getFileExtension ());
153+ $ this ->assertSame ($ expectedIsAbsolute , $ path ->isAbsolute ());
154+ $ this ->assertSame ($ expectedHasTail , $ path ->hasTail ());
155+ }
156+
157+ function provideConcatPaths () : \Generator {
158+ yield ['/foo/bar ' , '' , true , false , '/foo ' , '/bar ' ];
159+ yield ['/foo/bar ' , '' , true , false , '/foo ' , 'bar ' ];
160+ yield ['foo/bar ' , '' , false , false , 'foo ' , 'bar ' ];
161+ yield ['/foo ' , '' , true , false , '' , '/foo ' ];
162+ yield ['/foo/bar/ ' , '' , true , true , '' , '/foo ' , 'bar/ ' ];
163+ yield ['/foo/bar ' , '' , true , false , '/foo/ ' , '/bar ' ];
164+ yield ['/foo.php/bar.html ' , 'html ' , true , false , '/foo.php ' , 'bar.html ' ];
165+ }
166+
138167 }
0 commit comments