File tree 2 files changed +41
-0
lines changed
src/Symfony/Component/Finder
2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,13 @@ public function getRelativePathname()
57
57
return $ this ->relativePathname ;
58
58
}
59
59
60
+ public function getFilenameWithoutExtension (): string
61
+ {
62
+ $ filename = $ this ->getFilename ();
63
+
64
+ return \pathinfo ($ filename , PATHINFO_FILENAME );
65
+ }
66
+
60
67
/**
61
68
* Returns the contents of the file.
62
69
*
Original file line number Diff line number Diff line change @@ -1007,6 +1007,40 @@ public function testRelativePathname()
1007
1007
$ this ->assertEquals ($ ref , $ paths );
1008
1008
}
1009
1009
1010
+ public function testGetFilenameWithoutExtension ()
1011
+ {
1012
+ $ finder = $ this ->buildFinder ()->in (self ::$ tmpDir )->sortByName ();
1013
+
1014
+ $ fileNames = [];
1015
+
1016
+ foreach ($ finder as $ file ) {
1017
+ $ fileNames [] = $ file ->getFilenameWithoutExtension ();
1018
+ }
1019
+
1020
+ $ ref = [
1021
+ 'test ' ,
1022
+ 'toto ' ,
1023
+ 'test ' ,
1024
+ 'foo ' ,
1025
+ 'bar ' ,
1026
+ 'foo bar ' ,
1027
+ 'qux ' ,
1028
+ 'baz_100_1 ' ,
1029
+ 'baz_1_2 ' ,
1030
+ 'qux_0_1 ' ,
1031
+ 'qux_1000_1 ' ,
1032
+ 'qux_1002_0 ' ,
1033
+ 'qux_10_2 ' ,
1034
+ 'qux_12_0 ' ,
1035
+ 'qux_2_0 ' ,
1036
+ ];
1037
+
1038
+ sort ($ fileNames );
1039
+ sort ($ ref );
1040
+
1041
+ $ this ->assertEquals ($ ref , $ fileNames );
1042
+ }
1043
+
1010
1044
public function testAppendWithAFinder ()
1011
1045
{
1012
1046
$ finder = $ this ->buildFinder ();
You can’t perform that action at this time.
0 commit comments