1
0
mirror of https://github.com/owncloud/bookmarks.git synced 2024-12-01 05:24:11 +01:00

Merge pull request #87 from owncloud/travis-etc

initial setup of qa tooling
This commit is contained in:
Thomas Müller 2014-09-10 15:14:34 +02:00
commit 4ea680aebb
7 changed files with 138 additions and 8 deletions

11
.scrutinizer.yml Normal file
View File

@ -0,0 +1,11 @@
filter:
excluded_paths:
- '3rdparty/*'
imports:
- javascript
- php
tools:
external_code_coverage: true

46
.travis.yml Normal file
View File

@ -0,0 +1,46 @@
language: php
php:
- 5.3
- 5.4
- 5.5
env:
global:
- CORE_BRANCH=master
matrix:
- DB=sqlite
branches:
only:
- master
- stable7
before_install:
# - composer install
- wget https://raw.githubusercontent.com/owncloud/administration/master/travis-ci/before_install.sh
- bash ./before_install.sh bookmarks $CORE_BRANCH $DB
- cd ../core
- php occ app:enable bookmarks
script:
# Test lint
- cd apps/bookmarks
- sh -c "if [ '$DB' = 'sqlite' ]; then ant test; fi"
# 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
allow_failures:
- php: hhvm
fast_finish: true

25
build.xml Normal file
View File

@ -0,0 +1,25 @@
<project name="owncloud-mail" basedir="." default="test">
<property file="build.properties"/>
<!-- test - Tests if the code syntax is correct and executes phpunit tests -->
<target name="test">
<apply executable="php" failonerror="true">
<arg value="-l" />
<fileset dir=".">
<include name="**/*.php" />
<exclude name="vendor/**/*" />
</fileset>
</apply>
<!--<exec executable="phpunit" failonerror="true">-->
<!--<arg value="-c" />-->
<!--<arg path="${build.src.dir}/app/"/>-->
<!--<arg value="- -log-junit" />-->
<!--<arg path="${report.dir}/phpunit.xml"/>-->
<!--<arg value="- -coverage-clover" />-->
<!--<arg path=" ${report.dir}/clover.xml"/>-->
<!--</exec>-->
</target>
</project>

View File

@ -371,22 +371,28 @@ class OC_Bookmarks_Bookmarks{
/**
* Add a set of tags for a bookmark
* @param int $bookmark_id The bookmark reference
*
* @param int $bookmarkId The bookmark reference
* @param array $tags Set of tags to add to the bookmark
* @return null
**/
private static function addTags($bookmark_id, $tags) {
$query = OCP\DB::prepare("
INSERT INTO `*PREFIX*bookmarks_tags`
(`bookmark_id`, `tag`)
VALUES (?, ?)");
private static function addTags($bookmarkId, $tags) {
$sql = 'INSERT INTO `*PREFIX*bookmarks_tags` (`bookmark_id`, `tag`) select ?, ? ';
$dbtype = OCP\Config::getSystemValue( 'dbtype', 'sqlite' );
if ($dbtype === 'mysql') {
$sql .= 'from dual ';
}
$sql .= 'where not exists(select * from oc_bookmarks_tags where bookmark_id = ? and tag = ?)';
$query = OCP\DB::prepare($sql);
foreach ($tags as $tag) {
$tag = trim($tag);
if(empty($tag)) {
//avoid saving blankspaces
//avoid saving white spaces
continue;
}
$params = array($bookmark_id, trim($tag));
$params = array($bookmarkId, $tag, $bookmarkId, $tag);
$query->execute($params);
}
}

15
tests/bootstrap.php Normal file
View File

@ -0,0 +1,15 @@
<?php
global $RUNTIME_NOAPPS;
$RUNTIME_NOAPPS = true;
define('PHPUNIT_RUN', 1);
require_once __DIR__.'/../../../lib/base.php';
if(!class_exists('PHPUnit_Framework_TestCase')) {
require_once('PHPUnit/Autoload.php');
}
OC_Hook::clear();
OC_Log::$enabled = false;

27
tests/phpunit.xml Normal file
View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8" ?>
<phpunit bootstrap="bootstrap.php"
strict="true"
verbose="true"
timeoutForSmallTests="900"
timeoutForMediumTests="900"
timeoutForLargeTests="900"
>
<testsuite name='ownCloud - Bookmarks App Tests'>
<directory suffix='test.php'>.</directory>
</testsuite>
<!-- filters for code coverage -->
<filter>
<whitelist>
<directory suffix=".php">../../bookmarks</directory>
<exclude>
<directory suffix=".php">../../bookmarks/l10n</directory>
<directory suffix=".php">../../bookmarks/tests</directory>
</exclude>
</whitelist>
</filter>
<logging>
<!-- and this is where your report will be written -->
<log type="coverage-clover" target="./clover.xml"/>
</logging>
</phpunit>