Skip to content

Commit

Permalink
QUESTION ABOUT MOCKING TESTS
Browse files Browse the repository at this point in the history
  • Loading branch information
snim2 committed Sep 22, 2023
1 parent f890569 commit 2949ad0
Showing 1 changed file with 34 additions and 2 deletions.
36 changes: 34 additions & 2 deletions tests/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,39 @@ private function getProjectDirectory($dir)
private function getDir()
{
$root = \org\bovigo\vfs\vfsStream::setup();

return $root->url();
$dir = $root->url();

//
// None of these attempts to avoid the tests failing due to missing
// directories work, they don't work if you put them directly
// in the tests, but file_exists() returns true until it gets to
// WhippetHelpers. I think this is because in whippet_init() we ignore
// any directories that have been passed in, and search for a whippet.json
// file on the actual disk, so the virtual disk is never read.
//
// We seem to have more than one way of knowing which dir is the project
// repo, and whippet_init() recurses the directory to find a .json file.
// This means that the virtual fs that we use to mock the tests will not
// be used, hence the errors. I think we should probably remove that
// code, but I'm not sure if anything is relying on it...
//


mkdir($dir.'/config');
touch($dir.'/config/application.json');
mkdir($dir.'/wp-content');
mkdir($dir.'/wp-content/plugins');
// // if (!file_exists("{$dir}/config")) {
// // printf("FS SAYS NOPE");
// // }
// \org\bovigo\vfs\vfsStream::newDirectory($dir.'/config');
// // \org\bovigo\vfs\vfsStream::newDirectory($dir.'/wp-content/plugins');

// // mkdir(\org\bovigo\vfs\vfsStream::url($dir.'/wp-content/plugins'));
// mkdir(\org\bovigo\vfs\vfsStream::url($dir.'/config'));

// \org\bovigo\vfs\vfsStream::create(['config' => [], ['wp-content' => ['plugins' => []]]], $root);

return $dir;
}
}

0 comments on commit 2949ad0

Please sign in to comment.