Added all the old test things.

This commit is contained in:
James Cole 2015-02-07 08:42:20 +01:00
parent fb1c78c657
commit 2dc67d1674
45 changed files with 4254 additions and 13 deletions

2
.gitignore vendored
View File

@ -25,3 +25,5 @@ tests/_data/dump.sql
db.sqlite_snapshot
c3.php
db.sqlite-journal
tests/_output/*

View File

@ -9,14 +9,10 @@ settings:
colors: true
memory_limit: 1024M
modules:
config:
config:
coverage:
enabled: true
remote: false
whitelist:
include:
- app/controllers/*
- app/models/*
- app/lib/FireflyIII/*
exclude:
- app/controllers/BaseController.php
enabled: true
remote: false
whitelist:
include:
- app/*

View File

@ -33,7 +33,9 @@
"require-dev": {
"barryvdh/laravel-debugbar": "@stable",
"phpunit/phpunit": "~4.0",
"phpspec/phpspec": "~2.1"
"phpspec/phpspec": "~2.1",
"codeception/codeception": "@stable",
"codeception/c3": "@stable"
},
"autoload": {

532
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "071f987787047647b1082d7b077b943f",
"hash": "27043b82bc8681d1094337483ff561a7",
"packages": [
{
"name": "barryvdh/laravel-ide-helper",
@ -2589,6 +2589,130 @@
],
"time": "2015-02-03 19:52:06"
},
{
"name": "codeception/c3",
"version": "2.0.3",
"source": {
"type": "git",
"url": "https://github.com/Codeception/c3.git",
"reference": "30321efb2421c5d201d02e2cb8da1a1ca96e4a38"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Codeception/c3/zipball/30321efb2421c5d201d02e2cb8da1a1ca96e4a38",
"reference": "30321efb2421c5d201d02e2cb8da1a1ca96e4a38",
"shasum": ""
},
"require": {
"php": ">=5.4.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Codeception\\c3\\": "."
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Michael Bodnarchuk",
"email": "davert.php@resend.cc",
"homepage": "http://codegyre.com"
}
],
"description": "CodeCoverage collector for Codeception",
"homepage": "http://codeception.com/",
"keywords": [
"code coverage",
"codecoverage"
],
"time": "2014-11-18 22:06:45"
},
{
"name": "codeception/codeception",
"version": "2.0.9",
"source": {
"type": "git",
"url": "https://github.com/Codeception/Codeception.git",
"reference": "0094191ac0d6e87821fba41de002103ebe79a279"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Codeception/Codeception/zipball/0094191ac0d6e87821fba41de002103ebe79a279",
"reference": "0094191ac0d6e87821fba41de002103ebe79a279",
"shasum": ""
},
"require": {
"ext-json": "*",
"ext-mbstring": "*",
"facebook/webdriver": "~0.4",
"guzzlehttp/guzzle": "~4.0|~5.0",
"php": ">=5.4.0",
"phpunit/phpunit": "~4.0",
"symfony/browser-kit": "~2.4",
"symfony/console": "~2.4",
"symfony/css-selector": "~2.4",
"symfony/dom-crawler": "~2.4,!=2.4.5",
"symfony/event-dispatcher": "~2.4",
"symfony/finder": "~2.4",
"symfony/yaml": "~2.4"
},
"require-dev": {
"codeception/specify": "~0.3",
"codegyre/robo-ci": "@dev",
"facebook/php-sdk": "~3.2",
"flow/jsonpath": "~0.1",
"monolog/monolog": "~1.8",
"pda/pheanstalk": "~2.0",
"phpseclib/phpseclib": "~0.3.6",
"videlalvaro/php-amqplib": "~2.4"
},
"suggest": {
"codeception/phpbuiltinserver": "Extension to start and stop PHP built-in web server for your tests",
"codeception/specify": "BDD-style code blocks",
"codeception/verify": "BDD-style assertions",
"monolog/monolog": "Log test steps",
"phpseclib/phpseclib": "Extension required to use the SFTP option in the FTP Module."
},
"bin": [
"codecept"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.1-dev"
}
},
"autoload": {
"psr-0": {
"Codeception": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Michael Bodnarchuk",
"email": "davert@mail.ua",
"homepage": "http://codegyre.com"
}
],
"description": "BDD-style testing framework",
"homepage": "http://codeception.com/",
"keywords": [
"BDD",
"TDD",
"acceptance testing",
"functional testing",
"unit testing"
],
"time": "2014-12-19 23:54:20"
},
{
"name": "doctrine/instantiator",
"version": "1.0.4",
@ -2643,6 +2767,205 @@
],
"time": "2014-10-13 12:58:55"
},
{
"name": "facebook/webdriver",
"version": "v0.5.1",
"source": {
"type": "git",
"url": "https://github.com/facebook/php-webdriver.git",
"reference": "bbcb697efb394d17bd9ec3d467e7da847cde4509"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/facebook/php-webdriver/zipball/bbcb697efb394d17bd9ec3d467e7da847cde4509",
"reference": "bbcb697efb394d17bd9ec3d467e7da847cde4509",
"shasum": ""
},
"require": {
"php": ">=5.3.19"
},
"require-dev": {
"phpdocumentor/phpdocumentor": "2.*",
"phpunit/phpunit": "3.7.*"
},
"type": "library",
"autoload": {
"classmap": [
"lib/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"Apache-2.0"
],
"description": "A php client for WebDriver",
"homepage": "https://github.com/facebook/php-webdriver",
"keywords": [
"facebook",
"php",
"selenium",
"webdriver"
],
"time": "2014-11-05 20:53:09"
},
{
"name": "guzzlehttp/guzzle",
"version": "5.2.0",
"source": {
"type": "git",
"url": "https://github.com/guzzle/guzzle.git",
"reference": "475b29ccd411f2fa8a408e64576418728c032cfa"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/475b29ccd411f2fa8a408e64576418728c032cfa",
"reference": "475b29ccd411f2fa8a408e64576418728c032cfa",
"shasum": ""
},
"require": {
"guzzlehttp/ringphp": "~1.0",
"php": ">=5.4.0"
},
"require-dev": {
"ext-curl": "*",
"phpunit/phpunit": "~4.0",
"psr/log": "~1.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "5.0-dev"
}
},
"autoload": {
"psr-4": {
"GuzzleHttp\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
}
],
"description": "Guzzle is a PHP HTTP client library and framework for building RESTful web service clients",
"homepage": "http://guzzlephp.org/",
"keywords": [
"client",
"curl",
"framework",
"http",
"http client",
"rest",
"web service"
],
"time": "2015-01-28 01:03:29"
},
{
"name": "guzzlehttp/ringphp",
"version": "1.0.5",
"source": {
"type": "git",
"url": "https://github.com/guzzle/RingPHP.git",
"reference": "a903f51b692427318bc813217c0e6505287e79a4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/RingPHP/zipball/a903f51b692427318bc813217c0e6505287e79a4",
"reference": "a903f51b692427318bc813217c0e6505287e79a4",
"shasum": ""
},
"require": {
"guzzlehttp/streams": "~3.0",
"php": ">=5.4.0",
"react/promise": "~2.0"
},
"require-dev": {
"ext-curl": "*",
"phpunit/phpunit": "~4.0"
},
"suggest": {
"ext-curl": "Guzzle will use specific adapters if cURL is present"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"autoload": {
"psr-4": {
"GuzzleHttp\\Ring\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
}
],
"time": "2014-12-11 05:50:32"
},
{
"name": "guzzlehttp/streams",
"version": "3.0.0",
"source": {
"type": "git",
"url": "https://github.com/guzzle/streams.git",
"reference": "47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/streams/zipball/47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5",
"reference": "47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5",
"shasum": ""
},
"require": {
"php": ">=5.4.0"
},
"require-dev": {
"phpunit/phpunit": "~4.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0-dev"
}
},
"autoload": {
"psr-4": {
"GuzzleHttp\\Stream\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
}
],
"description": "Provides a simple abstraction over streams of data",
"homepage": "http://guzzlephp.org/",
"keywords": [
"Guzzle",
"stream"
],
"time": "2014-10-12 19:18:40"
},
{
"name": "maximebf/debugbar",
"version": "v1.10.4",
@ -3239,6 +3562,50 @@
],
"time": "2014-10-03 05:12:11"
},
{
"name": "react/promise",
"version": "v2.2.0",
"source": {
"type": "git",
"url": "https://github.com/reactphp/promise.git",
"reference": "365fcee430dfa4ace1fbc75737ca60ceea7eeeef"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/reactphp/promise/zipball/365fcee430dfa4ace1fbc75737ca60ceea7eeeef",
"reference": "365fcee430dfa4ace1fbc75737ca60ceea7eeeef",
"shasum": ""
},
"require": {
"php": ">=5.4.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0-dev"
}
},
"autoload": {
"psr-4": {
"React\\Promise\\": "src/"
},
"files": [
"src/functions_include.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jan Sorgalla",
"email": "jsorgalla@googlemail.com"
}
],
"description": "A lightweight implementation of CommonJS Promises/A for PHP",
"time": "2014-12-30 13:32:42"
},
{
"name": "sebastian/comparator",
"version": "1.1.1",
@ -3610,6 +3977,165 @@
"homepage": "https://github.com/sebastianbergmann/version",
"time": "2014-12-15 14:25:24"
},
{
"name": "symfony/browser-kit",
"version": "v2.6.4",
"target-dir": "Symfony/Component/BrowserKit",
"source": {
"type": "git",
"url": "https://github.com/symfony/BrowserKit.git",
"reference": "2ecec44ed5047020c65dd6e4a4b2f3cf13ae3c04"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/BrowserKit/zipball/2ecec44ed5047020c65dd6e4a4b2f3cf13ae3c04",
"reference": "2ecec44ed5047020c65dd6e4a4b2f3cf13ae3c04",
"shasum": ""
},
"require": {
"php": ">=5.3.3",
"symfony/dom-crawler": "~2.0,>=2.0.5"
},
"require-dev": {
"symfony/css-selector": "~2.0,>=2.0.5",
"symfony/process": "~2.0,>=2.0.5"
},
"suggest": {
"symfony/process": ""
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.6-dev"
}
},
"autoload": {
"psr-0": {
"Symfony\\Component\\BrowserKit\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Symfony Community",
"homepage": "http://symfony.com/contributors"
},
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
}
],
"description": "Symfony BrowserKit Component",
"homepage": "http://symfony.com",
"time": "2015-01-03 08:01:59"
},
{
"name": "symfony/css-selector",
"version": "v2.6.4",
"target-dir": "Symfony/Component/CssSelector",
"source": {
"type": "git",
"url": "https://github.com/symfony/CssSelector.git",
"reference": "3f80ecc614fec68d5b4a84a0703db3fdf5ce8584"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/CssSelector/zipball/3f80ecc614fec68d5b4a84a0703db3fdf5ce8584",
"reference": "3f80ecc614fec68d5b4a84a0703db3fdf5ce8584",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.6-dev"
}
},
"autoload": {
"psr-0": {
"Symfony\\Component\\CssSelector\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Symfony Community",
"homepage": "http://symfony.com/contributors"
},
{
"name": "Jean-François Simon",
"email": "jeanfrancois.simon@sensiolabs.com"
},
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
}
],
"description": "Symfony CssSelector Component",
"homepage": "http://symfony.com",
"time": "2015-01-03 08:01:59"
},
{
"name": "symfony/dom-crawler",
"version": "v2.6.4",
"target-dir": "Symfony/Component/DomCrawler",
"source": {
"type": "git",
"url": "https://github.com/symfony/DomCrawler.git",
"reference": "26a9eb302decd828990e1015afaa11b78b016073"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/DomCrawler/zipball/26a9eb302decd828990e1015afaa11b78b016073",
"reference": "26a9eb302decd828990e1015afaa11b78b016073",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"require-dev": {
"symfony/css-selector": "~2.3"
},
"suggest": {
"symfony/css-selector": ""
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.6-dev"
}
},
"autoload": {
"psr-0": {
"Symfony\\Component\\DomCrawler\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Symfony Community",
"homepage": "http://symfony.com/contributors"
},
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
}
],
"description": "Symfony DomCrawler Component",
"homepage": "http://symfony.com",
"time": "2015-01-03 08:01:59"
},
{
"name": "symfony/yaml",
"version": "v2.6.4",
@ -3665,7 +4191,9 @@
"grumpydictator/gchart": 20,
"michelf/php-markdown": 0,
"watson/validating": 20,
"barryvdh/laravel-debugbar": 0
"barryvdh/laravel-debugbar": 0,
"codeception/codeception": 0,
"codeception/c3": 0
},
"prefer-stable": false,
"prefer-lowest": false,

9
tests/_bootstrap.php Normal file
View File

@ -0,0 +1,9 @@
<?php
$db = realpath(__DIR__ . '/_data') . '/db.sqlite';
$dump = realpath(__DIR__ . '/_data') . '/dump.sql';
if (!file_exists($db)) {
$out = [];
exec('touch ' . $db);
exec('php artisan migrate --seed --env=testing', $out);
exec('sqlite3 tests/_data/db.sqlite .dump > tests/_data/dump.sql', $out);
}

5
tests/_data/db.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/bash
touch tests/_data/db.sqlite
php artisan migrate --seed --env=testing
sqlite3 tests/_data/db.sqlite .dump > tests/_data/dump.sql
exit 0

View File

@ -0,0 +1,10 @@
<?php
namespace Codeception\Module;
// here you can define custom actions
// all public methods declared in helper class will be available in $I
class AcceptanceHelper extends \Codeception\Module
{
}

View File

@ -0,0 +1,10 @@
<?php
namespace Codeception\Module;
// here you can define custom actions
// all public methods declared in helper class will be available in $I
class FunctionalHelper extends \Codeception\Module
{
}

View File

@ -0,0 +1,10 @@
<?php
namespace Codeception\Module;
// here you can define custom actions
// all public methods declared in helper class will be available in $I
class UnitHelper extends \Codeception\Module
{
}

View File

@ -0,0 +1,14 @@
# Codeception Test Suite Configuration
# suite for acceptance tests.
# perform tests in browser using the WebDriver or PhpBrowser.
# If you need both WebDriver and PHPBrowser tests - create a separate suite.
class_name: AcceptanceTester
modules:
enabled:
- PhpBrowser
- AcceptanceHelper
config:
PhpBrowser:
url: 'http://localhost/myapp/'

View File

@ -0,0 +1,2 @@
<?php
// Here you can initialize variables that will be available to your tests

View File

@ -0,0 +1,9 @@
# Codeception Test Suite Configuration
# suite for functional (integration) tests.
# emulate web requests and make application process them.
# Include one of framework modules (Symfony2, Yii2, Laravel4) to use it.
class_name: FunctionalTester
modules:
enabled: [Filesystem, FunctionalHelper]

View File

@ -0,0 +1,215 @@
<?php
/**
* @SuppressWarnings("CamelCase")
* @SuppressWarnings("short")
*
* Class AccountControllerCest
*/
class AccountControllerCest
{
/**
* @param FunctionalTester $I
*/
public function _after(FunctionalTester $I)
{
}
/**
* @param FunctionalTester $I
*/
public function _before(FunctionalTester $I)
{
$I->amLoggedAs(['email' => 'thegrumpydictator@gmail.com', 'password' => 'james']);
}
/**
* @param FunctionalTester $I
*/
public function create(FunctionalTester $I)
{
// @codingStandardsIgnoreStart
$I->wantTo('create a new asset account');
$I->amOnPage('/accounts/create/asset');
$I->see('Create a new asset account');
}
/**
* @param FunctionalTester $I
*/
public function delete(FunctionalTester $I)
{
$I->wantTo('delete an asset account');
$I->amOnPage('/accounts/delete/3');
$I->see('Delete account "Delete me"');
}
/**
* @param FunctionalTester $I
*/
public function destroy(FunctionalTester $I)
{
$I->wantTo('destroy an asset account');
$I->amOnPage('/accounts/delete/3');
$I->see('Delete account "Delete me"');
$I->submitForm('#destroy', []);
$I->dontSeeRecord('accounts', ['id' => 3, 'deleted_at' => null]);
}
/**
* @param FunctionalTester $I
*/
public function edit(FunctionalTester $I)
{
$I->wantTo('edit an asset account');
$I->amOnPage('/accounts/edit/3');
$I->see('Edit asset account "Delete me"');
}
/**
* @param FunctionalTester $I
*/
public function failUpdate(FunctionalTester $I)
{
$I->wantTo('update an asset account and fail');
$I->amOnPage('/accounts/edit/3');
$I->see('Edit asset account "Delete me"');
$I->submitForm('#update', ['name' => '', 'what' => 'asset', 'account_role' => 'defaultExpense', 'post_submit_action' => 'update']);
$I->seeRecord('accounts', ['name' => 'Delete me']);
}
/**
* @param FunctionalTester $I
*/
public function index(FunctionalTester $I)
{
$I->wantTo('see a list of accounts');
$I->amOnPage('/accounts/asset');
$I->see('Checking account');
$I->see('Delete me');
}
/**
* @param FunctionalTester $I
*/
public function show(FunctionalTester $I)
{
$I->wantTo('see one account');
$I->amOnPage('/accounts/show/3');
$I->see('Details for');
$I->see('Delete me');
}
/**
* @param FunctionalTester $I
*/
public function store(FunctionalTester $I)
{
$I->amOnPage('/accounts/create/asset');
$I->wantTo('store a new asset account');
$I->see('Create a new asset account');
$I->submitForm('#store', ['name' => 'New through tests.', 'what' => 'asset', 'account_role' => 'defaultExpense', 'post_submit_action' => 'store']);
$I->seeRecord('accounts', ['name' => 'New through tests.']);
}
/**
* @param FunctionalTester $I
*/
public function storeOpeningBalance(FunctionalTester $I)
{
$I->amOnPage('/accounts/create/asset');
$I->wantTo('store a new asset account with a balance');
$I->see('Create a new asset account');
$I->submitForm('#store', ['name' => 'New through tests with balance.',
'openingBalance' => 10,
'openingBalanceDate' => '2015-01-01',
'what' => 'asset', 'account_role' => 'defaultExpense', 'post_submit_action' => 'store']);
$I->seeRecord('accounts', ['name' => 'New through tests with balance.']);
}
/**
* @param FunctionalTester $I
*/
public function storeAndCreateAnother(FunctionalTester $I)
{
$I->amOnPage('/accounts/create/asset');
$I->wantTo('store a new asset account and create another');
$I->see('Create a new asset account');
$I->submitForm(
'#store', ['name' => 'New through tests.', 'what' => 'asset', 'account_role' => 'defaultExpense', 'post_submit_action' => 'create_another']
);
$I->seeRecord('accounts', ['name' => 'New through tests.']);
}
/**
* @param FunctionalTester $I
*/
public function storeFail(FunctionalTester $I)
{
$I->amOnPage('/accounts/create/asset');
$I->wantTo('make storing a new asset account fail.');
$I->see('Create a new asset account');
$I->submitForm('#store', ['name' => null, 'what' => 'asset', 'account_role' => 'defaultExpense', 'post_submit_action' => 'validate_only']);
$I->dontSeeRecord('accounts', ['name' => 'New through tests.']);
}
/**
* @param FunctionalTester $I
*/
public function storeValidateOnly(FunctionalTester $I)
{
$I->amOnPage('/accounts/create/asset');
$I->wantTo('validate a new asset account');
$I->see('Create a new asset account');
$I->submitForm(
'#store', ['name' => 'New through tests.', 'what' => 'asset', 'account_role' => 'defaultExpense', 'post_submit_action' => 'validate_only']
);
$I->dontSeeRecord('accounts', ['name' => 'New through tests.']);
}
/**
* @param FunctionalTester $I
*/
public function update(FunctionalTester $I)
{
$I->wantTo('update an asset account');
$I->amOnPage('/accounts/edit/3');
$I->see('Edit asset account "Delete me"');
$I->submitForm('#update', ['name' => 'Update me', 'what' => 'asset', 'account_role' => 'defaultExpense', 'post_submit_action' => 'update']);
$I->seeRecord('accounts', ['name' => 'Update me']);
}
/**
* @param FunctionalTester $I
*/
public function updateAndReturn(FunctionalTester $I)
{
$I->wantTo('update an asset account and return to form');
$I->amOnPage('/accounts/edit/2');
$I->see('Edit asset account "Savings account"');
$I->submitForm(
'#update', ['name' => 'Savings accountXX', 'what' => 'asset', 'account_role' => 'defaultExpense', 'post_submit_action' => 'return_to_edit']
);
$I->seeRecord('accounts', ['name' => 'Savings accountXX']);
}
/**
* @param FunctionalTester $I
*/
public function validateUpdateOnly(FunctionalTester $I)
{
$I->wantTo('update an asset account and validate only');
$I->amOnPage('/accounts/edit/2');
$I->see('Edit asset account "Savings account"');
$I->submitForm(
'#update', ['name' => 'Savings accountXX', 'what' => 'asset', 'account_role' => 'defaultExpense', 'post_submit_action' => 'validate_only']
);
$I->dontSeeRecord('accounts', ['name' => 'Savings accountXX']);
}
}

