local.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /**
  3. * ownCloud
  4. *
  5. * @author Robin Appelman
  6. * @copyright 2012 Robin Appelman icewind@owncloud.com
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
  10. * License as published by the Free Software Foundation; either
  11. * version 3 of the License, or any later version.
  12. *
  13. * This library is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public
  19. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. namespace Test\Files\Storage;
  23. class Local extends Storage {
  24. /**
  25. * @var string tmpDir
  26. */
  27. private $tmpDir;
  28. protected function setUp() {
  29. parent::setUp();
  30. $this->tmpDir = \OC_Helper::tmpFolder();
  31. $this->instance = new \OC\Files\Storage\Local(array('datadir' => $this->tmpDir));
  32. }
  33. protected function tearDown() {
  34. \OC_Helper::rmdirr($this->tmpDir);
  35. parent::tearDown();
  36. }
  37. public function testStableEtag() {
  38. if (\OC_Util::runningOnWindows()) {
  39. $this->markTestSkipped('[Windows] On Windows platform we have no stable etag generation - yet');
  40. }
  41. $this->instance->file_put_contents('test.txt', 'foobar');
  42. $etag1 = $this->instance->getETag('test.txt');
  43. $etag2 = $this->instance->getETag('test.txt');
  44. $this->assertEquals($etag1, $etag2);
  45. }
  46. public function testEtagChange() {
  47. if (\OC_Util::runningOnWindows()) {
  48. $this->markTestSkipped('[Windows] On Windows platform we have no stable etag generation - yet');
  49. }
  50. $this->instance->file_put_contents('test.txt', 'foo');
  51. $this->instance->touch('test.txt', time() - 2);
  52. $etag1 = $this->instance->getETag('test.txt');
  53. $this->instance->file_put_contents('test.txt', 'bar');
  54. $etag2 = $this->instance->getETag('test.txt');
  55. $this->assertNotEquals($etag1, $etag2);
  56. }
  57. }