From c9f46e2e3caa20d597315cd2fa85b0cce15c4c3b Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Thu, 6 Nov 2014 10:17:47 +0100 Subject: run integration tests on travis --- .travis.yml | 24 +++++++++--------- js/Gruntfile.js | 43 ++++++++++++++++++++++----------- tests/integration/bootstrap.php | 13 +++++++--- tests/integration/db/ItemMapperTest.php | 2 +- 4 files changed, 51 insertions(+), 31 deletions(-) diff --git a/.travis.yml b/.travis.yml index a5dfa597b..e5b14ea3d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -47,22 +47,22 @@ before_script: - cd owncloud - ocdev ci $DB - php -f console.php app:enable news - - cd apps/news + - cd apps/news/js + # install test deps + - npm install --deps # npm install needs to run before sudo npm install because otherwise it fails because a tmp file exists in the home dir + - sudo npm -g install grunt-cli protractor + - wget https://scrutinizer-ci.com/ocular.phar script: - # php unit tests - - phpunit --coverage-clover=coverage.clover -c phpunit.xml - - wget https://scrutinizer-ci.com/ocular.phar + # unit tests + - grunt php-unit - php ocular.phar code-coverage:upload --format=php-clover coverage.clover - - cd js/ - # install javascript deps (putting it into install section fails often) - - npm install --deps # npm install needs to run before sudo npm install because otherwise it fails because a tmp file exists in the home dir - - sudo npm -g install grunt-cli protractor - # js unit tests - - grunt ci-unit + - grunt js-unit + # integration tests + - grunt php-integration # acceptance tests - #- webdriver-manager update - #- grunt ci-e2e --verbose + - webdriver-manager update + #- grunt acceptance --verbose # debug section to check what went wrong - sudo apt-get install curl - curl http://admin:admin@localhost/owncloud/index.php diff --git a/js/Gruntfile.js b/js/Gruntfile.js index 133cf0303..e7d7398cc 100644 --- a/js/Gruntfile.js +++ b/js/Gruntfile.js @@ -152,7 +152,7 @@ module.exports = function (grunt) { files: [ '../**/*.php' ], - tasks: ['phpunit'] + tasks: ['phpunit:unit'] } }, karma: { @@ -167,13 +167,25 @@ module.exports = function (grunt) { } }, phpunit: { - classes: { - dir: '../tests' + unit: { + options: { + colors: true, + configuration: '../phpunit.xml' + } + }, + coverageUnit: { + options: { + colors: true, + configuration: '../phpunit.xml', + coverageClover: '../coverage.clover' + } + }, + integration: { + options: { + colors: true, + configuration: '../phpunit.integration.xml' + } }, - options: { - colors: true, - configuration: '../phpunit.xml' - } }, /* jshint camelcase: false */ protractor_webdriver: { @@ -211,11 +223,14 @@ module.exports = function (grunt) { grunt.registerTask('default', ['jshint', 'concat', 'wrap', 'ngAnnotate', 'uglify', 'cssmin']); grunt.registerTask('dev', ['watch:concat']); - grunt.registerTask('unit-js', ['karma:unit']); - grunt.registerTask('unit-php', ['watch:phpunit']); - grunt.registerTask('e2e', ['protractor_webdriver', 'connect', - 'protractor']); - grunt.registerTask('ci-unit', ['default', 'karma:continuous']); - grunt.registerTask('ci-e2e', ['protractor_webdriver', 'connect', - 'protractor']); + grunt.registerTask('dev-js-unit', ['karma:unit']); + grunt.registerTask('dev-php-unit', ['watch:phpunit']); + + grunt.registerTask('js-unit', ['default', 'karma:continuous']); + grunt.registerTask('php-unit', ['phpunit:coverageUnit']); + grunt.registerTask('php-integration', ['phpunit:integration']); + + grunt.registerTask('acceptance', ['protractor_webdriver', 'connect', + 'protractor']); + }; \ No newline at end of file diff --git a/tests/integration/bootstrap.php b/tests/integration/bootstrap.php index b9bbe6179..0f010b8f4 100644 --- a/tests/integration/bootstrap.php +++ b/tests/integration/bootstrap.php @@ -9,7 +9,7 @@ class NewsIntegrationTest extends \PHPUnit_Framework_TestCase { protected $userId = 'test'; protected $userPassword = 'test'; - protected function setupNewsDatabase($user='test') { + protected function clearNewsDatabase($user='test') { $sql = [ 'DELETE FROM *PREFIX*news_items WHERE feed_id IN ' . '(SELECT id FROM *PREFIX*news_feeds WHERE user_id = ?)', @@ -29,6 +29,7 @@ class NewsIntegrationTest extends \PHPUnit_Framework_TestCase { if ($userManager->userExists($user)) { $userManager->get($user)->delete(); + $userManager->delete($user); } $userManager->createUser($user, $password); @@ -38,9 +39,13 @@ class NewsIntegrationTest extends \PHPUnit_Framework_TestCase { } - protected function setUpOwnCloud($user='test', $password='test') { - $this->setupUser($user, $password); - $this->setupNewsDatabase($user); + protected function setUp() { + $this->setupUser($this->userId, $this->userPassword); + } + + + protected function tearDown() { + $this->clearNewsDatabase($this->userId); } diff --git a/tests/integration/db/ItemMapperTest.php b/tests/integration/db/ItemMapperTest.php index 23a9fca49..61ea33e47 100644 --- a/tests/integration/db/ItemMapperTest.php +++ b/tests/integration/db/ItemMapperTest.php @@ -11,7 +11,7 @@ class ItemMapperTest extends NewsIntegrationTest { private $itemMapper; protected function setUp() { - parent::setUpOwnCloud(); + parent::setUp(); $app = new Application(); $this->container = $app->getContainer(); $this->itemMapper = $this->container->query('ItemMapper'); -- cgit v1.2.3