View File

@ -0,0 +1,276 @@
<?php
/**
* Class BillControllerCest
*
* @SuppressWarnings("CamelCase")
* @SuppressWarnings("short")
*/
class BillControllerCest
{
/**
* @param FunctionalTester $I
*/
public function _after(FunctionalTester $I)
{
}
/**
* @param FunctionalTester $I
*/
public function _before(FunctionalTester $I)
{
$I->amLoggedAs(['email' => 'thegrumpydictator@gmail.com', 'password' => 'james']);
}
/**
* @param FunctionalTester $I
*/
public function create(FunctionalTester $I)
{
$I->wantTo('create a bill');
$I->amOnPage('/bills/create');
}
/**
* @param FunctionalTester $I
*/
public function delete(FunctionalTester $I)
{
$bill = User::whereEmail('thegrumpydictator@gmail.com')->first()->bills()->first();
$I->wantTo('delete a bill');
$I->amOnPage('/bills/delete/' . $bill->id);
$I->see('Delete "' . $bill->name . '"');
}
/**
* @param FunctionalTester $I
*/
public function destroy(FunctionalTester $I)
{
$bill = User::whereEmail('thegrumpydictator@gmail.com')->first()->bills()->first();
$I->wantTo('destroy a bill');
$I->amOnPage('/bills/delete/' . $bill->id);
$I->see('Delete "' . $bill->name . '"');
$I->submitForm('#destroy', []);
$I->see('The bill was deleted.');
}
/**
* @param FunctionalTester $I
*/
public function edit(FunctionalTester $I)
{
$bill = User::whereEmail('thegrumpydictator@gmail.com')->first()->bills()->first();
$I->wantTo('edit a bill');
$I->amOnPage('/bills/edit/' . $bill->id);
$I->see($bill->name);
}
/**
* @param FunctionalTester $I
*/
public function index(FunctionalTester $I)
{
$bill = User::whereEmail('thegrumpydictator@gmail.com')->first()->bills()->first();
$I->wantTo('see all bills');
$I->amOnPage('/bills');
$I->see('Bills');
$I->see($bill->name);
}
/**
* @param FunctionalTester $I
*/
public function rescan(FunctionalTester $I)
{
$bill = User::whereEmail('thegrumpydictator@gmail.com')->first()->bills()->first();
$I->wantTo('rescan a bill');
$I->amOnPage('/bills/rescan/' . $bill->id);
$I->see('Rescanned everything.');
}
/**
* @param FunctionalTester $I
*/
public function rescanInactive(FunctionalTester $I)
{
$bill = User::whereEmail('thegrumpydictator@gmail.com')->first()->bills()->where('active', 0)->first();
$I->wantTo('rescan an inactive bill');
$I->amOnPage('/bills/rescan/' . $bill->id);
$I->see('Inactive bills cannot be scanned.');
}
/**
* @param FunctionalTester $I
*/
public function show(FunctionalTester $I)
{
$bill = User::whereEmail('thegrumpydictator@gmail.com')->first()->bills()->first();
$I->wantTo('show a bill');
$I->amOnPage('/bills/show/' . $bill->id);
$I->see($bill->name);
}
/**
* @param FunctionalTester $I
*/
public function store(FunctionalTester $I)
{
$I->wantTo('store a bill');
$I->amOnPage('/bills/create');
$I->submitForm(
'#store', [
'name' => 'Some bill',
'match' => 'one,two',
'amount_min' => 10,
'amount_max' => 20,
'post_submit_action' => 'store',
'date' => date('Y-m-d'),
'repeat_freq' => 'monthly',
'skip' => 0
]
);
$I->see('Bill &quot;Some bill&quot; stored.');
}
/**
* @param FunctionalTester $I
*/
public function storeFail(FunctionalTester $I)
{
$I->wantTo('store a bill and fail');
$I->amOnPage('/bills/create');
$I->submitForm(
'#store', [
'name' => 'Some bill',
'match' => '',
'amount_min' => 10,
'amount_max' => 20,
'date' => date('Y-m-d'),
'repeat_freq' => 'monthly',
'skip' => 0
]
);
$I->dontSeeInDatabase('bills', ['name' => 'Some bill']);
$I->see('Could not store bill');
}
/**
* @param FunctionalTester $I
*/
public function storeRecreate(FunctionalTester $I)
{
$I->wantTo('validate a bill and create another one');
$I->amOnPage('/bills/create');
$I->submitForm(
'#store', [
'name' => 'Some bill',
'match' => 'one,two',
'amount_min' => 10,
'amount_max' => 20,
'post_submit_action' => 'create_another',
'date' => date('Y-m-d'),
'repeat_freq' => 'monthly',
'skip' => 0,
]
);
$I->see('Bill &quot;Some bill&quot; stored.');
}
/**
* @param FunctionalTester $I
*/
public function storeValidate(FunctionalTester $I)
{
$I->wantTo('validate a bill');
$I->amOnPage('/bills/create');
$I->submitForm(
'#store', [
'name' => 'Some bill',
'match' => 'one,two',
'amount_min' => 10,
'amount_max' => 20,
'post_submit_action' => 'validate_only',
'date' => date('Y-m-d'),
'repeat_freq' => 'monthly',
'skip' => 0,
]
);
$I->see('form-group has-success has-feedback');
}
/**
* @param FunctionalTester $I
*/
public function update(FunctionalTester $I)
{
$bill = User::whereEmail('thegrumpydictator@gmail.com')->first()->bills()->first();
$I->wantTo('update a bill');
$I->amOnPage('/bills/edit/' . $bill->id);
$I->submitForm(
'#update', [
'name' => 'Some bill',
'match' => 'bla,bla',
'amount_min' => 10,
'amount_max' => 20,
'date' => date('Y-m-d'),
'repeat_freq' => 'monthly',
'skip' => 0
]
);
$I->see('Bill &quot;Some bill&quot; updated.');
}
/**
* @param FunctionalTester $I
*/
public function updateFail(FunctionalTester $I)
{
$bill = User::whereEmail('thegrumpydictator@gmail.com')->first()->bills()->first();
$I->wantTo('update a bill and fail');
$I->amOnPage('/bills/edit/' . $bill->id);
$I->submitForm(
'#update', [
'name' => 'Some bill',
'match' => '',
'amount_min' => 10,
'amount_max' => 20,
'date' => date('Y-m-d'),
'repeat_freq' => 'monthly',
'skip' => 0
]
);
$I->see('Could not update bill');
}
/**
* @param FunctionalTester $I
*/
public function updateReturn(FunctionalTester $I)
{
$bill = User::whereEmail('thegrumpydictator@gmail.com')->first()->bills()->first();
$I->wantTo('update a bill and return to edit it');
$I->amOnPage('/bills/edit/' . $bill->id);
$I->submitForm(
'#update', [
'name' => 'Some bill',
'match' => 'bla,bla',
'amount_min' => 10,
'amount_max' => 20,
'post_submit_action' => 'return_to_edit',
'date' => date('Y-m-d'),
'repeat_freq' => 'monthly',
'skip' => 0
]
);
$I->see('Bill &quot;Some bill&quot; updated.');
}
}

