Some tests.

This commit is contained in:
James Cole 2016-01-17 15:48:18 +01:00
parent 68cdfd00b0
commit e6db49c20c
5 changed files with 142 additions and 0 deletions

View File

@ -73,6 +73,10 @@ class Range
Session::put('first', Carbon::now()->startOfYear()); Session::put('first', Carbon::now()->startOfYear());
} }
} }
// check "sum of everything".
$current = Carbon::now()->formatLocalized('%B %Y'); $current = Carbon::now()->formatLocalized('%B %Y');
$next = Carbon::now()->endOfMonth()->addDay()->formatLocalized('%B %Y'); $next = Carbon::now()->endOfMonth()->addDay()->formatLocalized('%B %Y');
$prev = Carbon::now()->startOfMonth()->subDay()->formatLocalized('%B %Y'); $prev = Carbon::now()->startOfMonth()->subDay()->formatLocalized('%B %Y');

46
cover.sh Executable file
View File

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

41
phpunit.cover.xml Executable file
View File

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

35
phpunit.default.xml Executable file
View File

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

View File

@ -17,6 +17,7 @@ class HomeControllerTest extends TestCase
$args = [ $args = [
'start' => '2012-01-01', 'start' => '2012-01-01',
'end' => '2012-04-01', 'end' => '2012-04-01',
'_token' => Session::token(),
]; ];
// if date range is > 50, should have flash. // 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.'); $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());
}
} }