From 5e879c3489f5c1a866a232b359a313789fe29285 Mon Sep 17 00:00:00 2001 From: kiswa Date: Fri, 22 Apr 2016 12:56:16 +0000 Subject: [PATCH] Fixes for proper test runs --- .travis.yml | 3 +- CONTRIBUTING.md | 6 +- README.md | 8 ++ gulpfile.js | 14 ++- package.json | 1 + src/api/composer.json | 2 +- src/api/composer.lock | 261 ++++++---------------------------------- test/api/BoardsTest.php | 22 ++++ test/api/Mocks.php | 28 +++++ 9 files changed, 113 insertions(+), 232 deletions(-) create mode 100644 test/api/Mocks.php diff --git a/.travis.yml b/.travis.yml index ad4fa99..fe71a93 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,8 @@ language: php php: + - '5.4' - '5.5' - '5.6' - - '7.0' before_script: - nvm install 4 - nvm use 4 @@ -10,3 +10,4 @@ before_script: - npm i script: - gulp test + diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 16b1da6..502737a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,5 +1,7 @@ # Contributing - Fork the repository and make your changes on the `dev` branch. +Fork the repository and make your changes on the `dev` branch. - Create a pull request against the `dev` branch to merge your changes with the main repository. +Create a pull request against the `dev` branch to merge your changes with the main repository. + +Make sure to include/update unit tests. diff --git a/README.md b/README.md index 30cc80d..6dae357 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,12 @@ Developing on TaskBoard is pretty simple too. 2. Run `npm i` to install dependencies (Linting the SCSS requires Ruby and running `gem install scss-lint`) 3. Run `git checkout dev` to work on the `dev` branch +#### Unit Tests + +Both the API and App are unit tested. To run all tests, use the command `gulp test`. For only one set, run `gulp test-api` or `gulp test-app`. + +These tests are run by [Travis CI](https://travis-ci.org/) on PRs and commits. + ## Features ### Boards @@ -85,6 +91,8 @@ Fork the repository and make your changes on the `dev` branch. Create a pull request against the `dev` branch to merge your changes with the main repository. +Make sure to include/update unit tests. + ## Feedback Constructive feedback is appreciated! If you have ideas for improvement, please [add an issue](https://github.com/kiswa/TaskBoard/issues) or implement it and submit a pull request. diff --git a/gulpfile.js b/gulpfile.js index f4244ee..df3d0bf 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -4,28 +4,33 @@ let gulp = require('gulp'), fs = require('fs'), del = require('del'), merge = require('merge-stream'), - concat = require('gulp-concat'), + composer = require('gulp-composer'), tsc = require('gulp-typescript'), jsMinify = require('gulp-uglify'), + mocha = require('gulp-mocha'), coverage = require('gulp-coverage'), phpunit = require('gulp-phpunit'), + scsslint = require('gulp-scss-lint'), sass = require('gulp-sass'), + + concat = require('gulp-concat'), cssPrefixer = require('gulp-autoprefixer'), cssMinify = require('gulp-cssnano'), imageMin = require('gulp-imagemin'), - node, - spawn = require('child_process').spawn, + paths = { bourbon: 'node_modules/bourbon/app/assets/stylesheets', neat: 'node_modules/bourbon-neat/app/assets/stylesheets', scss_base: 'node_modules/scss-base/src', tsconfig: 'src/app/tsconfig.json', - ts: 'src/app/**/*.ts', + tests_app: 'test/app/**/*.spec.js', tests_api: 'test/api/**/*.php', + + ts: 'src/app/**/*.ts', html: [ 'src/**/*.html', 'src/.htaccess' @@ -178,3 +183,4 @@ gulp.task('watchtests', () => { gulp.task('default', ['tsc', 'vendor', 'html', 'images', 'lintScss', 'styles', 'api'], () => { fs.chmod('dist/api', '0777'); }); + diff --git a/package.json b/package.json index 2674f5f..8ce6aab 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,7 @@ "gulp-scss-lint": "^0.3.9", "gulp-typescript": "^2.13.0", "gulp-uglify": "^1.5.3", + "gulp-util": "^3.0.7", "merge-stream": "^1.0.0", "reflect-metadata": "0.1.2", "rxjs": "5.0.0-beta.2", diff --git a/src/api/composer.json b/src/api/composer.json index ab16732..c2490a3 100644 --- a/src/api/composer.json +++ b/src/api/composer.json @@ -5,7 +5,7 @@ "slim/slim": "^3.3", "firebase/php-jwt": "^3.0", "phpmailer/phpmailer": "^5.2", - "phpunit/phpunit": "^5.3" + "phpunit/phpunit": "^4.8" }, "license": "MIT", "authors": [ diff --git a/src/api/composer.lock b/src/api/composer.lock index 91e3e74..2083ea1 100644 --- a/src/api/composer.lock +++ b/src/api/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "c7682af481691a5492281d5cf6706e3b", - "content-hash": "6703786ad7bca9ee273a519aba42012a", + "hash": "4d525f15d96360344612eef937df04f3", + "content-hash": "5eb7b7c370a74b3a8c4c8976ff018a64", "packages": [ { "name": "container-interop/container-interop", @@ -250,48 +250,6 @@ ], "time": "2016-04-12 18:29:35" }, - { - "name": "myclabs/deep-copy", - "version": "1.5.0", - "source": { - "type": "git", - "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "e3abefcd7f106677fd352cd7c187d6c969aa9ddc" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/e3abefcd7f106677fd352cd7c187d6c969aa9ddc", - "reference": "e3abefcd7f106677fd352cd7c187d6c969aa9ddc", - "shasum": "" - }, - "require": { - "php": ">=5.4.0" - }, - "require-dev": { - "doctrine/collections": "1.*", - "phpunit/phpunit": "~4.1" - }, - "type": "library", - "autoload": { - "psr-4": { - "DeepCopy\\": "src/DeepCopy/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Create deep copies (clones) of your objects", - "homepage": "https://github.com/myclabs/DeepCopy", - "keywords": [ - "clone", - "copy", - "duplicate", - "object", - "object graph" - ], - "time": "2015-11-07 22:20:37" - }, { "name": "nikic/fast-route", "version": "v0.6.0", @@ -509,40 +467,39 @@ }, { "name": "phpunit/php-code-coverage", - "version": "3.3.1", + "version": "2.2.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "2431befdd451fac43fbcde94d1a92fb3b8b68f86" + "reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/2431befdd451fac43fbcde94d1a92fb3b8b68f86", - "reference": "2431befdd451fac43fbcde94d1a92fb3b8b68f86", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/eabf68b476ac7d0f73793aada060f1c1a9bf8979", + "reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979", "shasum": "" }, "require": { - "php": "^5.6 || ^7.0", + "php": ">=5.3.3", "phpunit/php-file-iterator": "~1.3", "phpunit/php-text-template": "~1.2", - "phpunit/php-token-stream": "^1.4.2", - "sebastian/code-unit-reverse-lookup": "~1.0", + "phpunit/php-token-stream": "~1.3", "sebastian/environment": "^1.3.2", - "sebastian/version": "~1.0|~2.0" + "sebastian/version": "~1.0" }, "require-dev": { "ext-xdebug": ">=2.1.4", - "phpunit/phpunit": "~5" + "phpunit/phpunit": "~4" }, "suggest": { "ext-dom": "*", - "ext-xdebug": ">=2.4.0", + "ext-xdebug": ">=2.2.1", "ext-xmlwriter": "*" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3.x-dev" + "dev-master": "2.2.x-dev" } }, "autoload": { @@ -568,7 +525,7 @@ "testing", "xunit" ], - "time": "2016-04-08 08:14:53" + "time": "2015-10-06 15:47:00" }, { "name": "phpunit/php-file-iterator", @@ -750,16 +707,16 @@ }, { "name": "phpunit/phpunit", - "version": "5.3.2", + "version": "4.8.24", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "2c6da3536035617bae3fe3db37283c9e0eb63ab3" + "reference": "a1066c562c52900a142a0e2bbf0582994671385e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/2c6da3536035617bae3fe3db37283c9e0eb63ab3", - "reference": "2c6da3536035617bae3fe3db37283c9e0eb63ab3", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a1066c562c52900a142a0e2bbf0582994671385e", + "reference": "a1066c562c52900a142a0e2bbf0582994671385e", "shasum": "" }, "require": { @@ -768,22 +725,19 @@ "ext-pcre": "*", "ext-reflection": "*", "ext-spl": "*", - "myclabs/deep-copy": "~1.3", - "php": "^5.6 || ^7.0", + "php": ">=5.3.3", "phpspec/prophecy": "^1.3.1", - "phpunit/php-code-coverage": "^3.3.0", + "phpunit/php-code-coverage": "~2.1", "phpunit/php-file-iterator": "~1.4", "phpunit/php-text-template": "~1.2", - "phpunit/php-timer": "^1.0.6", - "phpunit/phpunit-mock-objects": "^3.1", + "phpunit/php-timer": ">=1.0.6", + "phpunit/phpunit-mock-objects": "~2.3", "sebastian/comparator": "~1.1", "sebastian/diff": "~1.2", "sebastian/environment": "~1.3", "sebastian/exporter": "~1.2", "sebastian/global-state": "~1.0", - "sebastian/object-enumerator": "~1.0", - "sebastian/resource-operations": "~1.0", - "sebastian/version": "~1.0|~2.0", + "sebastian/version": "~1.0", "symfony/yaml": "~2.1|~3.0" }, "suggest": { @@ -795,7 +749,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "5.3.x-dev" + "dev-master": "4.8.x-dev" } }, "autoload": { @@ -821,30 +775,30 @@ "testing", "xunit" ], - "time": "2016-04-12 16:20:08" + "time": "2016-03-14 06:16:08" }, { "name": "phpunit/phpunit-mock-objects", - "version": "3.1.3", + "version": "2.3.8", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "151c96874bff6fe61a25039df60e776613a61489" + "reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/151c96874bff6fe61a25039df60e776613a61489", - "reference": "151c96874bff6fe61a25039df60e776613a61489", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/ac8e7a3db35738d56ee9a76e78a4e03d97628983", + "reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983", "shasum": "" }, "require": { "doctrine/instantiator": "^1.0.2", - "php": ">=5.6", + "php": ">=5.3.3", "phpunit/php-text-template": "~1.2", "sebastian/exporter": "~1.2" }, "require-dev": { - "phpunit/phpunit": "~5" + "phpunit/phpunit": "~4.4" }, "suggest": { "ext-soap": "*" @@ -852,7 +806,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.1.x-dev" + "dev-master": "2.3.x-dev" } }, "autoload": { @@ -877,7 +831,7 @@ "mock", "xunit" ], - "time": "2016-04-20 14:39:26" + "time": "2015-10-02 06:51:40" }, { "name": "pimple/pimple", @@ -1012,51 +966,6 @@ ], "time": "2012-12-21 11:40:51" }, - { - "name": "sebastian/code-unit-reverse-lookup", - "version": "1.0.0", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", - "reference": "c36f5e7cfce482fde5bf8d10d41a53591e0198fe" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/c36f5e7cfce482fde5bf8d10d41a53591e0198fe", - "reference": "c36f5e7cfce482fde5bf8d10d41a53591e0198fe", - "shasum": "" - }, - "require": { - "php": ">=5.6" - }, - "require-dev": { - "phpunit/phpunit": "~5" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Looks up which function or method a line of code belongs to", - "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", - "time": "2016-02-13 06:45:14" - }, { "name": "sebastian/comparator", "version": "1.2.0", @@ -1340,52 +1249,6 @@ ], "time": "2015-10-12 03:26:01" }, - { - "name": "sebastian/object-enumerator", - "version": "1.0.0", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/object-enumerator.git", - "reference": "d4ca2fb70344987502567bc50081c03e6192fb26" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/d4ca2fb70344987502567bc50081c03e6192fb26", - "reference": "d4ca2fb70344987502567bc50081c03e6192fb26", - "shasum": "" - }, - "require": { - "php": ">=5.6", - "sebastian/recursion-context": "~1.0" - }, - "require-dev": { - "phpunit/phpunit": "~5" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Traverses array structures and object graphs to enumerate all referenced objects", - "homepage": "https://github.com/sebastianbergmann/object-enumerator/", - "time": "2016-01-28 13:25:10" - }, { "name": "sebastian/recursion-context", "version": "1.0.2", @@ -1439,71 +1302,21 @@ "homepage": "http://www.github.com/sebastianbergmann/recursion-context", "time": "2015-11-11 19:50:13" }, - { - "name": "sebastian/resource-operations", - "version": "1.0.0", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/resource-operations.git", - "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", - "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", - "shasum": "" - }, - "require": { - "php": ">=5.6.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Provides a list of PHP built-in functions that operate on resources", - "homepage": "https://www.github.com/sebastianbergmann/resource-operations", - "time": "2015-07-28 20:34:47" - }, { "name": "sebastian/version", - "version": "2.0.0", + "version": "1.0.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/version.git", - "reference": "c829badbd8fdf16a0bad8aa7fa7971c029f1b9c5" + "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/c829badbd8fdf16a0bad8aa7fa7971c029f1b9c5", - "reference": "c829badbd8fdf16a0bad8aa7fa7971c029f1b9c5", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", + "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", "shasum": "" }, - "require": { - "php": ">=5.6" - }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, "autoload": { "classmap": [ "src/" @@ -1522,7 +1335,7 @@ ], "description": "Library that helps with managing the version number of Git-hosted PHP projects", "homepage": "https://github.com/sebastianbergmann/version", - "time": "2016-02-04 12:56:52" + "time": "2015-06-21 13:59:46" }, { "name": "slim/slim", diff --git a/test/api/BoardsTest.php b/test/api/BoardsTest.php index 5e477b5..74f4bc1 100644 --- a/test/api/BoardsTest.php +++ b/test/api/BoardsTest.php @@ -1,3 +1,25 @@ addAlert('info', 'No boards in database.'); + + $this->assertEquals($expected, + $boards->getAllBoards(null, new ResponseMock(), null)); + } + } + diff --git a/test/api/Mocks.php b/test/api/Mocks.php new file mode 100644 index 0000000..35be358 --- /dev/null +++ b/test/api/Mocks.php @@ -0,0 +1,28 @@ +