Permalink
Browse files

set up phpunit

  • Loading branch information...
1 parent c3b2038 commit e8c3f07d2b84c72b9763c02d4a2fb866f3e6fb58 @hjue committed Jan 24, 2015
Showing with 54 additions and 0 deletions.
  1. +3 −0 .travis.yml
  2. +32 −0 phpunit.xml
  3. +19 −0 tests/CITest.php
View
@@ -6,3 +6,6 @@ php:
- 5.5
- 5.6
+script:
+ - phpunit #default test command
+ - phpunit -c phpunit.xml #custom test command to make sure CLI args don't break the test
View
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<phpunit
+ colors="true"
+ stopOnFailure="false"
+ backupGlobals="false"
+ backupStaticAttributes="false"
+ convertErrorsToExceptions="true"
+ convertNoticesToExceptions="true"
+ convertWarningsToExceptions="true"
+ processIsolation="false"
+ syntaxCheck="false"
+ cacheTokens="true"
+ verbose="false"
+ bootstrap="tests/bootstrap.php">
+ <testsuites>
+ <testsuite name="Justwriting Test Suite">
+ <directory>./tests/</directory>
+ </testsuite>
+ </testsuites>
+ <php>
+ <const name="PHPUNIT_TEST" value="1" />
+ <const name="PHPUNIT_CHARSET" value="UTF-8" />
+ <server name="REMOTE_ADDR" value="0.0.0.0" />
+ <server name="HTTP_HOST" value="localhost" />
+ </php>
+ <filter>
+ <whitelist>
+ <directory>./system/</directory>
+ </whitelist>
+ </filter>
+</phpunit>
View
@@ -0,0 +1,19 @@
+<?php
+
+ class CITest extends PHPUnit_Framework_TestCase
+ {
+ private $CI;
+
+ public function setUp()
+ {
+ // Load CI instance normally
+ $this->CI = &get_instance();
+ }
+
+ public function testGetPost()
+ {
+ $_SERVER['REQUEST_METHOD'] = 'GET';
+ $_GET['foo'] = 'bar';
+ $this->assertEquals('bar', $this->CI->input->get_post('foo'));
+ }
+ }

0 comments on commit e8c3f07

Please sign in to comment.