Skip to content

Firefly III: a personal finances manager

Some tests.

James Colee6db49c20cd1
diff --git a/app/Http/Middleware/Range.php b/app/Http/Middleware/Range.php
index a4b6ead33d..36155e56d3 100644
--- a/app/Http/Middleware/Range.php
+++ b/app/Http/Middleware/Range.php
@@ -73,6 +73,10 @@ class Range
Session::put('first', Carbon::now()->startOfYear());
}
}
+
+ // check "sum of everything".
+
+
$current = Carbon::now()->formatLocalized('%B %Y');
$next = Carbon::now()->endOfMonth()->addDay()->formatLocalized('%B %Y');
$prev = Carbon::now()->startOfMonth()->subDay()->formatLocalized('%B %Y');
diff --git a/cover.sh b/cover.sh
new file mode 100755
index 0000000000..4311932be6
--- /dev/null
+++ b/cover.sh
@@ -0,0 +1,46 @@
+#!/bin/bash
+
+# set testing environment
+cp .env.testing .env
+
+# set cover:
+cp phpunit.cover.xml phpunit.xml
+
+# test!
+if [ -z "$1" ]
+then
+ phpdbg -qrr /usr/local/bin/phpunit
+fi
+
+# directories to look in:
+#dirs=("controllers" "database" "factories" "generators" "helpers" "models" "middleware" "repositories" "support")
+#
+#if [ ! -z "$1" ]
+#then
+# for i in "${dirs[@]}"
+# do
+# firstFile="./tests/$i/$1.php"
+# secondFile="./tests/$i/$1Test.php"
+# if [ -f "$firstFile" ]
+# then
+# # run it!
+# phpunit --verbose $firstFile
+# exit $?
+# fi
+# if [ -f "$secondFile" ]
+# then
+# # run it!
+# phpunit --verbose $secondFile
+# exit $?
+# fi
+#
+#
+# done
+#
+#fi
+
+# restore .env file
+cp .env.local .env
+
+# restore cover
+cp phpunit.default.xml phpunit.xml
\ No newline at end of file
diff --git a/phpunit.cover.xml b/phpunit.cover.xml
new file mode 100755
index 0000000000..05acf49856
--- /dev/null
+++ b/phpunit.cover.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ phpunit.cover.xml
+ ~ Copyright (C) 2016 Sander Dorigo
+ ~
+ ~ This software may be modified and distributed under the terms
+ ~ of the MIT license. See the LICENSE file for details.
+ -->
+
+<phpunit backupGlobals="false"
+ backupStaticAttributes="false"
+ bootstrap="bootstrap/autoload.php"
+ colors="true"
+ convertErrorsToExceptions="true"
+ convertNoticesToExceptions="true"
+ convertWarningsToExceptions="true"
+ processIsolation="false"
+ stopOnFailure="false">
+ <testsuites>
+ <testsuite name="Application Test Suite">
+ <directory>./tests/</directory>
+ </testsuite>
+ </testsuites>
+ <filter>
+ <whitelist>
+ <directory suffix=".php">app/</directory>
+ </whitelist>
+ </filter>
+ <!--
+ Code coverage has never been slower.
+ -->
+ <logging>
+ <log type="coverage-clover" target="./storage/build/clover.xml" charset="UTF-8" />
+ </logging>
+ <php>
+ <env name="APP_ENV" value="testing"/>
+ <env name="CACHE_DRIVER" value="array"/>
+ <env name="SESSION_DRIVER" value="array"/>
+ <env name="QUEUE_DRIVER" value="sync"/>
+ </php>
+</phpunit>
diff --git a/phpunit.default.xml b/phpunit.default.xml
new file mode 100755
index 0000000000..04f27f97f4
--- /dev/null
+++ b/phpunit.default.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<phpunit backupGlobals="false"
+ backupStaticAttributes="false"
+ bootstrap="bootstrap/autoload.php"
+ colors="true"
+ convertErrorsToExceptions="true"
+ convertNoticesToExceptions="true"
+ convertWarningsToExceptions="true"
+ processIsolation="false"
+ stopOnFailure="false">
+ <testsuites>
+ <testsuite name="Application Test Suite">
+ <directory>./tests/</directory>
+ </testsuite>
+ </testsuites>
+ <filter>
+ <whitelist>
+ <directory suffix=".php">app/</directory>
+ </whitelist>
+ </filter>
+ <!--
+ Code coverage has never been slower.
+ -->
+ <!--
+ <logging>
+ <log type="coverage-clover" target="./storage/build/clover.xml" charset="UTF-8" />
+ </logging>
+ -->
+ <php>
+ <env name="APP_ENV" value="testing"/>
+ <env name="CACHE_DRIVER" value="array"/>
+ <env name="SESSION_DRIVER" value="array"/>
+ <env name="QUEUE_DRIVER" value="sync"/>
+ </php>
+</phpunit>
diff --git a/tests/acceptance/Controllers/HomeControllerTest.php b/tests/acceptance/Controllers/HomeControllerTest.php
index 23d725bb8e..804a9371ad 100644
--- a/tests/acceptance/Controllers/HomeControllerTest.php
+++ b/tests/acceptance/Controllers/HomeControllerTest.php
@@ -17,6 +17,7 @@ class HomeControllerTest extends TestCase
$args = [
'start' => '2012-01-01',
'end' => '2012-04-01',
+ '_token' => Session::token(),
];
// if date range is > 50, should have flash.
@@ -25,4 +26,19 @@ class HomeControllerTest extends TestCase
$this->assertSessionHas('warning', '91 days of data may take a while to load.');
}
+ public function testFlush()
+ {
+ $this->be($this->user());
+ $response = $this->call('GET', '/flush');
+ $this->assertEquals(302, $response->status());
+ }
+
+ public function testIndex()
+ {
+ $this->be($this->user());
+ $response = $this->call('GET', '/');
+ $this->assertEquals(200, $response->status());
+ }
+
+
}
\ No newline at end of file