View File

@ -0,0 +1,252 @@
<?php
/**
* @SuppressWarnings("CamelCase")
* @SuppressWarnings("short")
*
* Class BudgetControllerCest
*/
class BudgetControllerCest
{
/**
* @param FunctionalTester $I
*/
public function _after(FunctionalTester $I)
{
}
/**
* @param FunctionalTester $I
*/
public function _before(FunctionalTester $I)
{
$I->amLoggedAs(['email' => 'thegrumpydictator@gmail.com', 'password' => 'james']);
}
/**
* @param FunctionalTester $I
*/
public function amount(FunctionalTester $I)
{
$I->wantTo('update the amount for a budget and limit repetition');
$I->amOnPage('/budgets');
///budgets/income
$I->sendAjaxPostRequest('/budgets/amount/1', ['amount' => 100]);
$I->canSeeResponseCodeIs(200);
$I->see('Groceries');
$I->seeInDatabase('budgets', ['id' => 1]);
#$I->seeInDatabase('budget_limits', ['budget_id' => 1, 'amount' => 100.00]);
}
/**
* @param FunctionalTester $I
*/
public function create(FunctionalTester $I)
{
$I->wantTo('create a budget');
$I->amOnRoute('budgets.create');
$I->see('Create a new budget');
}
/**
* @param FunctionalTester $I
*/
public function delete(FunctionalTester $I)
{
$I->wantTo('delete a budget');
$I->amOnPage('/budgets/delete/3');
$I->see('Delete budget "Delete me"');
}
/**
* @param FunctionalTester $I
*/
public function destroy(FunctionalTester $I)
{
$I->wantTo('destroy a budget');
$I->amOnPage('/budgets/delete/3');
$I->see('Delete budget "Delete me"');
$I->submitForm('#destroy', []);
$I->see('Budget &quot;Delete me&quot; was deleted.');
}
/**
* @param FunctionalTester $I
*/
public function edit(FunctionalTester $I)
{
$I->wantTo('edit a budget');
$I->amOnPage('/budgets/edit/3');
$I->see('Edit budget "Delete me"');
}
/**
* @param FunctionalTester $I
*/
public function failUpdate(FunctionalTester $I)
{
$I->wantTo('update a budget and fail');
$I->amOnPage('/budgets/edit/3');
$I->see('Edit budget "Delete me"');
$I->submitForm('#update', ['name' => '', 'post_submit_action' => 'update']);
$I->seeRecord('budgets', ['name' => 'Delete me']);
}
/**
* @param FunctionalTester $I
*/
public function index(FunctionalTester $I)
{
$I->wantTo('show all budgets');
$I->amOnPage('/budgets');
$I->see('Budgets');
}
/**
* @param FunctionalTester $I
*/
public function indexNoBudget(FunctionalTester $I)
{
$I->wantTo('see transactions without a budget');
$I->amOnPage('/budgets/list/noBudget');
$I->see('Transactions without a budget in');
}
/**
* @param FunctionalTester $I
*/
public function postUpdateIncome(FunctionalTester $I)
{
$date = date('FY');
$I->wantTo('process the update to my monthly income');
$I->amOnPage('/budgets/income');
$I->see('Update (expected) income for');
$I->submitForm('#income', ['amount' => 1200]);
$I->seeRecord('preferences', ['name' => 'budgetIncomeTotal' . $date, 'data' => 1200]);
}
/**
* @param FunctionalTester $I
*/
public function show(FunctionalTester $I)
{
$I->wantTo('show a budget');
$I->amOnPage('/budgets/show/3');
$I->see('Delete me');
}
/**
* @param FunctionalTester $I
*/
public function showInvalidRepetition(FunctionalTester $I)
{
$I->wantTo('show a budget with a repetition that does not match the budget.');
$I->amOnPage('/budgets/show/1/3');
$I->see('Invalid selection');
}
/**
* @param FunctionalTester $I
*/
public function store(FunctionalTester $I)
{
$I->amOnPage('/budgets/create');
$I->wantTo('store a new budget');
$I->see('Create a new budget');
$I->submitForm('#store', ['name' => 'New budget.', 'post_submit_action' => 'store']);
$I->seeRecord('budgets', ['name' => 'New budget.']);
}
/**
* @param FunctionalTester $I
*/
public function storeAndCreateAnother(FunctionalTester $I)
{
$I->amOnPage('/budgets/create');
$I->wantTo('store a new budget and create another');
$I->see('Create a new budget');
$I->submitForm('#store', ['name' => 'New budget.', 'post_submit_action' => 'create_another']);
$I->seeRecord('budgets', ['name' => 'New budget.']);
}
/**
* @param FunctionalTester $I
*/
public function storeFail(FunctionalTester $I)
{
$I->amOnPage('/budgets/create');
$I->wantTo('make storing a new budget fail.');
$I->see('Create a new budget');
$I->submitForm('#store', ['name' => null, 'post_submit_action' => 'store']);
$I->dontSeeRecord('budgets', ['name' => 'New budget.']);
}
/**
* @param FunctionalTester $I
*/
public function storeValidateOnly(FunctionalTester $I)
{
$I->amOnPage('/budgets/create');
$I->wantTo('validate a new budget');
$I->see('Create a new budget');
$I->submitForm('#store', ['name' => 'New budget.', 'post_submit_action' => 'validate_only']);
$I->dontSeeRecord('budgets', ['name' => 'New budget.']);
}
/**
* @param FunctionalTester $I
*/
public function update(FunctionalTester $I)
{
$I->wantTo('update a budget');
$I->amOnPage('/budgets/edit/3');
$I->see('Edit budget "Delete me"');
$I->submitForm('#update', ['name' => 'Update me', 'post_submit_action' => 'update']);
$I->seeRecord('budgets', ['name' => 'Update me']);
}
/**
* @param FunctionalTester $I
*/
public function updateAndReturn(FunctionalTester $I)
{
$I->wantTo('update a budget and return to form');
$I->amOnPage('/budgets/edit/3');
$I->see('Edit budget "Delete me"');
$I->submitForm(
'#update', ['name' => 'Savings accountXX', 'post_submit_action' => 'return_to_edit']
);
$I->seeRecord('budgets', ['name' => 'Savings accountXX']);
}
/**
* @param FunctionalTester $I
*/
public function updateIncome(FunctionalTester $I)
{
$I->amOnPage('/budgets/income');
$I->wantTo('update my monthly income');
$I->see('Update (expected) income for ');
}
/**
* @param FunctionalTester $I
*/
public function validateUpdateOnly(FunctionalTester $I)
{
$I->wantTo('update a budget and validate only');
$I->amOnPage('/budgets/edit/3');
$I->see('Edit budget "Delete me"');
$I->submitForm(
'#update', ['name' => 'Validate Only', 'post_submit_action' => 'validate_only']
);
$I->dontSeeRecord('budgets', ['name' => 'Savings accountXX']);
$I->seeRecord('budgets', ['name' => 'Delete me']);
}
}

View File

@ -0,0 +1,201 @@
<?php
/**
* @SuppressWarnings("CamelCase")
* @SuppressWarnings("short")
*
* Class CategoryControllerCest
*/
class CategoryControllerCest
{
/**
* @param FunctionalTester $I
*/
public function _after(FunctionalTester $I)
{
}
/**
* @param FunctionalTester $I
*/
public function _before(FunctionalTester $I)
{
$I->amLoggedAs(['email' => 'thegrumpydictator@gmail.com', 'password' => 'james']);
}
/**
* @param FunctionalTester $I
*/
public function create(FunctionalTester $I)
{
$I->wantTo('create a new category');
$I->amOnPage('/categories/create');
}
/**
* @param FunctionalTester $I
*/
public function delete(FunctionalTester $I)
{
$I->wantTo('delete a category');
$I->amOnPage('/categories/delete/4');
$I->see('Delete category "Delete me"');
}
/**
* @param FunctionalTester $I
*/
public function destroy(FunctionalTester $I)
{
$I->wantTo('destroy a category');
$I->amOnPage('/categories/delete/4');
$I->see('Delete category "Delete me"');
$I->submitForm('#destroy', []);
$I->see('Category &quot;Delete me&quot; was deleted.');
}
/**
* @param FunctionalTester $I
*/
public function edit(FunctionalTester $I)
{
$I->wantTo('edit a category');
$I->amOnPage('/categories/edit/4');
$I->see('Edit category "Delete me"');
}
/**
* @param FunctionalTester $I
*/
public function failUpdate(FunctionalTester $I)
{
$I->wantTo('update a category and fail');
$I->amOnPage('/categories/edit/4');
$I->see('Edit category "Delete me"');
$I->submitForm('#update', ['name' => '', 'post_submit_action' => 'update']);
$I->seeRecord('categories', ['name' => 'Delete me']);
}
/**
* @param FunctionalTester $I
*/
public function index(FunctionalTester $I)
{
$I->wantTo('show all categories');
$I->amOnPage('/categories');
}
/**
* @param FunctionalTester $I
*/
public function indexNoCategory(FunctionalTester $I)
{
$I->wantTo('see transactions without a category');
$I->amOnPage('/categories/list/noCategory');
$I->see('Transactions without a category in');
}
/**
* @param FunctionalTester $I
*/
public function show(FunctionalTester $I)
{
$I->wantTo('show a category');
$I->amOnPage('/categories/show/4');
$I->see('Delete me');
}
/**
* @param FunctionalTester $I
*/
public function store(FunctionalTester $I)
{
$I->amOnPage('/categories/create');
$I->wantTo('store a new category');
$I->see('Create a new category');
$I->submitForm('#store', ['name' => 'New category.', 'post_submit_action' => 'store']);
$I->seeRecord('categories', ['name' => 'New category.']);
}
/**
* @param FunctionalTester $I
*/
public function storeAndCreateAnother(FunctionalTester $I)
{
$I->amOnPage('/categories/create');
$I->wantTo('store a new category and create another');
$I->see('Create a new category');
$I->submitForm('#store', ['name' => 'New category.', 'post_submit_action' => 'create_another']);
$I->seeRecord('categories', ['name' => 'New category.']);
}
/**
* @param FunctionalTester $I
*/
public function storeFail(FunctionalTester $I)
{
$I->amOnPage('/categories/create');
$I->wantTo('make storing a new category fail.');
$I->see('Create a new category');
$I->submitForm('#store', ['name' => null, 'post_submit_action' => 'validate_only']);
$I->dontSeeRecord('categories', ['name' => 'New category.']);
}
/**
* @param FunctionalTester $I
*/
public function storeValidateOnly(FunctionalTester $I)
{
$I->amOnPage('/categories/create');
$I->wantTo('validate a new category');
$I->see('Create a new category');
$I->submitForm('#store', ['name' => 'New category.', 'post_submit_action' => 'validate_only']);
$I->dontSeeRecord('categories', ['name' => 'New category.']);
}
/**
* @param FunctionalTester $I
*/
public function update(FunctionalTester $I)
{
$I->wantTo('update a category');
$I->amOnPage('/categories/edit/4');
$I->see('Edit category "Delete me"');
$I->submitForm('#update', ['name' => 'Update me', 'post_submit_action' => 'update']);
$I->seeRecord('categories', ['name' => 'Update me']);
}
/**
* @param FunctionalTester $I
*/
public function updateAndReturn(FunctionalTester $I)
{
$I->wantTo('update a category and return to form');
$I->amOnPage('/categories/edit/4');
$I->see('Edit category "Delete me"');
$I->submitForm(
'#update', ['name' => 'Savings accountXX', 'post_submit_action' => 'return_to_edit']
);
$I->seeRecord('categories', ['name' => 'Savings accountXX']);
}
/**
* @param FunctionalTester $I
*/
public function validateUpdateOnly(FunctionalTester $I)
{
$I->wantTo('update a category and validate only');
$I->amOnPage('/categories/edit/4');
$I->see('Edit category "Delete me"');
$I->submitForm(
'#update', ['name' => 'Validate Only', 'post_submit_action' => 'validate_only']
);
$I->dontSeeRecord('categories', ['name' => 'Savings accountXX']);
$I->seeRecord('categories', ['name' => 'Delete me']);
}
}

View File

