diff --git a/CHANGELOG.md b/CHANGELOG.md index 316c5a2..785ab5c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# Changelog since 1.0.6 + +* Made it compliant with PSR +* Made the class available through composer + # Changelog since 1.0.5 * Fixed filesPost so it can handle folders with spaces. diff --git a/Dropbox.php b/Dropbox.php index ce8e63f..1782158 100755 --- a/Dropbox.php +++ b/Dropbox.php @@ -5,7 +5,7 @@ * Dropbox class * * @author Tijs Verkoyen - * @version 1.0.6 + * @version 1.0.7 * @copyright Copyright (c), Tijs Verkoyen. All rights reserved. * @license BSD License */ @@ -25,7 +25,7 @@ class Dropbox const API_PORT = 443; // current version - const VERSION = '1.0.6'; + const VERSION = '1.0.7'; /** * A cURL instance diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..8d228d9 --- /dev/null +++ b/composer.json @@ -0,0 +1,21 @@ +{ + "name": "tijsverkoyen/dropbox", + "type": "library", + "description": "Dropbox is a wrapper-class to communicate with the Dropbox API.", + "homepage": "https://github.com/tijsverkoyen/Dropbox", + "license": "BSD", + "authors": [ + { + "name": "Tijs Verkoyen", + "email": "php-dropbox@verkoyen.eu", + "role": "Developer" + } + ], + "require": { + "php": ">=5.2.0", + "ext-curl": "*" + }, + "autoload": { + "classmap": [""] + } +} \ No newline at end of file diff --git a/tests/dropbox_test.php b/tests/dropbox_test.php index c150d2c..68664d7 100644 --- a/tests/dropbox_test.php +++ b/tests/dropbox_test.php @@ -11,194 +11,179 @@ class DropboxTest extends PHPUnit_Framework_TestCase { - /** - * @var Dropbox - */ - private $dropbox; - - - /** - * Prepares the environment before running a test. - */ - protected function setUp() - { - parent::setUp(); - - $this->dropbox = new Dropbox(APPLICATION_KEY, APPLICATION_SECRET); - $this->dropbox->setOAuthToken(TOKEN); - $this->dropbox->setOAuthTokenSecret(TOKEN_SECRET); - } - - - /** - * Cleans up the environment after running a test. - */ - protected function tearDown() - { - $this->dropbox = null; - - parent::tearDown(); - } - - - /** - * Tests Dropbox->getTimeOut() - */ - public function testGetTimeOut() - { - $this->dropbox->setTimeOut(5); - $this->assertEquals(5, $this->dropbox->getTimeOut()); - } - - - /** - * Tests Dropbox->getUserAgent() - */ - public function testGetUserAgent() - { - $this->dropbox->setUserAgent('testing/1.0.0'); - $this->assertEquals('PHP Dropbox/' . Dropbox::VERSION . ' testing/1.0.0' , $this->dropbox->getUserAgent()); - } - - - /** - * Tests Dropbox->oAuthRequestToken() - */ - public function testOAuthRequestToken() - { - $response = $this->dropbox->oAuthRequestToken(); - - $this->assertArrayHasKey('oauth_token_secret', $response); - $this->assertArrayHasKey('oauth_token', $response); - } - - - /** - * Tests Dropbox->account() - */ - public function testAccount() - { - $this->assertTrue($this->dropbox->account(time() . '-dropbox@verkoyen.eu', PASSWORD, 'Tijs', 'Verkoyen')); - } - - - /** - * Tests Dropbox->accountInfo() - */ - public function testAccountInfo() - { - $response = $this->dropbox->accountInfo(); - - $this->assertArrayHasKey('referral_link', $response); - $this->assertArrayHasKey('display_name', $response); - $this->assertArrayHasKey('uid', $response); - $this->assertArrayHasKey('email', $response); - } - - - /** - * Tests Dropbox->filesGet() - */ - public function testFilesGet() - { - $response = $this->dropbox->filesGet(BASE_PATH . 'hàh@, $.txt'); - - $this->assertArrayHasKey('content_type', $response); - $this->assertArrayHasKey('data', $response); - } - - - /** - * Tests Dropbox->filesPost() - */ - public function testFilesPost() - { - $this->assertTrue($this->dropbox->filesPost(BASE_PATH, realpath('/Users/tijs/Projects/dropbox/dropbox.php'))); - $this->assertTrue($this->dropbox->filesPost(BASE_PATH, realpath('/Users/tijs/Projects/dropbox/tests/with spaces.txt'))); - $this->assertTrue($this->dropbox->filesPost(BASE_PATH . 'with spaces', realpath('/Users/tijs/Projects/dropbox/tests/with spaces.txt'))); - - // cleanup - $this->dropbox->fileopsDelete(BASE_PATH . 'dropbox.php'); - $this->dropbox->fileopsDelete(BASE_PATH . 'with spaces.txt'); - $this->dropbox->fileopsDelete(BASE_PATH . 'with spaces/with spaces.txt'); - } - - - /** - * Tests Dropbox->metadata() - */ - public function testMetadata() - { - $response = $this->dropbox->metadata(BASE_PATH); - - $this->assertArrayHasKey('hash', $response); - $this->assertArrayHasKey('revision', $response); - $this->assertArrayHasKey('modified', $response); - $this->assertArrayHasKey('path', $response); - $this->assertArrayHasKey('contents', $response); - } - - - /** - * Tests Dropbox->thumbnails() - */ - public function testThumbnails() - { - $response = $this->dropbox->thumbnails(BASE_PATH . 'image.png'); - - $this->assertArrayHasKey('content_type', $response); - $this->assertArrayHasKey('data', $response); - } - - - /** - * Tests Dropbox->fileopsCopy() - */ - public function testFileopsCopy() - { - $response = $this->dropbox->fileopsCopy(BASE_PATH . 'image.png', BASE_PATH . 'copy.png'); - - $this->assertArrayHasKey('revision', $response); - $this->assertArrayHasKey('modified', $response); - $this->assertArrayHasKey('path', $response); - - // cleanup - $this->dropbox->fileopsDelete(BASE_PATH . 'copy.png'); - } - - - /** - * Tests Dropbox->fileopsCreateFolder() - */ - public function testFileopsCreateFolder() - { - $response = $this->dropbox->fileopsCreateFolder(BASE_PATH . 'created'); - - $this->assertArrayHasKey('revision', $response); - $this->assertArrayHasKey('modified', $response); - $this->assertArrayHasKey('path', $response); - - // cleanup - $this->dropbox->fileopsDelete(BASE_PATH . 'created'); - } - - - /** - * Tests Dropbox->fileopsMove() - */ - public function testFileopsMove() - { - $this->dropbox->fileopsCreateFolder(BASE_PATH . 'will_be_moved'); - - $response = $this->dropbox->fileopsMove(BASE_PATH . 'will_be_moved', BASE_PATH . 'moved'); - - $this->assertArrayHasKey('hash', $response); - $this->assertArrayHasKey('revision', $response); - $this->assertArrayHasKey('modified', $response); - $this->assertArrayHasKey('path', $response); - - // cleanup - $this->dropbox->fileopsDelete(BASE_PATH . 'moved'); - } + /** + * @var Dropbox + */ + private $dropbox; + + /** + * Prepares the environment before running a test. + */ + protected function setUp() + { + parent::setUp(); + + $this->dropbox = new Dropbox(APPLICATION_KEY, APPLICATION_SECRET); + $this->dropbox->setOAuthToken(TOKEN); + $this->dropbox->setOAuthTokenSecret(TOKEN_SECRET); + } + + /** + * Cleans up the environment after running a test. + */ + protected function tearDown() + { + $this->dropbox = null; + + parent::tearDown(); + } + + /** + * Tests Dropbox->getTimeOut() + */ + public function testGetTimeOut() + { + $this->dropbox->setTimeOut(5); + $this->assertEquals(5, $this->dropbox->getTimeOut()); + } + + /** + * Tests Dropbox->getUserAgent() + */ + public function testGetUserAgent() + { + $this->dropbox->setUserAgent('testing/1.0.0'); + $this->assertEquals('PHP Dropbox/' . Dropbox::VERSION . ' testing/1.0.0' , $this->dropbox->getUserAgent()); + } + + /** + * Tests Dropbox->oAuthRequestToken() + */ + public function testOAuthRequestToken() + { + $response = $this->dropbox->oAuthRequestToken(); + + $this->assertArrayHasKey('oauth_token_secret', $response); + $this->assertArrayHasKey('oauth_token', $response); + } + + /** + * Tests Dropbox->account() + */ + public function testAccount() + { + $this->assertTrue($this->dropbox->account(time() . '-dropbox@verkoyen.eu', PASSWORD, 'Tijs', 'Verkoyen')); + } + + /** + * Tests Dropbox->accountInfo() + */ + public function testAccountInfo() + { + $response = $this->dropbox->accountInfo(); + + $this->assertArrayHasKey('referral_link', $response); + $this->assertArrayHasKey('display_name', $response); + $this->assertArrayHasKey('uid', $response); + $this->assertArrayHasKey('email', $response); + } + + /** + * Tests Dropbox->filesGet() + */ + public function testFilesGet() + { + $response = $this->dropbox->filesGet(BASE_PATH . 'hàh@, $.txt'); + + $this->assertArrayHasKey('content_type', $response); + $this->assertArrayHasKey('data', $response); + } + + /** + * Tests Dropbox->filesPost() + */ + public function testFilesPost() + { + $this->assertTrue($this->dropbox->filesPost(BASE_PATH, realpath('/Users/tijs/Projects/dropbox/dropbox.php'))); + $this->assertTrue($this->dropbox->filesPost(BASE_PATH, realpath('/Users/tijs/Projects/dropbox/tests/with spaces.txt'))); + $this->assertTrue($this->dropbox->filesPost(BASE_PATH . 'with spaces', realpath('/Users/tijs/Projects/dropbox/tests/with spaces.txt'))); + + // cleanup + $this->dropbox->fileopsDelete(BASE_PATH . 'dropbox.php'); + $this->dropbox->fileopsDelete(BASE_PATH . 'with spaces.txt'); + $this->dropbox->fileopsDelete(BASE_PATH . 'with spaces/with spaces.txt'); + } + + /** + * Tests Dropbox->metadata() + */ + public function testMetadata() + { + $response = $this->dropbox->metadata(BASE_PATH); + + $this->assertArrayHasKey('hash', $response); + $this->assertArrayHasKey('revision', $response); + $this->assertArrayHasKey('modified', $response); + $this->assertArrayHasKey('path', $response); + $this->assertArrayHasKey('contents', $response); + } + + /** + * Tests Dropbox->thumbnails() + */ + public function testThumbnails() + { + $response = $this->dropbox->thumbnails(BASE_PATH . 'image.png'); + + $this->assertArrayHasKey('content_type', $response); + $this->assertArrayHasKey('data', $response); + } + + /** + * Tests Dropbox->fileopsCopy() + */ + public function testFileopsCopy() + { + $response = $this->dropbox->fileopsCopy(BASE_PATH . 'image.png', BASE_PATH . 'copy.png'); + + $this->assertArrayHasKey('revision', $response); + $this->assertArrayHasKey('modified', $response); + $this->assertArrayHasKey('path', $response); + + // cleanup + $this->dropbox->fileopsDelete(BASE_PATH . 'copy.png'); + } + + /** + * Tests Dropbox->fileopsCreateFolder() + */ + public function testFileopsCreateFolder() + { + $response = $this->dropbox->fileopsCreateFolder(BASE_PATH . 'created'); + + $this->assertArrayHasKey('revision', $response); + $this->assertArrayHasKey('modified', $response); + $this->assertArrayHasKey('path', $response); + + // cleanup + $this->dropbox->fileopsDelete(BASE_PATH . 'created'); + } + + /** + * Tests Dropbox->fileopsMove() + */ + public function testFileopsMove() + { + $this->dropbox->fileopsCreateFolder(BASE_PATH . 'will_be_moved'); + + $response = $this->dropbox->fileopsMove(BASE_PATH . 'will_be_moved', BASE_PATH . 'moved'); + + $this->assertArrayHasKey('hash', $response); + $this->assertArrayHasKey('revision', $response); + $this->assertArrayHasKey('modified', $response); + $this->assertArrayHasKey('path', $response); + + // cleanup + $this->dropbox->fileopsDelete(BASE_PATH . 'moved'); + } } - diff --git a/tests/index.php b/tests/index.php index 45a671c..5c149ba 100644 --- a/tests/index.php +++ b/tests/index.php @@ -40,5 +40,3 @@ // print echo '
' . htmlspecialchars($output, ENT_QUOTES, 'UTF-8') . '
'; - -?> \ No newline at end of file