largefilehelpergetfilesize.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /**
  3. * Copyright (c) 2014 Andreas Fischer <bantu@owncloud.com>
  4. * This file is licensed under the Affero General Public License version 3 or
  5. * later.
  6. * See the COPYING-README file.
  7. */
  8. namespace Test;
  9. /**
  10. * Tests whether LargeFileHelper is able to determine file size at all.
  11. * Large files are not considered yet.
  12. */
  13. class LargeFileHelperGetFileSize extends \PHPUnit_Framework_TestCase {
  14. protected $filename;
  15. protected $fileSize;
  16. protected $helper;
  17. public function setUp() {
  18. parent::setUp();
  19. $ds = DIRECTORY_SEPARATOR;
  20. $this->filename = dirname(__DIR__) . "{$ds}data{$ds}strängé filename (duplicate #2).txt";
  21. $this->fileSize = 446;
  22. $this->helper = new \OC\LargeFileHelper;
  23. }
  24. public function testGetFileSizeViaCurl() {
  25. if (!extension_loaded('curl')) {
  26. $this->markTestSkipped(
  27. 'The PHP curl extension is required for this test.'
  28. );
  29. }
  30. $this->assertSame(
  31. $this->fileSize,
  32. $this->helper->getFileSizeViaCurl($this->filename)
  33. );
  34. }
  35. public function testGetFileSizeViaCOM() {
  36. if (!extension_loaded('COM')) {
  37. $this->markTestSkipped(
  38. 'The PHP Windows COM extension is required for this test.'
  39. );
  40. }
  41. $this->assertSame(
  42. $this->fileSize,
  43. $this->helper->getFileSizeViaCOM($this->filename)
  44. );
  45. }
  46. public function testGetFileSizeViaExec() {
  47. if (!\OC_Helper::is_function_enabled('exec')) {
  48. $this->markTestSkipped(
  49. 'The exec() function needs to be enabled for this test.'
  50. );
  51. }
  52. $this->assertSame(
  53. $this->fileSize,
  54. $this->helper->getFileSizeViaExec($this->filename)
  55. );
  56. }
  57. public function testGetFileSizeNative() {
  58. $this->assertSame(
  59. $this->fileSize,
  60. $this->helper->getFileSizeNative($this->filename)
  61. );
  62. }
  63. }