Skip to content
This repository was archived by the owner on Apr 17, 2019. It is now read-only.

Commit a1b398a

Browse files
committed
Full code coverage with new testing tools
1 parent 10d57a9 commit a1b398a

6 files changed

Lines changed: 47 additions & 11 deletions

File tree

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"stack/builder": "*"
1717
},
1818
"require-dev": {
19-
"satooshi/php-coveralls": "*"
19+
"satooshi/php-coveralls": "*",
20+
"phpunit/phpunit": "4.2"
2021
},
2122
"autoload": {
2223
"psr-4": {

conf/defaults.ini

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
;This is your default config file which is always included
2+
;Environment specific config files will be included after to override these defaults
3+
14
[kernel]
25
default = \Skeleton\Project
36

@@ -7,4 +10,3 @@ gzip = false
710
[dispatch]
811
run_on = path
912
run_match = assets
10-
aliases[src] = src/res

conf/testing.ini

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
;This is the configuration file used when running unit tests
2+
3+
[test]
4+
username = test
5+
password = test

phpunit.xml.dist

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,20 @@
99
processIsolation="false"
1010
stopOnFailure="false"
1111
syntaxCheck="false"
12-
bootstrap="vendor/autoload.php"
12+
bootstrap="./vendor/cubex/framework/testing/bootstrap.php"
1313
>
1414
<testsuites>
15-
<testsuite name="Cubex Test Suite">
15+
<testsuite name="Project Test Suite">
1616
<directory>./tests</directory>
1717
</testsuite>
1818
</testsuites>
19+
<filter>
20+
<whitelist>
21+
<directory suffix=".php">src</directory>
22+
</whitelist>
23+
<blacklist>
24+
<directory suffix=".php">vendor</directory>
25+
<directory suffix=".php">tests</directory>
26+
</blacklist>
27+
</filter>
1928
</phpunit>

src/Project.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public function getRoutes()
1515
return [
1616
'hello/world' => 'hello', //Run the renderHello method
1717
'google' => 'http://www.google.com', //Redirect to url
18-
'hi' => '#@hello/world', //Redirect to hello/world
18+
'hi' => '#@/hello/world', //Redirect to hello/world
1919
];
2020
}
2121

tests/ProjectTest.php

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,35 @@
11
<?php
2+
namespace Tests;
23

3-
class ProjectTest extends PHPUnit_Framework_TestCase
4+
use Cubex\Testing\CubexTestCase;
5+
6+
class ProjectTest extends CubexTestCase
47
{
58
public function testProjectIsCubexKernel()
69
{
7-
$cubex = new \Cubex\Cubex(__DIR__);
8-
$cubex->prepareCubex();
9-
$cubex->processConfiguration($cubex->getConfiguration());
10-
1110
$this->assertInstanceOf(
1211
'\Cubex\Kernel\CubexKernel',
13-
$cubex->make('\Cubex\Kernel\CubexKernel')
12+
$this->getCubex()->make('\Cubex\Kernel\CubexKernel')
1413
);
1514
}
15+
16+
public function testDefaultAction()
17+
{
18+
$this->getResponse('/');
19+
$this->assertResponseContains('Welcome to Cubex');
20+
$this->assertResponseOk();
21+
$this->assertReturnsCubexResponse();
22+
}
23+
24+
public function testHello()
25+
{
26+
$this->getResponse('/hello');
27+
$this->assertResponseContains('Hello World');
28+
}
29+
30+
public function testHi()
31+
{
32+
$this->getResponse('/hi');
33+
$this->assertRedirectedTo('/hello/world');
34+
}
1635
}

0 commit comments

Comments
 (0)