FilesystemTest.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. }