Fix travis build (#178)
* Use stable12 branch for travis * Shorten db indices to max 27 characters to satisfy app:check-code * Use precise container, downgrade to psql 9.4 * Create psql role * Fix ContentController test * Fix PageController and StatusService tests * Use OCP\IDBConnection, OCP\IDb was removed * Extend IntegrationTest from \Test\Testcase, use loginAsUser to login * Require phpunit 5, nextcloud tests not compatible with phpunit 6 Change tests to use phpunit from vendor directory
This commit is contained in:
parent
f18aef805e
commit
b7f20c0f36
15
.travis.yml
15
.travis.yml
|
@ -1,4 +1,5 @@
|
|||
sudo: false
|
||||
dist: precise
|
||||
language: php
|
||||
php:
|
||||
- 5.6
|
||||
|
@ -7,7 +8,7 @@ php:
|
|||
|
||||
env:
|
||||
global:
|
||||
- CORE_BRANCH=stable11
|
||||
- CORE_BRANCH=stable12
|
||||
matrix:
|
||||
- DB=pgsql
|
||||
|
||||
|
@ -37,14 +38,15 @@ before_install:
|
|||
- mv news nextcloud/apps/
|
||||
|
||||
before_script:
|
||||
- if [[ "$DB" == 'pgsql' ]]; then psql -c 'create database oc_autotest;' -U postgres; fi
|
||||
- if [[ "$DB" == 'pgsql' ]]; then psql -c "CREATE ROLE oc_autotest LOGIN PASSWORD 'oc_autotest'" -U postgres; fi
|
||||
- if [[ "$DB" == 'pgsql' ]]; then psql -c "CREATE DATABASE oc_autotest OWNER oc_autotest;" -U postgres; fi
|
||||
- if [[ "$DB" == 'mysql' ]]; then mysql -u root -e 'CREATE DATABASE oc_autotest;'; fi
|
||||
- if [[ "$DB" == 'mysql' ]]; then mysql -u root -e "CREATE USER 'oc_autotest'@'localhost' IDENTIFIED BY '';"; fi
|
||||
- if [[ "$DB" == 'mysql' ]]; then mysql -u root -e "CREATE USER 'oc_autotest'@'localhost' IDENTIFIED BY 'oc_autotest';"; fi
|
||||
- if [[ "$DB" == 'mysql' ]]; then mysql -u root -e "GRANT ALL ON oc_autotest.* TO 'oc_autotest'@'localhost';"; fi
|
||||
# fill nextcloud with default configs and enable news
|
||||
- cd nextcloud
|
||||
- mkdir data
|
||||
- ./occ maintenance:install --database-name oc_autotest --database-user oc_autotest --admin-user admin --admin-pass admin --database $DB --database-pass=''
|
||||
- ./occ maintenance:install --database-name oc_autotest --database-user oc_autotest --admin-user admin --admin-pass admin --database $DB --database-pass="oc_autotest"
|
||||
- ./occ app:enable news
|
||||
- ./occ app:check-code news
|
||||
- ./occ background:cron # enable default cron
|
||||
|
@ -59,8 +61,7 @@ after_failure:
|
|||
|
||||
addons:
|
||||
firefox: "latest"
|
||||
postgresql: "9.5"
|
||||
postgresql: "9.4"
|
||||
|
||||
services:
|
||||
- mysql
|
||||
- postgresql
|
||||
- mysql
|
13
Makefile
13
Makefile
|
@ -178,13 +178,6 @@ endif
|
|||
.PHONY: test
|
||||
test:
|
||||
cd js && $(npm) run test
|
||||
ifeq (, $(shell which phpunit 2> /dev/null))
|
||||
@echo "No phpunit command available, downloading a copy from the web"
|
||||
mkdir -p $(build_tools_directory)
|
||||
curl -sSL https://phar.phpunit.de/phpunit.phar -o $(build_tools_directory)/phpunit.phar
|
||||
php $(build_tools_directory)/phpunit.phar -c phpunit.xml --coverage-clover build/php-unit.clover
|
||||
php $(build_tools_directory)/phpunit.phar -c phpunit.integration.xml --coverage-clover build/php-integration.clover
|
||||
else
|
||||
phpunit -c phpunit.xml --coverage-clover build/php-unit.clover
|
||||
phpunit -c phpunit.integration.xml --coverage-clover build/php-unit.clover
|
||||
endif
|
||||
./vendor/phpunit/phpunit/phpunit -c phpunit.xml --coverage-clover build/php-unit.clover
|
||||
# \Test\TestCase is only allowed to access the db if TRAVIS environment variable is set
|
||||
env TRAVIS=1 ./vendor/phpunit/phpunit/phpunit -c phpunit.integration.xml --coverage-clover build/php-unit.clover
|
||||
|
|
|
@ -58,21 +58,21 @@
|
|||
</field>
|
||||
|
||||
<index>
|
||||
<name>news_folders_last_modified_index</name>
|
||||
<name>news_folders_last_mod_idx</name>
|
||||
<field>
|
||||
<name>last_modified</name>
|
||||
</field>
|
||||
</index>
|
||||
|
||||
<index>
|
||||
<name>news_folders_parent_id_index</name>
|
||||
<name>news_folders_parent_id_idx</name>
|
||||
<field>
|
||||
<name>parent_id</name>
|
||||
</field>
|
||||
</index>
|
||||
|
||||
<index>
|
||||
<name>news_folders_user_id_index</name>
|
||||
<name>news_folders_user_id_idx</name>
|
||||
<field>
|
||||
<name>user_id</name>
|
||||
</field>
|
||||
|
@ -234,7 +234,7 @@
|
|||
</field>
|
||||
|
||||
<index>
|
||||
<name>news_feeds_last_modified_index</name>
|
||||
<name>news_feeds_last_mod_idx</name>
|
||||
<field>
|
||||
<name>last_modified</name>
|
||||
</field>
|
||||
|
@ -373,7 +373,7 @@
|
|||
</field>
|
||||
|
||||
<index>
|
||||
<name>news_items_last_modified_index</name>
|
||||
<name>news_items_last_mod_idx</name>
|
||||
<field>
|
||||
<name>last_modified</name>
|
||||
</field>
|
||||
|
@ -387,7 +387,7 @@
|
|||
</index>
|
||||
|
||||
<index>
|
||||
<name>news_items_fingerprint_index</name>
|
||||
<name>news_items_fingerprint_idx</name>
|
||||
<field>
|
||||
<name>fingerprint</name>
|
||||
</field>
|
||||
|
|
|
@ -33,5 +33,8 @@
|
|||
"fguillot/picofeed": "0.1.33",
|
||||
"pear/net_url2": "2.2.1",
|
||||
"riimu/kit-pathjoin": "1.1.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^5.4"
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -402,13 +402,15 @@ describe('ContentController', function () {
|
|||
}));
|
||||
|
||||
|
||||
it ('should toggle active item', function ($controller) {
|
||||
var ctrl = $controller('ContentController');
|
||||
expect(ctrl.isItemActive(3)).toBe(undefined);
|
||||
it ('should toggle active item', inject(function ($controller) {
|
||||
var ctrl = $controller('ContentController', {
|
||||
data: {'items': [{id: 3}, {id: 4}]}
|
||||
});
|
||||
expect(ctrl.isItemActive(3)).toBe(false);
|
||||
ctrl.setItemActive(3);
|
||||
expect(ctrl.isItemActive(4)).toBe(false);
|
||||
expect(ctrl.isItemActive(3)).toBe(true);
|
||||
});
|
||||
}));
|
||||
|
||||
it('should autopage if more than 0 elements',
|
||||
inject(function ($controller, ItemResource, Publisher) {
|
||||
|
|
|
@ -19,7 +19,7 @@ use OCA\News\Db\Item;
|
|||
use OCP\AppFramework\Db\Entity;
|
||||
use OCP\AppFramework\IAppContainer;
|
||||
|
||||
use OCP\IDb;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\IUserSession;
|
||||
use OCP\IUserManager;
|
||||
|
||||
|
@ -32,7 +32,7 @@ use OCA\News\Db\ItemMapper;
|
|||
use OCA\News\Db\FolderMapper;
|
||||
|
||||
|
||||
abstract class IntegrationTest extends PHPUnit_Framework_TestCase {
|
||||
abstract class IntegrationTest extends \Test\TestCase {
|
||||
|
||||
protected $user = 'test';
|
||||
protected $userPassword = 'test';
|
||||
|
@ -162,8 +162,7 @@ abstract class IntegrationTest extends PHPUnit_Framework_TestCase {
|
|||
$userManager = $this->container->query(IUserManager::class);
|
||||
$userManager->createUser($user, $password);
|
||||
|
||||
$session = $this->container->query(IUserSession::class);
|
||||
$session->login($user, $password);
|
||||
$this->loginAsUser($user);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -192,9 +191,9 @@ abstract class IntegrationTest extends PHPUnit_Framework_TestCase {
|
|||
'DELETE FROM `*PREFIX*news_folders` WHERE `user_id` = ?'
|
||||
];
|
||||
|
||||
$db = $this->container->query(IDb::class);
|
||||
$db = $this->container->query(IDBConnection::class);
|
||||
foreach ($sql as $query) {
|
||||
$db->prepareQuery($query)->execute([$user]);
|
||||
$db->prepare($query)->execute([$user]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -80,8 +80,8 @@ class PageControllerTest extends \PHPUnit_Framework_TestCase {
|
|||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$this->controller = new PageController($this->appName, $this->request,
|
||||
$this->settings, $this->urlGenerator, $this->appConfig,
|
||||
$this->config, $this->l10n, $this->recommended, $this->status,
|
||||
$this->settings, $this->urlGenerator, $this->config,
|
||||
$this->l10n, $this->recommended, $this->status,
|
||||
$this->user);
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,7 @@ class PageControllerTest extends \PHPUnit_Framework_TestCase {
|
|||
|
||||
$response = $this->controller->index();
|
||||
$this->assertEquals('index', $response->getTemplateName());
|
||||
$this->assertSame(false, $response->getParams()['cronWarning']);
|
||||
$this->assertSame(false, $response->getParams()['warnings']['improperlyConfiguredCron']);
|
||||
}
|
||||
|
||||
|
||||
|
@ -112,7 +112,7 @@ class PageControllerTest extends \PHPUnit_Framework_TestCase {
|
|||
|
||||
|
||||
$response = $this->controller->index();
|
||||
$this->assertEquals(true, $response->getParams()['cronWarning']);
|
||||
$this->assertEquals(true, $response->getParams()['warnings']['improperlyConfiguredCron']);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -33,8 +33,11 @@ class StatusServiceTest extends \PHPUnit_Framework_TestCase {
|
|||
'\OCA\News\Config\Config')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$this->service = new StatusService($this->settings, $this->config,
|
||||
$this->appName);
|
||||
$this->db = $this->getMockBuilder("\OCP\IDBConnection")
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$this->service = new StatusService($this->settings, $this->db,
|
||||
$this->config, $this->appName);
|
||||
}
|
||||
|
||||
private function beforeStatus($cronMode='cron', $cronEnabled=true,
|
||||
|
|
Loading…
Reference in New Issue