forked from e-foundation/serverinfo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
213 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
imports: | ||
- javascript | ||
- php | ||
|
||
tools: | ||
external_code_coverage: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
language: php | ||
|
||
php: | ||
- 5.4 | ||
- 5.5 | ||
- 5.6 | ||
- 7 | ||
|
||
env: | ||
global: | ||
- CORE_BRANCH=master | ||
matrix: | ||
- DB=sqlite | ||
|
||
branches: | ||
only: | ||
- master | ||
- /^stable\d+(\.\d+)?$/ | ||
|
||
sudo: true | ||
before_install: | ||
- wget https://raw.githubusercontent.com/nextcloud/travis_ci/master/before_install.sh | ||
- bash ./before_install.sh serverinfo $CORE_BRANCH $DB | ||
|
||
script: | ||
# Test lint | ||
- cd ../server | ||
- cd apps/serverinfo | ||
- find . -name \*.php -exec php -l "{}" \; | ||
|
||
# Run phpunit tests | ||
- cd tests | ||
- phpunit --configuration phpunit.xml | ||
|
||
# Create coverage report | ||
- wget https://scrutinizer-ci.com/ocular.phar | ||
- php ocular.phar code-coverage:upload --format=php-clover clover.xml | ||
|
||
matrix: | ||
include: | ||
- php: 5.4 | ||
env: DB=mysql | ||
- php: 5.4 | ||
env: DB=pgsql | ||
fast_finish: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,14 @@ | ||
<?php | ||
/** | ||
* @copyright Copyright (c) 2016 Bjoern Schiessle <[email protected]> | ||
* | ||
* @license GNU AGPL version 3 or any later version | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
require_once __DIR__ . '/../../../tests/bootstrap.php'; | ||
require_once __DIR__ . '/../appinfo/autoload.php'; | ||
if (!defined('PHPUNIT_RUN')) { | ||
define('PHPUNIT_RUN', 1); | ||
} | ||
|
||
require_once __DIR__ . '/../../../lib/base.php'; | ||
|
||
if(!class_exists('PHPUnit_Framework_TestCase')) { | ||
require_once('PHPUnit/Autoload.php'); | ||
} | ||
\OC_App::loadApp('serverinfo'); | ||
OC_Hook::clear(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
<?php | ||
/** | ||
* @copyright Copyright (c) 2016 Bjoern Schiessle <[email protected]> | ||
* | ||
* @license GNU AGPL version 3 or any later version | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
|
||
namespace OCA\ServerInfo\Tests\lib\Controller; | ||
|
||
|
||
use OCA\ServerInfo\Controller\ApiController; | ||
use OCA\ServerInfo\DatabaseStatistics; | ||
use OCA\ServerInfo\PhpStatistics; | ||
use OCA\ServerInfo\ShareStatistics; | ||
use OCA\ServerInfo\StorageStatistics; | ||
use OCA\ServerInfo\SystemStatistics; | ||
use OCP\AppFramework\Http\DataResponse; | ||
use OCP\IRequest; | ||
use Test\TestCase; | ||
|
||
class ApiControllerTest extends TestCase { | ||
|
||
/** @var IRequest | \PHPUnit_Framework_MockObject_MockObject */ | ||
private $request; | ||
|
||
/** @var SystemStatistics | \PHPUnit_Framework_MockObject_MockObject */ | ||
private $systemStatistics; | ||
|
||
/** @var StorageStatistics | \PHPUnit_Framework_MockObject_MockObject */ | ||
private $storageStatistics; | ||
|
||
/** @var PhpStatistics | \PHPUnit_Framework_MockObject_MockObject */ | ||
private $phpStatistics; | ||
|
||
/** @var DatabaseStatistics | \PHPUnit_Framework_MockObject_MockObject */ | ||
private $databaseStatistics; | ||
|
||
/** @var ShareStatistics | \PHPUnit_Framework_MockObject_MockObject */ | ||
private $shareStatistics; | ||
|
||
/** @var ApiController */ | ||
private $instance; | ||
|
||
public function setUp() { | ||
parent::setUp(); | ||
|
||
$this->request = $this->getMockBuilder('OCP\IRequest') | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
|
||
$this->systemStatistics = $this->getMockBuilder('OCA\ServerInfo\SystemStatistics') | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
|
||
$this->storageStatistics = $this->getMockBuilder('OCA\ServerInfo\StorageStatistics') | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
|
||
$this->phpStatistics = $this->getMockBuilder('OCA\ServerInfo\PhpStatistics') | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
|
||
$this->databaseStatistics = $this->getMockBuilder('OCA\ServerInfo\DatabaseStatistics') | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
|
||
$this->shareStatistics = $this->getMockBuilder('OCA\ServerInfo\ShareStatistics') | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
|
||
$this->instance = new ApiController( | ||
'ServerInfoTest', | ||
$this->request, | ||
$this->systemStatistics, | ||
$this->storageStatistics, | ||
$this->phpStatistics, | ||
$this->databaseStatistics, | ||
$this->shareStatistics | ||
); | ||
} | ||
|
||
public function testInfo() { | ||
|
||
$this->systemStatistics->expects($this->once())->method('getSystemStatistics') | ||
->willReturn('systemStatistics'); | ||
$this->storageStatistics->expects($this->once())->method('getStorageStatistics') | ||
->willReturn('storageStatistics'); | ||
$this->phpStatistics->expects($this->once())->method('getPhpStatistics') | ||
->willReturn('phpStatistics'); | ||
$this->databaseStatistics->expects($this->once())->method('getDatabaseStatistics') | ||
->willReturn('databaseStatistics'); | ||
$this->shareStatistics->expects($this->once())->method('getShareStatistics') | ||
->willReturn('shareStatistics'); | ||
|
||
$result = $this->instance->info(); | ||
$this->assertTrue($result instanceof DataResponse); | ||
$data = $result->getData(); | ||
$this->assertTrue(isset($data['data']['nextcloud'])); | ||
$this->assertTrue(isset($data['data']['server'])); | ||
|
||
$this->assertSame('systemStatistics', $data['data']['nextcloud']['system']); | ||
$this->assertSame('storageStatistics', $data['data']['nextcloud']['storage']); | ||
$this->assertSame('shareStatistics', $data['data']['nextcloud']['shares']); | ||
$this->assertSame('unknown', $data['data']['server']['webserver']); | ||
$this->assertSame('databaseStatistics', $data['data']['server']['database']); | ||
$this->assertSame('phpStatistics', $data['data']['server']['php']); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<phpunit bootstrap="bootstrap.php" | ||
verbose="true" | ||
timeoutForSmallTests="900" | ||
timeoutForMediumTests="900" | ||
timeoutForLargeTests="900" | ||
> | ||
<testsuite name='Nextcloud - ServerInfo Tests'> | ||
<directory suffix='Test.php'>.</directory> | ||
</testsuite> | ||
<!-- filters for code coverage --> | ||
<filter> | ||
<whitelist> | ||
<directory suffix=".php">../../serverinfo/lib</directory> | ||
<exclude> | ||
<directory suffix=".php">../../serverinfo/l10n</directory> | ||
<directory suffix=".php">../../serverinfo/lists</directory> | ||
<directory suffix=".php">../../serverinfo/tests</directory> | ||
</exclude> | ||
</whitelist> | ||
</filter> | ||
<logging> | ||
<!-- and this is where your report will be written --> | ||
<log type="coverage-clover" target="./clover.xml"/> | ||
</logging> | ||
</phpunit> |
This file was deleted.
Oops, something went wrong.