diff --git a/phpunit.hhvm.xml b/phpunit.hhvm.xml new file mode 100644 index 0000000..5df38f6 --- /dev/null +++ b/phpunit.hhvm.xml @@ -0,0 +1,24 @@ + + + + + ./tests/ + + + + + ./src/ + + + \ No newline at end of file diff --git a/phpunit.php b/phpunit.php new file mode 100644 index 0000000..2c9fb1d --- /dev/null +++ b/phpunit.php @@ -0,0 +1,3 @@ + + + + + ./tests/ + + + + + ./src/ + + + + + + + + \ No newline at end of file diff --git a/src/BackblazeAdapter.php b/src/BackblazeAdapter.php index e92aed9..32a7541 100755 --- a/src/BackblazeAdapter.php +++ b/src/BackblazeAdapter.php @@ -34,11 +34,12 @@ public function has($path) */ public function write($path, $contents, Config $config) { - return $this->getClient()->upload([ + $file = $this->getClient()->upload([ 'BucketName' => $this->bucketName, 'FileName' => $path, 'Body' => $contents ]); + return $this->getFileInfo($file); } /** @@ -46,11 +47,12 @@ public function write($path, $contents, Config $config) */ public function writeStream($path, $resource, Config $config) { - return $this->getClient()->upload([ + $file = $this->getClient()->upload([ 'BucketName' => $this->bucketName, 'FileName' => $path, 'Body' => $resource ]); + return $this->getFileInfo($file); } /** diff --git a/tests/BackblazeAdapterTests.php b/tests/BackblazeAdapterTests.php new file mode 100644 index 0000000..a958824 --- /dev/null +++ b/tests/BackblazeAdapterTests.php @@ -0,0 +1,29 @@ +prophesize('ChrisWhite\B2\Client'); + return [ + [new Backblaze($mock->reveal(), 'my_bucket'), $mock], + ]; + } + + /** + * @dataProvider backblazeProvider + */ + public function testWrite($adapter, $mock) + { + $mock->upload(["BucketName" => "my_bucket", "FileName" => "something", "Body" => "contents"])->willReturn(new File('something','','','',''), false); + $result = $adapter->write('something', 'contents', new Config()); + $this->assertInternalType('array', $result); + $this->assertArrayHasKey('type', $result); + $this->assertEquals('file', $result['type']); + } +} \ No newline at end of file