@ -0,0 +1,202 @@
<?php
/**
*
* @SuppressWarnings("CamelCase")
* @SuppressWarnings("short")
*
* Class CurrencyControllerCest
*/
class CurrencyControllerCest
{
/**
* @param FunctionalTester $I
*/
public function _after(FunctionalTester $I)
{
}
/**
* @param FunctionalTester $I
*/
public function _before(FunctionalTester $I)
{
$I->amLoggedAs(['email' => 'thegrumpydictator@gmail.com', 'password' => 'james']);
}
/**
* @param FunctionalTester $I
*/
public function create(FunctionalTester $I)
{
$I->wantTo('create a currency');
$I->amOnRoute('currency.create');
$I->see('Create a new currency');
}
/**
* @param FunctionalTester $I
*/
public function defaultCurrency(FunctionalTester $I)
{
$I->wantTo('make US Dollar the default currency');
$I->amOnPage('/currency/default/2');
$I->see('US Dollar is now the default currency.');
}
/**
* @param FunctionalTester $I
*/
public function delete(FunctionalTester $I)
{
$I->wantTo('delete a currency');
$I->amOnPage('/currency/delete/3');
$I->see('Delete currency "Hungarian forint"');
}
/**
* @param FunctionalTester $I
*/
public function destroy(FunctionalTester $I)
{
$I->wantTo('destroy a currency');
$I->amOnPage('/currency/delete/3');
$I->see('Delete currency "Hungarian forint"');
$I->submitForm('#destroy', []);
$I->see('Currency &quot;Hungarian forint&quot; deleted');
}
/**
* @param FunctionalTester $I
*/
public function destroyFail(FunctionalTester $I)
{
$I->wantTo('destroy a currency currently in use');
$I->amOnPage('/currency/delete/1');
$I->see('Cannot delete Euro because there are still transactions attached to it.');
}
/**
* @param FunctionalTester $I
*/
public function edit(FunctionalTester $I)
{
$I->wantTo('edit a currency');
$I->amOnPage('/currency/edit/2');
$I->see('Edit currency "US Dollar"');
}
/**
* @param FunctionalTester $I
*/
public function failUpdate(FunctionalTester $I)
{
$I->wantTo('update a currency and fail');
$I->amOnPage('/currency/edit/2');
$I->see('Edit currency "US Dollar"');
$I->submitForm('#update', ['name' => 'Failed update', 'code' => '123', 'post_submit_action' => 'update']);
$I->dontSeeRecord('transaction_currencies', ['name' => 'Failed update']);
}
/**
* @param FunctionalTester $I
*/
public function index(FunctionalTester $I)
{
$I->wantTo('show all currencies');
$I->amOnPage('/currency');
$I->see('fa-usd');
}
/**
* @param FunctionalTester $I
*/
public function store(FunctionalTester $I)
{
$I->amOnPage('/currency/create');
$I->wantTo('store a new currency');
$I->see('Create a new currency');
$I->submitForm('#store', ['name' => 'New currency.', 'symbol' => 'C', 'code' => 'CXX', 'post_submit_action' => 'store']);
$I->seeRecord('transaction_currencies', ['name' => 'New currency.']);
}
/**
* @param FunctionalTester $I
*/
public function storeAndCreateAnother(FunctionalTester $I)
{
$I->amOnPage('/currency/create');
$I->wantTo('store a new currency and create another');
$I->see('Create a new currency');
$I->submitForm('#store', ['name' => 'Store and create another.', 'symbol' => 'C', 'code' => 'CXX', 'post_submit_action' => 'create_another']);
$I->seeRecord('transaction_currencies', ['name' => 'Store and create another.']);
}
/**
* @param FunctionalTester $I
*/
public function storeFail(FunctionalTester $I)
{
$I->amOnPage('/currency/create');
$I->wantTo('make storing a new currency fail.');
$I->see('Create a new currency');
$I->submitForm('#store', ['name' => 'Store and fail', 'symbol' => null, 'code' => '123', 'post_submit_action' => 'store']);
$I->dontSeeRecord('transaction_currencies', ['name' => 'Store and fail']);
}
/**
* @param FunctionalTester $I
*/
public function storeValidateOnly(FunctionalTester $I)
{
$I->amOnPage('/currency/create');
$I->wantTo('validate a new currency');
$I->see('Create a new currency');
$I->submitForm('#store', ['name' => 'Store validate only.', 'symbol' => 'C', 'code' => 'CXX', 'post_submit_action' => 'validate_only']);
$I->dontSeeRecord('transaction_currencies', ['name' => 'Store validate only.']);
}
/**
* @param FunctionalTester $I
*/
public function update(FunctionalTester $I)
{
$I->wantTo('update a currency');
$I->amOnPage('/currency/edit/2');
$I->see('Edit currency "US Dollar"');
$I->submitForm('#update', ['name' => 'Successful update', 'symbol' => '$', 'code' => 'USD', 'post_submit_action' => 'update']);
$I->seeRecord('transaction_currencies', ['name' => 'Successful update']);
}
/**
* @param FunctionalTester $I
*/
public function updateAndReturn(FunctionalTester $I)
{
$I->wantTo('update a currency and return to form');
$I->amOnPage('/currency/edit/2');
$I->see('Edit currency "US Dollar"');
$I->submitForm(
'#update', ['name' => 'US DollarXXX', 'symbol' => '$', 'code' => 'USD', 'post_submit_action' => 'return_to_edit']
);
$I->seeRecord('transaction_currencies', ['name' => 'US DollarXXX']);
}
/**
* @param FunctionalTester $I
*/
public function validateUpdateOnly(FunctionalTester $I)
{
$I->wantTo('update a currency and validate only');
$I->amOnPage('/currency/edit/2');
$I->see('Edit currency "US Dollar"');
$I->submitForm('#update', ['name' => 'Update Validate Only', 'post_submit_action' => 'validate_only']);
$I->dontSeeRecord('transaction_currencies', ['name' => 'Update Validate Only']);
$I->seeRecord('transaction_currencies', ['name' => 'US Dollar']);
}
}

View File

@ -0,0 +1,201 @@
<?php
/**
* @SuppressWarnings("CamelCase")
* @SuppressWarnings("short")
* Class GoogleChartControllerCest
*/
class GoogleChartControllerCest
{
/**
* @param FunctionalTester $I
*/
public function _after(FunctionalTester $I)
{
}
/**
* @param FunctionalTester $I
*/
public function _before(FunctionalTester $I)
{
$I->amLoggedAs(['email' => 'thegrumpydictator@gmail.com', 'password' => 'james']);
}
/**
* @param FunctionalTester $I
*/
public function accountAllBalanceChart(FunctionalTester $I)
{
$I->wantTo('see the complete balance chart of an account.');
$I->amOnPage('chart/account/1/all');
$I->seeResponseCodeIs(200);
}
/**
* @param FunctionalTester $I
*/
public function accountBalanceChart(FunctionalTester $I)
{
$I->wantTo('see the session balance chart of an account.');
$I->amOnPage('chart/account/1/session');
$I->seeResponseCodeIs(200);
}
/**
* @param FunctionalTester $I
*/
public function allAccountsBalanceChart(FunctionalTester $I)
{
$I->wantTo('see the chart with the balances of all accounts');
$I->amOnPage('/chart/home/account');
$I->seeResponseCodeIs(200);
}
/**
* @param FunctionalTester $I
*/
public function allBudgetsHomeChart(FunctionalTester $I)
{
$I->wantTo('see the chart with all budgets on it');
$I->amOnPage('/chart/home/budgets');
$I->seeResponseCodeIs(200);
}
/**
* @param FunctionalTester $I
*/
public function allCategoriesHomeChart(FunctionalTester $I)
{
$I->wantTo('see the chart with all categories on it');
$I->amOnPage('/chart/home/categories');
$I->seeResponseCodeIs(200);
}
/**
* @param FunctionalTester $I
*/
public function billOverview(FunctionalTester $I)
{
$I->wantTo('see the chart for the history of a bill');
$I->amOnPage('/chart/bills/1');
$I->seeResponseCodeIs(200);
}
/**
* @param FunctionalTester $I
*/
public function billsOverview(FunctionalTester $I)
{
$I->wantTo('see the chart for which bills I have yet to pay');
$I->amOnPage('/chart/home/bills');
$I->seeResponseCodeIs(200);
}
/**
* @param FunctionalTester $I
*/
public function budgetLimitSpending(FunctionalTester $I)
{
$I->wantTo('see the chart for a budget and a repetition');
$I->amOnPage('/chart/budget/1/1');
$I->seeResponseCodeIs(200);
}
/**
* @param FunctionalTester $I
*/
public function budgetsAndSpending(FunctionalTester $I)
{
$I->wantTo('see the chart for a budget in a specific year');
$I->amOnPage('/chart/budget/1/spending');
$I->seeResponseCodeIs(200);
}
/**
* @param FunctionalTester $I
*/
public function categoriesAndSpending(FunctionalTester $I)
{
$year = date('Y');
$I->wantTo('see the chart for a category in a specific year');
$I->amOnPage('/chart/category/1/spending/'.$year);
$I->seeResponseCodeIs(200);
}
/**
* @param FunctionalTester $I
*/
public function categoriesAndSpendingInvalidYear(FunctionalTester $I)
{
$I->wantTo('see the chart for a category in an invalid year');
$I->amOnPage('/chart/category/1/spending/XXXX');
$I->seeResponseCodeIs(200);
$I->see('Invalid year');
}
/**
* @param FunctionalTester $I
*/
public function emptyBillOverview(FunctionalTester $I)
{
$I->wantTo('see the chart for the history of an empty bill');
$I->amOnPage('/chart/bills/2');
$I->seeResponseCodeIs(200);
}
/**
* @param FunctionalTester $I
*/
public function piggyBankHistory(FunctionalTester $I)
{
$I->wantTo('see the chart for the history of a piggy bank');
$I->amOnPage('/chart/piggy_history/1');
$I->seeResponseCodeIs(200);
}
/**
* @param FunctionalTester $I
*/
public function yearInExp(FunctionalTester $I)
{
$I->wantTo("see this year's expenses");
$I->amOnPage('/chart/reports/income-expenses/' . date('Y'));
$I->seeResponseCodeIs(200);
}
/**
* @param FunctionalTester $I
*/
public function yearInExpInvalidYear(FunctionalTester $I)
{
$I->wantTo("see the year's expenses of an invalid year");
$I->amOnPage('/chart/reports/income-expenses/XXXXX');
$I->seeResponseCodeIs(200);
$I->see('Invalid year');
}
/**
* @param FunctionalTester $I
*/
public function yearInExpSum(FunctionalTester $I)
{
$I->wantTo("see this year's expenses summarized");
$I->amOnPage('/chart/reports/income-expenses-sum/' . date('Y'));
$I->seeResponseCodeIs(200);
}
/**
* @param FunctionalTester $I
*/
public function yearInExpSumInvalidYear(FunctionalTester $I)
{
$I->wantTo("see the year's expenses summarized of an invalid year");
$I->amOnPage('/chart/reports/income-expenses-sum/XXXXX');
$I->seeResponseCodeIs(200);
$I->see('Invalid year');
}
}

View File

@ -0,0 +1,89 @@
<?php
/**
* Class HelpControllerCest
*
* @SuppressWarnings("CamelCase")
* @SuppressWarnings("short")
*/
class HelpControllerCest
{
/**
* @param FunctionalTester $I
*/
public function _after(FunctionalTester $I)
{
}
/**
* @param FunctionalTester $I
*/
public function _before(FunctionalTester $I)
{
$I->amLoggedAs(['email' => 'thegrumpydictator@gmail.com', 'password' => 'james']);
}
/**
* @param FunctionalTester $I
*/
public function show(FunctionalTester $I)
{
$I->wantTo('show help for the index page');
$I->amOnPage('/help/index');
$I->canSeeResponseCodeIs(200);
$I->see('text');
}
/**
* @param FunctionalTester $I
*/
public function showFromCache(FunctionalTester $I)
{
$I->wantTo('show help for the index page from the cache.');
$I->amOnPage('/help/index');
$I->amOnPage('/help/index');
$I->canSeeResponseCodeIs(200);
$I->see('text');
}
/**
* @param FunctionalTester $I
*/
public function showHelpEmptyHelpFile(FunctionalTester $I)
{
$I->wantTo('show help for a route with no text.');
$I->amOnPage('/help/transactions.doRelate');
$I->canSeeResponseCodeIs(200);
$I->see('There is no help for this route');
}
/**
* @param FunctionalTester $I
*/
public function showHelpInvalidRoute(FunctionalTester $I)
{
$I->wantTo('show help for a non-existing route.');
$I->amOnPage('/help/indexXXXX');
$I->canSeeResponseCodeIs(200);
$I->see('There is no help for this route');
}
//
/**
* @param FunctionalTester $I
*/
public function showHelpNoHelpFile(FunctionalTester $I)
{
$I->wantTo('show help for route that has no help file.');
$I->amOnPage('/help/help.show');
$I->canSeeResponseCodeIs(200);
$I->see('text');
}
}

View File

