FilesystemTest.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. use Codeception\Module\Filesystem;
  3. use Codeception\Util\Stub;
  4. class FilesystemTest extends \PHPUnit\Framework\TestCase
  5. {
  6. /**
  7. * @var \Codeception\Module\Filesystem
  8. */
  9. protected $module;
  10. public function setUp()
  11. {
  12. $this->module = new Filesystem(make_container());
  13. $this->module->_before(Stub::makeEmpty('\Codeception\Test\Test'));
  14. }
  15. public function tearDown()
  16. {
  17. $this->module->_after(Stub::makeEmpty('\Codeception\Test\Test'));
  18. }
  19. public function testSeeFileFoundPassesWhenFileExists()
  20. {
  21. $this->module->seeFileFound('tests/data/dumps/mysql.sql');
  22. }
  23. public function testSeeFileFoundPassesWhenFileExistsInSubdirectoryOfPath()
  24. {
  25. $this->module->seeFileFound('mysql.sql', 'tests/data/');
  26. }
  27. /**
  28. * @expectedException PHPUnit\Framework\AssertionFailedError
  29. * @expectedExceptionMessage File "does-not-exist" not found at
  30. */
  31. public function testSeeFileFoundFailsWhenFileDoesNotExist()
  32. {
  33. $this->module->seeFileFound('does-not-exist');
  34. }
  35. /**
  36. * @expectedException PHPUnit\Framework\AssertionFailedError
  37. * @expectedExceptionMessageRegExp /Directory does not exist: .*does-not-exist/
  38. */
  39. public function testSeeFileFoundFailsWhenPathDoesNotExist()
  40. {
  41. $this->module->seeFileFound('mysql.sql', 'does-not-exist');
  42. }
  43. public function testDontSeeFileFoundPassesWhenFileDoesNotExists()
  44. {
  45. $this->module->dontSeeFileFound('does-not-exist');
  46. }
  47. public function testDontSeeFileFoundPassesWhenFileDoesNotExistsInPath()
  48. {
  49. $this->module->dontSeeFileFound('does-not-exist', 'tests/data/');
  50. }
  51. /**
  52. * @expectedException PHPUnit\Framework\AssertionFailedError
  53. * @expectedExceptionMessage Failed asserting that file "tests/data/dumps/mysql.sql" does not exist.
  54. */
  55. public function testDontSeeFileFoundFailsWhenFileExists()
  56. {
  57. $this->module->dontSeeFileFound('tests/data/dumps/mysql.sql');
  58. }
  59. /**
  60. * @expectedException PHPUnit\Framework\AssertionFailedError
  61. * @expectedExceptionMessageRegExp /Directory does not exist: .*does-not-exist/
  62. */
  63. public function testDontSeeFileFoundFailsWhenPathDoesNotExist()
  64. {
  65. $this->module->dontSeeFileFound('mysql.sql', 'does-not-exist');
  66. }
  67. /**
  68. * @expectedException PHPUnit\Framework\AssertionFailedError
  69. * @expectedExceptionMessageRegExp /Failed asserting that file ".*tests\/data\/dumps\/mysql.sql" does not exist/
  70. */
  71. public function testDontSeeFileFoundFailsWhenFileExistsInSubdirectoryOfPath()
  72. {
  73. $this->module->dontSeeFileFound('mysql.sql', 'tests/data/');
  74. }
  75. }