GoogleTest.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Bart Visscher <bartv@thisnet.nl>
  6. * @author Christopher Schäpers <kondou@ts.unde.re>
  7. * @author Joas Schilling <coding@schilljs.com>
  8. * @author Michael Gapczynski <GapczynskiM@gmail.com>
  9. * @author Morris Jobke <hey@morrisjobke.de>
  10. * @author Robin Appelman <robin@icewind.nl>
  11. * @author Robin McCorkell <robin@mccorkell.me.uk>
  12. * @author Thomas Müller <thomas.mueller@tmit.eu>
  13. * @author Vincent Petry <pvince81@owncloud.com>
  14. *
  15. * @license AGPL-3.0
  16. *
  17. * This code is free software: you can redistribute it and/or modify
  18. * it under the terms of the GNU Affero General Public License, version 3,
  19. * as published by the Free Software Foundation.
  20. *
  21. * This program is distributed in the hope that it will be useful,
  22. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24. * GNU Affero General Public License for more details.
  25. *
  26. * You should have received a copy of the GNU Affero General Public License, version 3,
  27. * along with this program. If not, see <http://www.gnu.org/licenses/>
  28. *
  29. */
  30. namespace OCA\Files_External\Tests\Storage;
  31. use \OCA\Files_External\Lib\Storage\Google;
  32. /**
  33. * Class GoogleTest
  34. *
  35. * @group DB
  36. *
  37. * @package OCA\Files_External\Tests\Storage
  38. */
  39. class GoogleTest extends \Test\Files\Storage\Storage {
  40. private $config;
  41. protected function setUp() {
  42. parent::setUp();
  43. $this->config = include('files_external/tests/config.php');
  44. if (!is_array($this->config) || !isset($this->config['google'])
  45. || !$this->config['google']['run']
  46. ) {
  47. $this->markTestSkipped('Google Drive backend not configured');
  48. }
  49. $this->instance = new Google($this->config['google']);
  50. }
  51. protected function tearDown() {
  52. if ($this->instance) {
  53. $this->instance->rmdir('/');
  54. }
  55. parent::tearDown();
  56. }
  57. public function testSameNameAsFolderWithExtension() {
  58. $this->assertTrue($this->instance->mkdir('testsamename'));
  59. $this->assertEquals(13, $this->instance->file_put_contents('testsamename.txt', 'some contents'));
  60. $this->assertEquals('some contents', $this->instance->file_get_contents('testsamename.txt'));
  61. $this->assertTrue($this->instance->is_dir('testsamename'));
  62. $this->assertTrue($this->instance->unlink('testsamename.txt'));
  63. $this->assertTrue($this->instance->rmdir('testsamename'));
  64. }
  65. }