@ -0,0 +1,97 @@
<?php
/**
*
* @SuppressWarnings("CamelCase")
* @SuppressWarnings("short")
* Class HomeControllerCest
*/
class HomeControllerCest
{
/**
* @param FunctionalTester $I
*/
public function _after(FunctionalTester $I)
{
}
/**
* @param FunctionalTester $I
*/
public function _before(FunctionalTester $I)
{
$I->amLoggedAs(['email' => 'thegrumpydictator@gmail.com', 'password' => 'james']);
}
/**
* @param FunctionalTester $I
*/
public function flush(FunctionalTester $I)
{
$I->wantTo('flush the cache');
$I->amOnPage('/flush');
$I->canSeeResponseCodeIs(200);
$I->see('Firefly');
}
/**
* @param FunctionalTester $I
*/
public function index(FunctionalTester $I)
{
$I->wantTo('see the home page of Firefly');
$I->amOnPage('/');
$I->canSeeResponseCodeIs(200);
$I->see('Firefly');
}
/**
* @param FunctionalTester $I
*/
public function indexWithPrefs(FunctionalTester $I)
{
\Preference::whereName('frontPageAccounts')->delete();
\Preference::create(
[
'user_id' => 1,
'name' => 'frontPageAccounts',
'data' => [1,2]
]
);
$I->wantTo('see the home page of Firefly using pre-set accounts');
$I->amOnPage('/');
$I->canSeeResponseCodeIs(200);
$I->see('Firefly');
}
/**
* @param FunctionalTester $I
*/
public function rangeJump(FunctionalTester $I)
{
$I->wantTo('switch to another date range');
$I->amOnPage('/jump/6M');
$I->canSeeResponseCodeIs(200);
}
/**
* @param FunctionalTester $I
*/
public function sessionNext(FunctionalTester $I)
{
$I->wantTo('jump to the next period');
$I->amOnPage('/next');
$I->canSeeResponseCodeIs(200);
}
/**
* @param FunctionalTester $I
*/
public function sessionPrev(FunctionalTester $I)
{
$I->wantTo('jump to the previous period');
$I->amOnPage('/prev');
$I->canSeeResponseCodeIs(200);
}
}

View File

@ -0,0 +1,56 @@
<?php
/**
*
* @SuppressWarnings("CamelCase")
* @SuppressWarnings("short")
*
* Class JsonControllerCest
*/
class JsonControllerCest
{
/**
* @param FunctionalTester $I
*/
public function _after(FunctionalTester $I)
{
}
/**
* @param FunctionalTester $I
*/
public function _before(FunctionalTester $I)
{
$I->amLoggedAs(['email' => 'thegrumpydictator@gmail.com', 'password' => 'james']);
}
/**
* @param FunctionalTester $I
*/
public function categories(FunctionalTester $I)
{
$I->wantTo('See a JSON list of categories.');
$I->amOnPage('/json/categories');
$I->canSeeResponseCodeIs(200);
}
/**
* @param FunctionalTester $I
*/
public function expenseAccounts(FunctionalTester $I)
{
$I->wantTo('See a JSON list of expense accounts.');
$I->amOnPage('/json/expense-accounts');
$I->canSeeResponseCodeIs(200);
}
/**
* @param FunctionalTester $I
*/
public function revenueAccounts(FunctionalTester $I)
{
$I->wantTo('See a JSON list of revenue accounts.');
$I->amOnPage('/json/revenue-accounts');
$I->canSeeResponseCodeIs(200);
}
}

View File

@ -0,0 +1,356 @@
<?php
/**
*
* @SuppressWarnings("CamelCase")
* @SuppressWarnings("short")
*
* Class PiggyBankControllerCest
*/
class PiggyBankControllerCest
{
/**
* @param FunctionalTester $I
*/
public function _after(FunctionalTester $I)
{
}
/**
* @param FunctionalTester $I
*/
public function _before(FunctionalTester $I)
{
$I->amLoggedAs(['email' => 'thegrumpydictator@gmail.com', 'password' => 'james']);
}
/**
* @param FunctionalTester $I
*/
public function add(FunctionalTester $I)
{
$I->wantTo('add money to a piggy bank');
$I->amOnPage('/piggy_banks/add/1');
$I->see('Add money to New camera');
}
/**
* @param FunctionalTester $I
*/
public function create(FunctionalTester $I)
{
$I->wantTo('create a piggy bank');
$I->amOnPage('/piggy_banks/create');
$I->see('Create new piggy bank');
}
/**
* @param FunctionalTester $I
*/
public function delete(FunctionalTester $I)
{
$I->wantTo('delete a piggy bank');
$I->amOnPage('/piggy_banks/delete/1');
$I->see('Delete &quot;New camera&quot;');
}
/**
* @param FunctionalTester $I
*/
public function destroy(FunctionalTester $I)
{
$I->wantTo('destroy a piggy bank');
$I->amOnPage('/piggy_banks/delete/1');
$I->see('Delete &quot;New camera&quot;');
$I->submitForm('#destroy', []);
$I->see('Piggy bank &quot;New camera&quot; deleted.');
}
/**
* @param FunctionalTester $I
*/
public function edit(FunctionalTester $I)
{
$I->wantTo('edit a piggy bank');
$I->amOnPage('/piggy_banks/edit/1');
$I->see('Edit piggy bank "New camera"');
}
/**
* @param FunctionalTester $I
*/
public function editWithTargetDate(FunctionalTester $I)
{
$I->wantTo('edit a piggy bank with a target date');
$I->amOnPage('/piggy_banks/edit/2');
$I->see('Edit piggy bank "New clothes"');
}
/**
* @param FunctionalTester $I
*/
public function index(FunctionalTester $I)
{
$I->wantTo('view all piggy banks');
$I->amOnPage('/piggy_banks');
$I->see('Piggy banks');
$I->see('New camera');
}
/**
* @param FunctionalTester $I
*/
public function postAdd(FunctionalTester $I)
{
$I->wantTo('process adding money to a piggy bank');
$I->amOnPage('/piggy_banks/add/1');
$I->see('Add money to New camera');
$I->submitForm('#add', ['amount' => 100]);
$I->see(',00 to &quot;New camera&quot;.');
}
/**
* @param FunctionalTester $I
*/
public function postAddTooMuch(FunctionalTester $I)
{
$I->wantTo('try to add too much money to a piggy bank');
$I->amOnPage('/piggy_banks/add/1');
$I->see('Add money to New camera');
$I->submitForm('#add', ['amount' => 100000]);
$I->see(',00 to &quot;New camera&quot;.');
}
/**
* @param FunctionalTester $I
*/
public function postRemove(FunctionalTester $I)
{
$I->wantTo('process removing money from a piggy bank');
$I->amOnPage('/piggy_banks/add/1');
$I->see('Add money to New camera');
$I->submitForm('#add', ['amount' => 100]);
$I->see(',00 to &quot;New camera&quot;.');
$I->amOnPage('/piggy_banks/remove/1');
$I->see('Remove money from New camera');
$I->submitForm('#remove', ['amount' => 50]);
$I->see(',00 from &quot;New camera&quot;.');
}
/**
* @param FunctionalTester $I
*/
public function postRemoveFail(FunctionalTester $I)
{
$I->wantTo('process removing too much money from a piggy bank');
$I->amOnPage('/piggy_banks/add/1');
$I->see('Add money to New camera');
$I->submitForm('#add', ['amount' => 100]);
$I->see(',00 to &quot;New camera&quot;.');
$I->amOnPage('/piggy_banks/remove/1');
$I->see('Remove money from New camera');
$I->submitForm('#remove', ['amount' => 500]);
$I->see(',00 from &quot;New camera&quot;.');
}
/**
* @param FunctionalTester $I
*/
public function remove(FunctionalTester $I)
{
$I->wantTo('removing money from a piggy bank');
$I->amOnPage('/piggy_banks/remove/1');
$I->see('Remove money from New camera');
}
/**
* @param FunctionalTester $I
*/
public function show(FunctionalTester $I)
{
$I->wantTo('view a piggy bank');
$I->amOnPage('/piggy_banks/show/1');
$I->see('New camera');
}
/**
* @param FunctionalTester $I
*/
public function store(FunctionalTester $I)
{
$I->wantTo('store a new piggy bank');
$I->amOnPage('/piggy_banks/create');
$I->see('Create new piggy bank');
$I->submitForm(
'#store', ['name' => 'Some new piggy bank',
'rep_every' => 0,
'reminder_skip' => 0,
'remind_me' => 0,
'order' => 3,
'account_id' => 1, 'targetamount' => 1000]
);
$I->see('Piggy bank &quot;Some new piggy bank&quot; stored.');
$I->seeRecord('piggy_banks', ['name' => 'Some new piggy bank']);
}
/**
* @param FunctionalTester $I
*/
public function storeValidate(FunctionalTester $I)
{
$I->wantTo('validate a new piggy bank');
$I->amOnPage('/piggy_banks/create');
$I->see('Create new piggy bank');
$I->submitForm(
'#store', ['name' => 'Some new piggy bank validated',
'rep_every' => 0,
'reminder_skip' => 0,
'remind_me' => 0,
'order' => 3,
'post_submit_action' => 'validate_only',
'account_id' => 1,
'targetamount' => 1000]
);
$I->see('OK');
$I->seeInSession('successes');
$I->dontSeeRecord('piggy_banks', ['name' => 'Some new piggy bank validated']);
}
/**
* @param FunctionalTester $I
*/
public function storeAndReturn(FunctionalTester $I)
{
$I->wantTo('store a new piggy bank and return');
$I->amOnPage('/piggy_banks/create');
$I->see('Create new piggy bank');
$I->submitForm(
'#store', ['name' => 'Some new piggy bank',
'rep_every' => 0,
'reminder_skip' => 0,
'post_submit_action' => 'create_another',
'remind_me' => 0,
'order' => 3,
'account_id' => 1,
'targetamount' => 1000]
);
$I->see('Piggy bank &quot;Some new piggy bank&quot; stored.');
}
/**
* @param FunctionalTester $I
*/
public function storeFail(FunctionalTester $I)
{
$I->wantTo('fail storing a new piggy bank');
$I->amOnPage('/piggy_banks/create');
$I->see('Create new piggy bank');
$I->submitForm(
'#store', ['name' => null,
'rep_every' => 0,
'reminder_skip' => 0,
'remind_me' => 0,
'order' => 3,
'account_id' => 1,
'post_submit_action' => 'store',
'targetamount' => 1000]
);
$I->see('The name field is required.');
}
/**
* @param FunctionalTester $I
*/
public function update(FunctionalTester $I)
{
$I->wantTo('update a piggy bank');
$I->amOnPage('/piggy_banks/edit/1');
$I->see('Edit piggy bank "New camera"');
$I->submitForm(
'#update', [
'name' => 'Updated camera',
'account_id' => 2,
'targetamount' => 2000,
'targetdate' => '',
'reminder' => 'week',
'post_submit_action' => 'update',
]
);
$I->see('Piggy bank &quot;Updated camera&quot; updated.');
}
/**
* @param FunctionalTester $I
*/
public function updateAndReturn(FunctionalTester $I)
{
$I->wantTo('update a piggy bank and return');
$I->amOnPage('/piggy_banks/edit/1');
$I->see('Edit piggy bank "New camera"');
$I->submitForm(
'#update', [
'name' => 'Updated camera',
'account_id' => 2,
'targetamount' => 2000,
'targetdate' => '',
'reminder' => 'week',
'post_submit_action' => 'return_to_edit',
]
);
$I->see('Piggy bank &quot;Updated camera&quot; updated.');
}
/**
* @param FunctionalTester $I
*/
public function updateFail(FunctionalTester $I)
{
$I->wantTo('update a piggy bank and fail');
$I->amOnPage('/piggy_banks/edit/1');
$I->see('Edit piggy bank "New camera"');
$I->submitForm(
'#update', [
'name' => '',
'account_id' => 2,
'targetamount' => 2000,
'targetdate' => '',
'reminder' => 'week',
'post_submit_action' => 'update',
]
);
$I->see('The name field is required.');
$I->seeInDatabase('piggy_banks', ['name' => 'New camera']);
}
/**
* @param FunctionalTester $I
*/
public function updateValidateOnly(FunctionalTester $I)
{
$I->wantTo('validate a piggy bank');
$I->amOnPage('/piggy_banks/edit/1');
$I->see('Edit piggy bank "New camera"');
$I->submitForm(
'#update', [
'name' => 'Updated camera',
'account_id' => 2,
'targetamount' => 2000,
'targetdate' => '',
'reminder' => 'week',
'post_submit_action' => 'validate_only',
]
);
$I->see('Updated camera');
}
}

View File

@ -0,0 +1,48 @@
<?php
/**
* Class PreferencesControllerCest
*
* @SuppressWarnings("CamelCase")
* @SuppressWarnings("short")
*
*/
class PreferencesControllerCest
{
/**
* @param FunctionalTester $I
*/
public function _after(FunctionalTester $I)
{
}
/**
* @param FunctionalTester $I
*/
public function _before(FunctionalTester $I)
{
$I->amLoggedAs(['email' => 'thegrumpydictator@gmail.com', 'password' => 'james']);
}
/**
* @param FunctionalTester $I
*/
public function index(FunctionalTester $I)
{
$I->wantTo('see my current set of preferences');
$I->amOnPage('/preferences');
$I->see('Preferences');
}
/**
* @param FunctionalTester $I
*/
public function postIndex(FunctionalTester $I)
{
$I->wantTo('want to update my preferences');
$I->amOnPage('/preferences');
$I->see('Preferences');
$I->submitForm('#preferences', []);
$I->see('Preferences saved!');
}
}

View File

