Skip to content

Commit

Permalink
Configured PHPunit and added first test
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramesh Mhetre committed Aug 27, 2016
1 parent 9abd298 commit aa7a97b
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 2 deletions.
24 changes: 24 additions & 0 deletions phpunit.hhvm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="./phpunit.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="true"
verbose="true"
>
<testsuites>
<testsuite name="flysystem/tests">
<directory suffix=".php">./tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">./src/</directory>
</whitelist>
</filter>
</phpunit>
3 changes: 3 additions & 0 deletions phpunit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

require __DIR__.'/vendor/autoload.php';
29 changes: 29 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="./phpunit.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="true"
verbose="true"
>
<testsuites>
<testsuite name="flysystem/tests">
<directory suffix=".php">./tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">./src/</directory>
</whitelist>
</filter>
<logging>
<log type="coverage-text" target="php://stdout" showUncoveredFiles="true"/>
<log type="coverage-html" target="coverage" showUncoveredFiles="true"/>
<log type="coverage-clover" target="coverage.xml" showUncoveredFiles="true"/>
</logging>
</phpunit>
6 changes: 4 additions & 2 deletions src/BackblazeAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,25 @@ 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);
}

/**
* {@inheritdoc}
*/
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);
}

/**
Expand Down
29 changes: 29 additions & 0 deletions tests/BackblazeAdapterTests.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

use ChrisWhite\B2\Client;
use Mhetreramesh\Flysystem\BackblazeAdapter as Backblaze;
use \ChrisWhite\B2\File;
use \League\Flysystem\Config;

class BackblazeAdapterTests extends PHPUnit_Framework_TestCase
{
public function backblazeProvider()
{
$mock = $this->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']);
}
}

0 comments on commit aa7a97b

Please sign in to comment.