Fixes for proper test runs

This commit is contained in:
kiswa 2016-04-22 12:56:16 +00:00
parent 69a891eb6e
commit 5e879c3489
9 changed files with 113 additions and 232 deletions

View File

@ -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

View File

@ -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.

View File

@ -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.

View File

@ -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');
});

View File

@ -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",

View File

@ -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": [

261
src/api/composer.lock generated
View File

@ -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",

View File

@ -1,3 +1,25 @@
<?php
require 'Mocks.php';
class BoardsTest extends PHPUnit_Framework_TestCase {
public static function setupBeforeClass() {
RedBeanPHP\R::setup('sqlite:tests.db');
}
public static function tearDownAfterClass() {
unlink('tests.db');
}
public function testGetAllBoards() {
$boards = new Boards(new ControllerMock());
$expected = new ApiJson();
$expected->addAlert('info', 'No boards in database.');
$this->assertEquals($expected,
$boards->getAllBoards(null, new ResponseMock(), null));
}
}

28
test/api/Mocks.php Normal file
View File

@ -0,0 +1,28 @@
<?php
class LoggerMock {
public function addInfo() {
}
public function addError() {
}
}
class ControllerMock {
public function get() {
return new LoggerMock();
}
}
class ResponseMock {
public function withJson($apiJson) {
return $apiJson;
}
}