@ -0,0 +1,150 @@
<?php
/**
* Class ProfileControllerCest
*
* @SuppressWarnings("CamelCase")
* @SuppressWarnings("short")
*/
class ProfileControllerCest
{
/**
* @param FunctionalTester $I
*/
public function _after(FunctionalTester $I)
{
}
/**
* @param FunctionalTester $I
*/
public function _before(FunctionalTester $I)
{
$I->amLoggedAs(['email' => 'thegrumpydictator@gmail.com', 'password' => 'james']);
}
/**
* @param FunctionalTester $I
*/
public function changePassword(FunctionalTester $I)
{
$I->wantTo('change my password.');
$I->amOnPage('/profile/change-password');
$I->see('thegrumpydictator@gmail.com');
$I->see('Change your password');
}
/**
* @param FunctionalTester $I
*/
public function index(FunctionalTester $I)
{
$I->wantTo('see my profile options');
$I->amOnPage('/profile');
$I->see('thegrumpydictator@gmail.com');
$I->see('Profile');
}
/**
* @param FunctionalTester $I
*/
public function postChangePassword(FunctionalTester $I)
{
$I->wantTo('submit a new password.');
$I->amOnPage('/profile/change-password');
$I->see('thegrumpydictator@gmail.com');
$I->see('Change your password');
$I->submitForm(
'#change-password', [
'old' => 'james',
'new1' => 'James',
'new2' => 'James'
]
);
$I->see('Password changed!');
}
/**
* @param FunctionalTester $I
*/
public function postChangePasswordInvalidCurrent(FunctionalTester $I)
{
$I->wantTo('submit a new password and enter the wrong current password.');
$I->amOnPage('/profile/change-password');
$I->see('thegrumpydictator@gmail.com');
$I->see('Change your password');
$I->submitForm(
'#change-password', [
'old' => 'Blablabla',
'new1' => 'James',
'new2' => 'James'
]
);
$I->see('Invalid current password!');
}
/**
* @param FunctionalTester $I
*/
public function postChangePasswordNoMatch(FunctionalTester $I)
{
$I->wantTo('submit a new password but make a mistake in filling it in twice.');
$I->amOnPage('/profile/change-password');
$I->see('thegrumpydictator@gmail.com');
$I->see('Change your password');
$I->submitForm(
'#change-password', [
'old' => 'james',
'new1' => 'blabla',
'new2' => 'bla'
]
);
$I->see('New passwords do not match!');
}
/**
* @param FunctionalTester $I
*/
public function postChangePasswordNoNewPassword(FunctionalTester $I)
{
$I->wantTo('submit a new password and forget to fill in a new one.');
$I->amOnPage('/profile/change-password');
$I->see('thegrumpydictator@gmail.com');
$I->see('Change your password');
$I->submitForm(
'#change-password', [
'old' => 'james',
'new1' => '',
'new2' => ''
]
);
$I->see('Do fill in a password!');
}
/**
* @param FunctionalTester $I
*/
public function postChangePasswordToSame(FunctionalTester $I)
{
$I->wantTo('submit a new password but fill in my old one twice.');
$I->amOnPage('/profile/change-password');
$I->see('thegrumpydictator@gmail.com');
$I->see('Change your password');
$I->submitForm(
'#change-password', [
'old' => 'james',
'new1' => 'james',
'new2' => 'james'
]
);
$I->see('The idea is to change your password.');
}
}

View File

@ -0,0 +1,99 @@
<?php
/**
* @SuppressWarnings("CamelCase")
* @SuppressWarnings("short")
*
* Class RelatedControllerCest
*/
class RelatedControllerCest
{
/**
* @param FunctionalTester $I
*/
public function _after(FunctionalTester $I)
{
}
/**
* @param FunctionalTester $I
*/
public function _before(FunctionalTester $I)
{
$I->amLoggedAs(['email' => 'thegrumpydictator@gmail.com', 'password' => 'james']);
}
public function alreadyRelated(FunctionalTester $I)
{
$group = TransactionGroup::first();
$journal = $group->transactionjournals()->first();
$I->wantTo('see already related transactions');
$I->amOnPage('/related/alreadyRelated/' . $journal->id);
$I->see('Big expense in ');
}
public function alreadyRelatedNoRelations(FunctionalTester $I)
{
$journal = TransactionJournal::first();
$I->wantTo('see already related transactions for a journal without any');
$I->amOnPage('/related/alreadyRelated/' . $journal->id);
$I->see('[]');
}
public function relate(FunctionalTester $I)
{
$journal = TransactionJournal::leftJoin(
'transaction_group_transaction_journal', 'transaction_journals.id', '=', 'transaction_group_transaction_journal.transaction_journal_id'
)
->whereNull('transaction_group_transaction_journal.transaction_group_id')->first(['transaction_journals.*']);
$otherJournal = TransactionJournal::leftJoin(
'transaction_group_transaction_journal', 'transaction_journals.id', '=', 'transaction_group_transaction_journal.transaction_journal_id'
)
->whereNull('transaction_group_transaction_journal.transaction_group_id')->where(
'transaction_journals.id', '!=', $journal->id
)->first(
['transaction_journals.*']
);
$I->wantTo('relate two journals');
$I->sendAjaxPostRequest('/related/relate/' . $journal->id . '/' . $otherJournal->id);
$I->see('true');
}
public function related(FunctionalTester $I)
{
$group = TransactionGroup::first();
$journal = $group->transactionjournals()->first();
$I->wantTo('see the popup with already related transactions');
$I->amOnPage('/related/related/' . $journal->id);
$I->see('Big expense in ');
}
public function removeRelation(FunctionalTester $I)
{
$group = TransactionGroup::first();
$one = $group->transactionjournals[0];
$two = $group->transactionjournals[1];
$I->wantTo('relate two journals');
$I->amOnPage('/related/removeRelation/' . $one->id . '/' . $two->id);
$I->see('true');
}
public function search(FunctionalTester $I)
{
$one = TransactionJournal::first();//$group = TransactionGroup::first();
//$one = $group->transactionjournals[0];
$I->wantTo('search for a transaction to relate');
$I->sendAjaxPostRequest('/related/search/' . $one->id . '?searchValue=expense');
$I->see('Big expense in');
}
}

View File

@ -0,0 +1,86 @@
<?php
/**
* Class ReminderControllerCest
*
* @SuppressWarnings("CamelCase")
* @SuppressWarnings("short")
*/
class ReminderControllerCest
{
/**
* @param FunctionalTester $I
*/
public function _after(FunctionalTester $I)
{
}
/**
* @param FunctionalTester $I
*/
public function _before(FunctionalTester $I)
{
$I->amLoggedAs(['email' => 'thegrumpydictator@gmail.com', 'password' => 'james']);
}
/**
* @param FunctionalTester $I
*/
public function act(FunctionalTester $I)
{
$reminder = Reminder::leftJoin('piggy_banks', 'piggy_banks.id', '=', 'reminders.remindersable_id')->where('piggy_banks.reminder','!=','')->first(
['reminders.*']
);
$I->wantTo('act on a reminder');
$I->amOnPage('/reminders/' . $reminder->id . '/act');
$I->see('Money for Nieuwe spullen');
}
/**
* @param FunctionalTester $I
*/
public function actOnInvalid(FunctionalTester $I)
{
$I->wantTo('act on an invalid reminder');
$I->amOnPage('/reminders/2/act');
$I->see('This reminder has an invalid class connected to it.');
}
/**
* @param FunctionalTester $I
*/
public function dismiss(FunctionalTester $I)
{
$I->wantTo('dismiss a reminder');
$I->amOnPage('/reminders/1/dismiss');
$I->see('Reminder dismissed');
}
/**
* @param FunctionalTester $I
*/
public function notNow(FunctionalTester $I)
{
$I->wantTo('ignore a reminder');
$I->amOnPage('/reminders/1/notNow');
$I->see('Reminder dismissed');
}
/**
* @param FunctionalTester $I
*/
public function show(FunctionalTester $I)
{
$reminder = Reminder::leftJoin('piggy_banks', 'piggy_banks.id', '=', 'reminders.remindersable_id')->where('piggy_banks.reminder','!=','')->first(
['reminders.*']
);
$I->wantTo('see a reminder');
$I->amOnPage('/reminders/'.$reminder->id);
$I->see('A reminder about');
$I->see('your piggy bank labelled "Nieuwe spullen"');
}
}

View File

@ -0,0 +1,298 @@
<?php
use Carbon\Carbon;
/**
* Class RepeatedExpenseControllerCest
*
* @SuppressWarnings("CamelCase")
* @SuppressWarnings("short")
*/
class RepeatedExpenseControllerCest
{
/**
* @param FunctionalTester $I
*/
public function _after(FunctionalTester $I)
{
}
/**
* @param FunctionalTester $I
*/
public function _before(FunctionalTester $I)
{
$I->amLoggedAs(['email' => 'thegrumpydictator@gmail.com', 'password' => 'james']);
}
/**
* @param FunctionalTester $I
*/
public function create(FunctionalTester $I)
{
$I->wantTo('create a repeated expense');
$I->amOnPage('/repeatedexpenses/create');
$I->see('Create new repeated expense');
}
/**
* @param FunctionalTester $I
*/
public function delete(FunctionalTester $I)
{
$repeatedExpense = PiggyBank::where('repeats', 1)->first();
$I->wantTo('delete a repeated expense');
$I->amOnPage('/repeatedexpenses/delete/' . $repeatedExpense->id);
$I->see('Delete "' . $repeatedExpense->name . '"');
}
/**
* @param FunctionalTester $I
*/
public function destroy(FunctionalTester $I)
{
$repeatedExpense = PiggyBank::where('repeats', 1)->first();
$I->wantTo('destroy a repeated expense');
$I->amOnPage('/repeatedexpenses/delete/' . $repeatedExpense->id);
$I->submitForm('#destroy', []);
$I->see('Repeated expense &quot;' . $repeatedExpense->name . '&quot; deleted.');
}
/**
* @param FunctionalTester $I
*/
public function edit(FunctionalTester $I)
{
$repeatedExpense = PiggyBank::where('repeats', 1)->first();
$I->wantTo('edit a repeated expense');
$I->amOnPage('/repeatedexpenses/edit/' . $repeatedExpense->id);
$I->see('Edit repeated expense "' . $repeatedExpense->name . '"');
}
/**
* @param FunctionalTester $I
*/
public function index(FunctionalTester $I)
{
$repeatedExpense = PiggyBank::where('repeats', 1)->first();
$I->wantTo('see all repeated expenses');
$I->amOnPage('/repeatedexpenses');
$I->see('Overview');
$I->see($repeatedExpense->name);
}
/**
* @param FunctionalTester $I
*/
public function show(FunctionalTester $I)
{
$repeatedExpense = PiggyBank::where('repeats', 1)->first();
$I->wantTo('view a repeated expense');
$I->amOnPage('/repeatedexpenses/show/' . $repeatedExpense->id);
$I->see($repeatedExpense->name);
}
/**
* @param FunctionalTester $I
*/
public function store(FunctionalTester $I)
{
$I->wantTo('store a repeated expense');
$I->amOnPage('/repeatedexpenses/create');
$I->submitForm(
'#store', [
'name' => 'TestRepeatedExpense',
'account_id' => 1,
'targetamount' => 1000,
'targetdate' => Carbon::now()->format('Y-m-d'),
'rep_length' => 'month',
'rep_every' => 0,
'rep_times' => 0,
'remind_me' => 1,
'reminder' => 'month',
'post_submit_action' => 'store',
]
);
$I->see('Piggy bank &quot;TestRepeatedExpense&quot; stored.');
}
/**
* @param FunctionalTester $I
*/
public function storeValidate(FunctionalTester $I)
{
$I->wantTo('validate a repeated expense');
$I->amOnPage('/repeatedexpenses/create');
$I->submitForm(
'#store', [
'name' => 'TestRepeatedExpenseXX',
'account_id' => 1,
'targetamount' => 1000,
'targetdate' => Carbon::now()->format('Y-m-d'),
'rep_length' => 'month',
'rep_every' => 0,
'rep_times' => 0,
'remind_me' => 1,
'reminder' => 'month',
'post_submit_action' => 'validate_only',
]
);
$I->see('TestRepeatedExpenseXX');
$I->see('OK');
$I->seeInSession('successes');
}
/**
* @param FunctionalTester $I
*/
public function storeAndReturn(FunctionalTester $I)
{
$I->wantTo('store a repeated expense and return');
$I->amOnPage('/repeatedexpenses/create');
$I->submitForm(
'#store', [
'name' => 'TestRepeatedExpense',
'account_id' => 1,
'targetamount' => 1000,
'targetdate' => Carbon::now()->format('Y-m-d'),
'rep_length' => 'month',
'rep_every' => 0,
'rep_times' => 0,
'remind_me' => 1,
'reminder' => 'month',
'post_submit_action' => 'create_another',
]
);
$I->see('Piggy bank &quot;TestRepeatedExpense&quot; stored.');
}
/**
* @param FunctionalTester $I
*/
public function storeFail(FunctionalTester $I)
{
$I->wantTo('store a repeated expense and fail');
$I->amOnPage('/repeatedexpenses/create');
$I->submitForm(
'#store', [
'name' => '',
'account_id' => 1,
'targetamount' => 1000,
'targetdate' => Carbon::now()->format('Y-m-d'),
'rep_length' => 'month',
'rep_every' => 0,
'rep_times' => 0,
'remind_me' => 1,
'reminder' => 'month',
'post_submit_action' => 'store',
]
);
$I->see('Could not store repeated expense: The name field is required.');
}
/**
* @param FunctionalTester $I
*/
public function update(FunctionalTester $I)
{
$repeatedExpense = PiggyBank::where('repeats', 1)->first();
$I->wantTo('update a repeated expense');
$I->amOnPage('/repeatedexpenses/edit/' . $repeatedExpense->id);
$I->submitForm(
'#update', [
'name' => $repeatedExpense->name . '!',
'account_id' => 2,
'targetamount' => 1000.00,
'targetdate' => $repeatedExpense->targetdate->format('Y-m-d'),
'rep_length' => 'month',
'rep_every' => 0,
'rep_times' => 0,
'remind_me' => 1,
'reminder' => 'month',
'post_submit_action' => 'update',
]
);
$I->see('Repeated expense &quot;' . $repeatedExpense->name . '!&quot; updated.');
}
/**
* @param FunctionalTester $I
*/
public function updateValidate(FunctionalTester $I)
{
$repeatedExpense = PiggyBank::where('repeats', 1)->first();
$I->wantTo('validate an updated repeated expense');
$I->amOnPage('/repeatedexpenses/edit/' . $repeatedExpense->id);
$I->submitForm(
'#update', [
'name' => $repeatedExpense->name . 'ABCD',
'account_id' => 2,
'targetamount' => 1000.00,
'targetdate' => $repeatedExpense->targetdate->format('Y-m-d'),
'rep_length' => 'month',
'rep_every' => 0,
'rep_times' => 0,
'remind_me' => 1,
'reminder' => 'month',
'post_submit_action' => 'validate_only',
]
);
$I->see($repeatedExpense->name . 'ABCD');
$I->see('OK');
$I->seeInSession('successes');
}
/**
* @param FunctionalTester $I
*/
public function updateAndReturnToEdit(FunctionalTester $I)
{
$repeatedExpense = PiggyBank::where('repeats', 1)->first();
$I->wantTo('update a repeated expense and return to edit screen');
$I->amOnPage('/repeatedexpenses/edit/' . $repeatedExpense->id);
$I->submitForm(
'#update', [
'name' => $repeatedExpense->name . '!',
'account_id' => 2,
'targetamount' => 1000.00,
'targetdate' => $repeatedExpense->targetdate->format('Y-m-d'),
'rep_length' => 'month',
'rep_every' => 0,
'rep_times' => 0,
'remind_me' => 1,
'reminder' => 'month',
'post_submit_action' => 'return_to_edit',
]
);
$I->see('Repeated expense &quot;' . $repeatedExpense->name . '!&quot; updated.');
}
/**
* @param FunctionalTester $I
*/
public function updateFail(FunctionalTester $I)
{
$repeatedExpense = PiggyBank::where('repeats', 1)->first();
$I->wantTo('try to update a repeated expense and fail');
$I->amOnPage('/repeatedexpenses/edit/' . $repeatedExpense->id);
$I->submitForm(
'#update', [
'name' => '',
'account_id' => 2,
'targetamount' => 1000.00,
'targetdate' => '2014-12-30',
'rep_length' => 'month',
'rep_every' => 0,
'rep_times' => 0,
'remind_me' => 1,
'reminder' => 'month',
'post_submit_action' => 'update',
]
);
$I->see('The name field is required.');
}
}

