Skip to content

Commit

Permalink
Merge pull request #2279 from MitrahSoft/LDEV-4736
Browse files Browse the repository at this point in the history
Added a testcase to the directoryEvery() function for LDEV-4736
  • Loading branch information
zspitzer authored Feb 1, 2024
2 parents 33e03dd + 4c2bf2f commit f37135e
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
40 changes: 40 additions & 0 deletions test/tickets/LDEV4736.cfc
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
component extends = "org.lucee.cfml.test.LuceeTestCase" labels="directoryEvery"{

function beforeAll() {
variables.name = ListFirst(ListLast(getCurrentTemplatePath(), "\/"), ".");
variables.parent = getDirectoryFromPath(getCurrentTemplatePath()) & name & Server.separator.file & "parent";
variables.SEP = Server.separator.file;
variables.path = parent&createUUID();
variables.path2 = path&"#SEP#a";

directoryCreate(path2);
cffile (action="write" addnewline="yes" file="#path##SEP#b.txt" output="aaa" fixnewline="no");
cffile (action="write" addnewline="yes" file="#path2##SEP#c.txt" output="aaa" fixnewline="no");
}

function run( testresults , testbox ) {
describe( "Testcase for DirectoryEvery() function", function() {
it( title = "Checking DirectoryEvery() with recurse=false", body = function ( currentSpec ) {
savecontent variable="result" {
DirectoryEvery( path, new LDEV4736.LDEV_4736(), false);
};
expect(result).toInclude("b.txt");
expect(result).toInclude("a");
});

it( title = "Checking DirectoryEvery() with recurse=true", body = function ( currentSpec ) {
savecontent variable="result" {
DirectoryEvery( path, new LDEV4736.LDEV_4736(), true);
};
expect(result).toInclude("a");
expect(result).toInclude("b.txt");
expect(result).toInclude("c.txt");
});
});
}

function afterAll(){
if(directoryExists(parent)) directorydelete(parent, true);
directoryDelete(path, true);
}
}
6 changes: 6 additions & 0 deletions test/tickets/LDEV4736/LDEV_4736.cfc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
component {
function invoke( path ) {
writeoutput( path );
return true;
}
}

0 comments on commit f37135e

Please sign in to comment.