largefilehelpergetfilesize.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. $this->filename = __DIR__ . '/../data/data.tar.gz';
  20. $this->fileSize = 4195;
  21. $this->helper = new \OC\LargeFileHelper;
  22. }
  23. public function testGetFileSizeViaCurl() {
  24. if (!extension_loaded('curl')) {
  25. $this->markTestSkipped(
  26. 'The PHP curl extension is required for this test.'
  27. );
  28. }
  29. $this->assertSame(
  30. $this->fileSize,
  31. $this->helper->getFileSizeViaCurl($this->filename)
  32. );
  33. }
  34. public function testGetFileSizeViaCOM() {
  35. if (!extension_loaded('COM')) {
  36. $this->markTestSkipped(
  37. 'The PHP Windows COM extension is required for this test.'
  38. );
  39. }
  40. $this->assertSame(
  41. $this->fileSize,
  42. $this->helper->getFileSizeViaCOM($this->filename)
  43. );
  44. }
  45. public function testGetFileSizeViaExec() {
  46. if (!\OC_Helper::is_function_enabled('exec')) {
  47. $this->markTestSkipped(
  48. 'The exec() function needs to be enabled for this test.'
  49. );
  50. }
  51. $this->assertSame(
  52. $this->fileSize,
  53. $this->helper->getFileSizeViaExec($this->filename)
  54. );
  55. }
  56. public function testGetFileSizeNative() {
  57. $this->assertSame(
  58. $this->fileSize,
  59. $this->helper->getFileSizeNative($this->filename)
  60. );
  61. }
  62. }