View File

@ -0,0 +1,79 @@
<?php
/**
* Class ReportControllerCest
*
* @SuppressWarnings("CamelCase")
* @SuppressWarnings("short")
*
*/
class ReportControllerCest
{
/**
* @param FunctionalTester $I
*/
public function _after(FunctionalTester $I)
{
}
/**
* @param FunctionalTester $I
*/
public function _before(FunctionalTester $I)
{
$I->amLoggedAs(['email' => 'thegrumpydictator@gmail.com', 'password' => 'james']);
}
public function budget(FunctionalTester $I)
{
$I->wantTo('see a budget report');
$I->amOnPage('/reports/budget/2014/9');
$I->see('Budget report for September 2014');
}
public function budgetInvalidDate(FunctionalTester $I)
{
$I->wantTo('see a budget report for an invalid date');
$I->amOnPage('/reports/budget/XXXX/XX');
$I->see('Invalid date');
}
public function index(FunctionalTester $I)
{
$I->wantTo('see all possible reports');
$I->amOnPage('/reports');
$I->see('Reports');
$I->see('Monthly reports');
$I->see('Budget reports');
}
public function month(FunctionalTester $I)
{
$I->wantTo('see a monthly report');
$I->amOnPage('/reports/2014/9');
$I->see('Report for September 2014');
}
public function monthInvalidDate(FunctionalTester $I)
{
$I->wantTo('see a monthly report for an invalid month');
$I->amOnPage('/reports/XXXX/XX');
$I->see('Invalid date');
}
public function year(FunctionalTester $I)
{
$I->wantTo('see a yearly report');
$I->amOnPage('/reports/2014');
$I->see('Income vs. expenses');
$I->see('Account balance');
}
public function yearInvalidDate(FunctionalTester $I)
{
$I->wantTo('see a yearly report for an invalid year');
$I->amOnPage('/reports/XXXX');
$I->see('Invalid date');
}
}

View File

@ -0,0 +1,39 @@
<?php
/**
* Class SearchControllerCest
*/
class SearchControllerCest
{
/**
* @param FunctionalTester $I
*/
public function _after(FunctionalTester $I)
{
}
/**
* @param FunctionalTester $I
*/
public function _before(FunctionalTester $I)
{
$I->amLoggedAs(['email' => 'thegrumpydictator@gmail.com', 'password' => 'james']);
}
public function index(FunctionalTester $I)
{
$I->wantTo('search for "salary"');
$I->amOnPage('/search?q=salary');
$I->see('Transactions');
$I->see('Results for "salary"');
}
public function indexNoQuery(FunctionalTester $I)
{
$I->wantTo('Search for empty string');
$I->amOnPage('/search?q=');
$I->see('Search for &quot;&quot;');
}
}

View File

@ -0,0 +1,356 @@
<?php
/**
* Class TransactionControllerCest
*/
class TransactionControllerCest
{
/**
* @param FunctionalTester $I
*/
public function _after(FunctionalTester $I)
{
}
/**
* @param FunctionalTester $I
*/
public function _before(FunctionalTester $I)
{
$I->amLoggedAs(['email' => 'thegrumpydictator@gmail.com', 'password' => 'james']);
}
public function create(FunctionalTester $I)
{
$I->wantTo('create a transaction');
$I->amOnPage('/transactions/create/withdrawal?account_id=1');
$I->see('Add a new withdrawal');
}
public function deleteWithdrawal(FunctionalTester $I)
{
// get withdrawal transaction type id:
$type = TransactionType::whereType('Withdrawal')->first();
// get a journal
$journal = TransactionJournal::where('transaction_type_id', $type->id)->first();
$I->wantTo('delete a transaction');
$I->amOnPage('/transaction/delete/' . $journal->id);
$I->see('Delete withdrawal "' . $journal->description . '"');
}
public function destroyDeposit(FunctionalTester $I)
{
// get withdrawal transaction type id:
$type = TransactionType::whereType('Deposit')->first();
// get a journal
$journal = TransactionJournal::where('transaction_type_id', $type->id)->first();
$I->wantTo('destroy a deposit');
$I->amOnPage('/transaction/delete/' . $journal->id);
$I->submitForm('#destroy', []);
$I->see('Transaction &quot;' . $journal->description . '&quot; destroyed.');
}
public function destroyTransfer(FunctionalTester $I)
{
// get withdrawal transaction type id:
$type = TransactionType::whereType('Transfer')->first();
// get a journal
$journal = TransactionJournal::where('transaction_type_id', $type->id)->first();
$I->wantTo('destroy a transfer');
$I->amOnPage('/transaction/delete/' . $journal->id);
$I->submitForm('#destroy', []);
$I->see('Transaction &quot;' . $journal->description . '&quot; destroyed.');
}
public function destroyTransferWithEvent(FunctionalTester $I)
{
// get withdrawal transaction type id:
$row = DB::table('piggy_bank_events')->whereNotNull('transaction_journal_id')->first();
$journalId = $row->transaction_journal_id;
$journal = TransactionJournal::find($journalId);
$I->wantTo('destroy a transfer connected to a piggy bank');
$I->amOnPage('/transaction/delete/' . $journal->id);
$I->submitForm('#destroy', []);
$I->see('Transaction &quot;' . $journal->description . '&quot; destroyed.');
}
public function destroyWithdrawal(FunctionalTester $I)
{
// get withdrawal transaction type id:
$type = TransactionType::whereType('Withdrawal')->first();
// get a journal
$journal = TransactionJournal::where('transaction_type_id', $type->id)->first();
$I->wantTo('destroy a withdrawal');
$I->amOnPage('/transaction/delete/' . $journal->id);
$I->submitForm('#destroy', []);
$I->see('Transaction &quot;' . $journal->description . '&quot; destroyed.');
}
public function edit(FunctionalTester $I)
{
// get withdrawal transaction type id:
$type = TransactionType::whereType('Transfer')->first();
// get a journal
$journal = TransactionJournal::where('transaction_type_id', $type->id)->first();
$I->wantTo('edit a transaction');
$I->amOnPage('/transaction/edit/' . $journal->id);
$I->see('Edit transfer &quot;' . $journal->description . '&quot;');
}
public function index(FunctionalTester $I)
{
$I->wantTo('see all withdrawals');
$I->amOnPage('/transactions/withdrawal');
$I->see('Expenses');
}
public function indexExpenses(FunctionalTester $I)
{
$I->wantTo('see all expenses');
$I->amOnPage('/transactions/deposit');
$I->see('Revenue, income and deposits');
}
public function indexTransfers(FunctionalTester $I)
{
$I->wantTo('see all transfers');
$I->amOnPage('/transactions/transfers');
$I->see('Transfers');
}
public function show(FunctionalTester $I)
{
// get withdrawal transaction type id:
$type = TransactionType::whereType('Withdrawal')->first();
// get a journal
$journal = TransactionJournal::where('transaction_type_id', $type->id)->first();
$I->wantTo('see a transaction');
$I->amOnPage('/transaction/show/' . $journal->id);
$I->see($journal->description);
$I->see(intval($journal->getAmount()));
}
/**
* @param FunctionalTester $I
*/
public function showGroupedJournal(FunctionalTester $I)
{
$groupRow = DB::table('transaction_group_transaction_journal')->select('transaction_journal_id')->first(['transaction_journal_id']);
$id = $groupRow->transaction_journal_id;
// get a grouped journal:
$journal = TransactionJournal::find($id);
$I->wantTo('see a grouped transaction');
$I->amOnPage('/transaction/show/' . $journal->id);
$I->see($journal->description);
}
public function store(FunctionalTester $I)
{
$I->wantTo('store a transaction');
$I->amOnPage('/transactions/create/withdrawal');
$I->submitForm(
'#store', [
'reminder' => '',
'description' => 'Test',
'account_id' => 1,
'expense_account' => 'Zomaar',
'amount' => 100,
'date' => '2014-12-30',
'budget_id' => 3,
'category' => 'Categorrr',
'post_submit_action' => 'store'
]
);
$I->see('Transaction &quot;Test&quot; stored.');
}
public function storeAndFail(FunctionalTester $I)
{
$I->wantTo('store a transaction and fail');
$I->amOnPage('/transactions/create/withdrawal');
$I->submitForm(
'#store', [
'reminder' => '',
'description' => '',
'account_id' => 1,
'expense_account' => 'Zomaar',
'amount' => 100,
'date' => '2014-12-30',
'budget_id' => 3,
'category' => 'Categorrr',
'post_submit_action' => 'store'
]
);
$I->see('Could not store transaction: The description field is required.');
}
public function storeAndReturn(FunctionalTester $I)
{
$I->wantTo('store a transaction');
$I->amOnPage('/transactions/create/withdrawal');
$I->submitForm(
'#store', [
'reminder' => '',
'description' => 'Test',
'account_id' => 1,
'expense_account' => 'Zomaar',
'amount' => 100,
'date' => '2014-12-30',
'budget_id' => 3,
'category' => 'Categorrr',
'post_submit_action' => 'create_another'
]
);
$I->see('Transaction &quot;Test&quot; stored.');
}
public function storeValidate(FunctionalTester $I)
{
$I->wantTo('validate a transaction');
$I->amOnPage('/transactions/create/withdrawal');
$I->submitForm(
'#store', [
'reminder' => '',
'description' => 'TestValidateMe',
'account_id' => 1,
'expense_account' => 'Zomaar',
'amount' => 100,
'date' => '2014-12-30',
'budget_id' => 3,
'category' => 'CategorrXXXXr',
'post_submit_action' => 'validate_only'
]
);
$I->see('OK');
$I->seeInSession('successes');
$I->dontSeeRecord('transaction_journals', ['description' => 'TestValidateMe']);
}
public function update(FunctionalTester $I)
{
// get withdrawal transaction type id:
$type = TransactionType::whereType('Deposit')->first();
// get a journal
$journal = TransactionJournal::where('transaction_type_id', $type->id)->first();
$I->wantTo('update a transaction');
$I->amOnPage('/transaction/edit/' . $journal->id);
$I->see($journal->description);
$I->submitForm(
'#update', [
'description' => $journal->description . '!',
'account_id' => 1,
'expense_account' => 'Portaal',
'amount' => 500,
'date' => $journal->date->format('Y-m-d'),
'budget_id' => is_null($journal->budgets()->first()) ? 0 : $journal->budgets()->first()->id,
'category' => is_null($journal->categories()->first()) ? '' : $journal->categories()->first()->id,
'post_submit_action' => 'update'
]
);
$I->see($journal->description . '!');
}
public function updateAndFail(FunctionalTester $I)
{
// get withdrawal transaction type id:
$type = TransactionType::whereType('Deposit')->first();
// get a journal
$journal = TransactionJournal::where('transaction_type_id', $type->id)->first();
$I->wantTo('update a transaction and fail');
$I->amOnPage('/transaction/edit/' . $journal->id);
$I->see($journal->description);
$I->submitForm(
'#update', [
'description' => '',
'account_id' => 1,
'expense_account' => 'Portaal',
'amount' => 500,
'date' => '2014-01-01',
'budget_id' => 2,
'category' => 'House',
'post_submit_action' => 'update'
]
);
$I->see('Could not update transaction: The description field is required.');
}
public function updateAndReturn(FunctionalTester $I)
{
// get withdrawal transaction type id:
$type = TransactionType::whereType('Deposit')->first();
// get a journal
$journal = TransactionJournal::where('transaction_type_id', $type->id)->first();
$I->wantTo('update a transaction and return to the edit screen');
$I->amOnPage('/transaction/edit/' . $journal->id);
$I->see($journal->description);
$I->submitForm(
'#update', [
'description' => $journal->description . '!',
'account_id' => 1,
'expense_account' => 'Portaal',
'amount' => 500,
'date' => $journal->date->format('Y-m-d'),
'budget_id' => is_null($journal->budgets()->first()) ? 0 : $journal->budgets()->first()->id,
'category' => is_null($journal->categories()->first()) ? '' : $journal->categories()->first()->id,
'post_submit_action' => 'return_to_edit'
]
);
$I->see($journal->description . '!');
}
public function updateValidate(FunctionalTester $I)
{
// get withdrawal transaction type id:
$type = TransactionType::whereType('Deposit')->first();
// get a journal
$journal = TransactionJournal::where('transaction_type_id', $type->id)->first();
$I->wantTo('validate an updated transaction');
$I->amOnPage('/transaction/edit/' . $journal->id);
$I->see($journal->description);
$I->submitForm(
'#update', [
'description' => $journal->description . 'XYZ',
'account_id' => 1,
'expense_account' => 'Portaal',
'amount' => 500,
'date' => $journal->date->format('Y-m-d'),
'budget_id' => is_null($journal->budgets()->first()) ? 0 : $journal->budgets()->first()->id,
'category' => is_null($journal->categories()->first()) ? '' : $journal->categories()->first()->id,
'post_submit_action' => 'validate_only'
]
);
$I->see($journal->description . 'XYZ');
$I->see('OK');
$I->seeInSession('successes');
}
}

