Skip to content

Commit

Permalink
Unit test FutureFile
Browse files Browse the repository at this point in the history
  • Loading branch information
DeepDiver1975 committed Oct 28, 2015
1 parent d137941 commit 3bc02fc
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 0 deletions.
11 changes: 11 additions & 0 deletions apps/dav/tests/unit/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

define('PHPUNIT_RUN', 1);

require_once __DIR__.'/../../../../lib/base.php';

if(!class_exists('PHPUnit_Framework_TestCase')) {
require_once('PHPUnit/Autoload.php');
}

OC_Hook::clear();
25 changes: 25 additions & 0 deletions apps/dav/tests/unit/phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8" ?>
<phpunit bootstrap="bootstrap.php"
verbose="true"
timeoutForSmallTests="900"
timeoutForMediumTests="900"
timeoutForLargeTests="900"
>
<testsuite name='unit'>
<directory suffix='test.php'>.</directory>
</testsuite>
<!-- filters for code coverage -->
<filter>
<whitelist>
<directory suffix=".php">../../dav</directory>
<exclude>
<directory suffix=".php">../../dav/tests</directory>
</exclude>
</whitelist>
</filter>
<logging>
<!-- and this is where your report will be written -->
<log type="coverage-clover" target="./clover.xml"/>
</logging>
</phpunit>

36 changes: 36 additions & 0 deletions apps/dav/tests/unit/upload/futurefiletest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

class FutureFileTest extends \PHPUnit_Framework_TestCase {

public function testGetContentType() {
$f = $this->mockFutureFile();
$this->assertEquals('application/octet-stream', $f->getContentType());
}

public function testGetETag() {
$f = $this->mockFutureFile();
$this->assertEquals('1234567890', $f->getETag());
}

public function testGetName() {
$f = $this->mockFutureFile();
$this->assertEquals('foo.txt', $f->getName());
}

/**
* @return \OCA\DAV\Upload\FutureFile
*/
private function mockFutureFile() {
$d = $this->getMockBuilder('OCA\DAV\Connector\Sabre\Directory')
->disableOriginalConstructor()
->setMethods(['getETag'])
->getMock();

$d->expects($this->any())
->method('getETag')
->willReturn('1234567890');

return new \OCA\DAV\Upload\FutureFile($d, 'foo.txt');
}
}

0 comments on commit 3bc02fc

Please sign in to comment.