View File

@ -0,0 +1,150 @@
<?php
/**
* Class UserControllerCest
*
* @SuppressWarnings("CamelCase")
* @SuppressWarnings("short")
*/
class UserControllerCest
{
/**
* @param FunctionalTester $I
*/
public function _after(FunctionalTester $I)
{
}
/**
* @param FunctionalTester $I
*/
public function _before(FunctionalTester $I)
{
}
/**
* @param FunctionalTester $I
*/
public function login(FunctionalTester $I)
{
$I->wantTo('login');
$I->amOnPage('/login');
$I->see('Sign In');
$I->submitForm('#login', ['email' => 'functional@example.com', 'password' => 'functional']);
$I->see('functional@example.com');
}
/**
* @param FunctionalTester $I
*/
public function loginFails(FunctionalTester $I)
{
$I->wantTo('fail the login');
$I->amOnPage('/login');
$I->see('Sign In');
$I->submitForm('#login', ['email' => 'functional@example.com', 'password' => 'wrong']);
$I->see('No good');
}
/**
* @param FunctionalTester $I
*/
public function logout(FunctionalTester $I)
{
$I->amLoggedAs(['email' => 'thegrumpydictator@gmail.com', 'password' => 'james']);
$I->wantTo('logout');
$I->amOnPage('/');
$I->click('Logout');
$I->see('Firefly III &mdash; Sign In');
}
/**
* @param FunctionalTester $I
*/
public function postRegister(FunctionalTester $I)
{
$I->wantTo('post-register a new account');
$I->amOnPage('/register');
$I->submitForm('#register', ['email' => 'noreply@gmail.com']);
$I->see('You\'re about to get an e-mail. Please follow its instructions.');
$I->seeRecord('users', ['email' => 'noreply@gmail.com']);
}
/**
* @param FunctionalTester $I
*/
public function postRegisterFail(FunctionalTester $I)
{
$I->wantTo('post-register a new account and fail');
$I->amOnPage('/register');
$I->submitForm('#register', ['email' => 'XXxxxxx']);
$I->see('Input invalid, please try again: The email must be a valid email address.');
$I->dontseeRecord('users', ['email' => 'XXxxxxx']);
}
/**
* @param FunctionalTester $I
*/
public function postRemindme(FunctionalTester $I)
{
$I->wantTo('get a password reminder');
$I->amOnRoute('remindMe');
$I->submitForm('#remindMe', ['email' => 'functional@example.com']);
$I->see('You\'re about to get an e-mail.');
}
/**
* @param FunctionalTester $I
*/
public function postRemindmeFail(FunctionalTester $I)
{
$I->wantTo('get a password reminder and fail');
$I->amOnRoute('remindMe');
$I->submitForm('#remindMe', ['email' => 'abcdee']);
$I->see('No good!');
}
/**
* @param FunctionalTester $I
*/
public function register(FunctionalTester $I)
{
$I->wantTo('register a new account');
$I->amOnRoute('register');
}
/**
* @param FunctionalTester $I
*/
public function remindMe(FunctionalTester $I)
{
$I->wantTo('reminded of my password');
$I->amOnRoute('remindMe');
$I->see('Firefly III &mdash; Reset your password');
}
/**
* @param FunctionalTester $I
*/
public function resetFail(FunctionalTester $I)
{
$I->wantTo('reset my password and fail');
$I->amOnPage('/reset/123');
$I->see('No reset code found!');
}
/**
* @param FunctionalTester $I
*/
public function reset(FunctionalTester $I)
{
$I->wantTo('reset my password');
$I->amOnPage('/reset/okokokokokokokokokokokokokokokok');
$I->see('You\'re about to get an e-mail.');
}
}

View File

@ -0,0 +1,8 @@
<?php
$db = realpath(__DIR__ . '/../_data') . '/db.sqlite';
if (!file_exists($db)) {
$out = [];
exec('touch ' . $db);
exec('php artisan migrate --seed --env=testing', $out);
exec('sqlite3 tests/_data/db.sqlite .dump > tests/_data/dump.sql', $out);
}

6
tests/unit.suite.yml Normal file
View File

@ -0,0 +1,6 @@
# Codeception Test Suite Configuration
# suite for unit (internal) tests.
class_name: UnitTester
modules:
enabled: [Asserts, UnitHelper]

View File

@ -0,0 +1,40 @@
<?php
use League\FactoryMuffin\Facade as f;
/**
* Class AccountTest
*/
class AccountTest extends TestCase
{
public function setUp()
{
parent::setUp();
}
public function tearDown()
{
parent::tearDown();
}
// tests
public function testAccountMeta()
{
$account = f::create('Account');
$newMeta = $account->updateMeta('field', 'value');
$this->assertInstanceOf('AccountMeta', $newMeta);
$secondMeta = $account->updateMeta('field', 'newValue');
$this->assertEquals($newMeta->id, $secondMeta->id);
$this->assertEquals($newMeta->data, 'value');
$this->assertEquals($secondMeta->data, 'newValue');
}
public function testAccountUser()
{
$account = f::create('Account');
$this->assertInstanceOf('Account', $account);
$this->assertInstanceOf('User', $account->user);
}
}

View File

@ -0,0 +1,27 @@
<?php
use League\FactoryMuffin\Facade as f;
/**
* Class AccountTypeTest
*/
class AccountTypeTest extends TestCase
{
public function setUp()
{
parent::setUp();
}
public function tearDown()
{
parent::tearDown();
}
// tests
public function testAccounts()
{
$account = f::create('Account');
$this->assertCount(1, $account->accountType()->first()->accounts()->get());
}
}

26
tests/unit/BudgetTest.php Normal file
View File

@ -0,0 +1,26 @@
<?php
use League\FactoryMuffin\Facade as f;
/**
* Class BudgetTest
*/
class BudgetTest extends TestCase
{
public function setUp()
{
parent::setUp();
}
public function tearDown()
{
parent::tearDown();
}
public function testUser()
{
$budget = f::create('Budget');
$this->assertInstanceOf('User', $budget->user);
}
}

View File

@ -0,0 +1,29 @@
<?php
use League\FactoryMuffin\Facade as f;
/**
* Class PiggyBankRepetitionTest
*/
class PiggyBankRepetitionTest extends TestCase
{
public function setUp()
{
parent::setUp();
}
public function tearDown()
{
parent::tearDown();
}
public function testPiggyBankRepetitionScope()
{
$repetition = f::create('PiggyBankRepetition');
$start = clone $repetition->startdate;
$target = clone $repetition->targetdate;
$this->assertCount(1, PiggyBankRepetition::starts($start)->get());
$this->assertCount(1, PiggyBankRepetition::targets($target)->get());
}
}

View File

@ -0,0 +1,27 @@
<?php
use League\FactoryMuffin\Facade as f;
/**
* Class PiggyBankTest
*/
class PiggyBankTest extends TestCase
{
public function setUp()
{
parent::setUp();
}
public function tearDown()
{
parent::tearDown();
}
public function testPiggyBankReminders()
{
$reminder = f::create('Reminder');
$piggyBank = f::create('PiggyBank');
$piggyBank->reminders()->save($reminder);
$this->assertCount(1, $piggyBank->reminders()->get());
}
}

View File

@ -0,0 +1,38 @@
<?php
use League\FactoryMuffin\Facade as f;
/**
* Class ReminderTest
*/
class ReminderTest extends TestCase
{
public function setUp()
{
parent::setUp();
}
public function tearDown()
{
parent::tearDown();
}
public function testDateIs()
{
$reminder = f::create('Reminder');
$start = clone $reminder->startdate;
$end = clone $reminder->enddate;
$this->assertCount(1, Reminder::dateIs($start, $end)->get());
}
public function testUser()
{
$user = f::create('User');
$reminder = f::create('Reminder');
$reminder->user_id = $user->id;
$reminder->save();
$this->assertEquals($reminder->user->id, $user->id);
}
}

View File

@ -0,0 +1,25 @@
<?php
use League\FactoryMuffin\Facade as f;
/**
* Class TransactionGroupTest
*/
class TransactionGroupTest extends TestCase
{
public function setUp()
{
parent::setUp();
}
public function tearDown()
{
parent::tearDown();
}
public function testUser()
{
$group = f::create('TransactionGroup');
$this->assertEquals($group->user_id, $group->user->id);
}
}

View File

@ -0,0 +1,33 @@
<?php
use League\FactoryMuffin\Facade as f;
/**
* Class TransactionJournalTest
*/
class TransactionJournalTest extends TestCase
{
public function setUp()
{
parent::setUp();
}
public function tearDown()
{
parent::tearDown();
}
public function testMorethan()
{
$journal = f::create('TransactionJournal');
$transaction = f::create('Transaction');
$other = clone $transaction;
$journal->transactions()->save($transaction);
$journal->transactions()->save($other);
$amount = floatval($transaction->amount);
$amount--;
$this->assertCount(1, TransactionJournal::moreThan($amount)->get());
}
}

View File

@ -0,0 +1,67 @@
<?php
use League\FactoryMuffin\Facade as f;
/**
* Class TransactionTest
*/
class TransactionTest extends TestCase
{
public function setUp()
{
parent::setUp();
}
public function tearDown()
{
parent::tearDown();
}
public function testAccount()
{
$transaction = f::create('Transaction');
$this->assertCount(1, Transaction::accountIs($transaction->account)->get());
}
public function testDateAfter()
{
$transaction = f::create('Transaction');
$date = clone $transaction->transactionJournal->date;
$date->subDay();
$this->assertCount(1, Transaction::after($date)->get());
}
public function testDateBefore()
{
$transaction = f::create('Transaction');
$date = clone $transaction->transactionJournal->date;
$date->addDay();
$this->assertCount(1, Transaction::before($date)->get());
}
public function testLessThan()
{
$transaction = f::create('Transaction');
$amount = floatval($transaction->amount);
$amount++;
$this->assertCount(1, Transaction::lessThan($amount)->get());
}
public function testMoreThan()
{
$transaction = f::create('Transaction');
$amount = floatval($transaction->amount);
$amount--;
$this->assertCount(1, Transaction::moreThan($amount)->get());
}
public function testTransactionTypes()
{
$transaction = f::create('Transaction');
$type = $transaction->transactionJournal->transactionType->type;
$this->assertCount(1, Transaction::transactionTypes([$type])->get());
}
}

View File

@ -0,0 +1,30 @@
<?php
use League\FactoryMuffin\Facade as f;
/**
* Class TransactionTypeTest
*/
class TransactionTypeTest extends TestCase
{
public function setUp()
{
parent::setUp();
}
public function tearDown()
{
parent::tearDown();
}
// tests
public function testJournals()
{
$journal = f::create('TransactionJournal');
$type = $journal->transactionType;
$this->assertCount(1, $type->transactionJournals()->get());
}
}

36
tests/unit/UserTest.php Normal file
View File

@ -0,0 +1,36 @@
<?php
use League\FactoryMuffin\Facade as f;
/**
* Class AccountTest
*/
class UserTest extends TestCase
{
public function setUp()
{
parent::setUp();
}
public function tearDown()
{
parent::tearDown();
}
// tests
public function testPreference()
{
$pref = f::create('Preference');
$this->assertEquals($pref->user_id, $pref->user->id);
$this->assertCount(1, $pref->user->preferences()->get());
}
public function testReminder()
{
$reminder = f::create('Reminder');
$this->assertEquals($reminder->user_id, $reminder->user->id);
$this->assertCount(1, $reminder->user->reminders()->get());
}
}

View File

@ -0,0 +1,2 @@
<?php
// Here you can initialize variables that will be available to your tests