Skip to content

Commit

Permalink
- renamed examples/tests to examples/input
Browse files Browse the repository at this point in the history
- debugged tests/ExampleTest.php
- added instructions for running unit tests to doc/ConfigManually.md
  • Loading branch information
metaclass-nl committed Nov 16, 2013
1 parent 3d79f5d commit b44c1ab
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 20 deletions.
7 changes: 7 additions & 0 deletions doc/ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
v0.5
- renamed examples/tests to examples/input
- Added output of examples to the repository
- Added tests folder with phpunit.xml and bootstrap.php for testing with PHPUnit
- Addes tests/ExapleTest.php that compares the actual output of the examples with the output from the repository
- Added instructions for running unit tests to doc/ConfigManually.md

v0.4
-----------------
- introduced name spaces fitshelf, chat and PHPFIT_TypeAdapter
Expand Down
27 changes: 20 additions & 7 deletions doc/ConfigManually.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
TO INSTALL AND RUN EXAMPLES
===========================

1. You need a http server with PHP 5.3.2 or higher. For security reasons it should only be accessable
1. You need a HTTP server with PHP 5.3.2 or higher. For security reasons it should only be accessable
to you and those who need to run tests.

2. Download or fetch PhpFit from https://github.com/metaclass-nl/phpfit
Expand All @@ -10,9 +10,9 @@ TO INSTALL AND RUN EXAMPLES

4. Download or fetch Fit Shelf from https://github.com/metaclass-nl/fit-shelf

5. Extract and/or upload the shelf subfolder from the fit_shelf folder to a folder on your http server
5. Extract and/or upload the shelf subfolder from the fit_shelf folder to a folder on your HTTP server

6. Edit the examples/config/config.php file in the folder you copied in step 5 and correct the include paths
6. Edit the examples/config/config.php file on your server and correct the include paths
with respect to the location of phpfit on your server.

7. If necessary create a file with the name from $fitConfig->output and make it writable for the run-web.php script.
Expand All @@ -37,14 +37,14 @@ TO RUN YOUR OWN TESTS

2. Upload you own Fixture files to your fixtures folder

3. Eventually make aditional folders for the application classes you want to test and add it to $fitConfig->nameSpacedMap
3. Eventually make aditional folders for the application classes you want to test and add them to $fitConfig->nameSpacedMap
or to the include path.

4. Eventually upload the application classes.

5. Make your own tests folder and add it to $fitConfig->exampleDirs.
5. Make your own input folder and add it to $fitConfig->exampleDirs.

6. Upload your own test to your tests folder.
6. Upload your own tests to your input folder.

5. Enter the url in your browser to index.php from the examples folder on your http server.

Expand All @@ -58,4 +58,17 @@ You may explicitly include_once your own type adapters from anywhere,

or you may add your own type adapters to the src/PHPFIT/TypeAdapters so that the ClassLoader will autoload them,

or you may use Composer, see the [fit-skeleton package](https://github.com/metaclass-nl/fit-skeleton).
or you may use Composer, see the [fit-skeleton package](https://github.com/metaclass-nl/fit-skeleton).


TO RUN THE UNIT TESTS
=====================
- Install PHPUnit
- if you did not already do so, Edit the examples/config/config.php file in the examples/config folder and
perform step 7 from "TO INSTALL AND RUN EXAMPLES" above.
- on the CLI, cd to the tests folder
- run phpunit

(on windows you can choose your PHP version with something like:
C:\php551\php.exe C:\xampp\php\phpunit
but PEAR with phpunit must be in the include path of the php version used)
2 changes: 1 addition & 1 deletion examples/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

$fitConfig = new StdClass();

$fitConfig->exampleDirs["Fit Shelf"] = "tests";
$fitConfig->exampleDirs["Fit Shelf"] = "input";
$fitConfig->exampleDirs["PHPFIT"] = "../../phpfit/examples/input";
//add your own input folders here

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion examples/run-cli.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
//usage: php run-cli.php tests/Fig1TestDisconnect.html
//usage: php run-cli.php input/Fig1TestDisconnect.html
require_once 'config/config.php';

require_once '../src/fitshelf/ClassLoader.php';
Expand Down
9 changes: 4 additions & 5 deletions tests/ExampleTest.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<?php
$GLOBALS['SIMPLE_SUMMARY'] = 1;

class ExampleTest extends UnitTestCase {
class ExampleTest extends PHPUnit_Framework_TestCase {
public $mustFilename;
public $isFilename;
public $runFilename;

public function setUp() {
$this->isFilename = "../examples/output.html";
global $fitConfig;
$this->isFilename = $fitConfig->output;
}

public function tearDown() {
Expand All @@ -16,7 +17,7 @@ public function tearDown() {
$must = str_replace("\r\n", "\n", file_get_contents($this->mustFilename, true));
$is = str_replace("\r\n", "\n", file_get_contents($this->isFilename, true));

$this->assertEqual($is, $must);
$this->assertEquals($is, $must);
}

public function testFig1TestDisconnect() {
Expand All @@ -41,6 +42,4 @@ public function testFig4TestDiscountGroupsSetUp() {

}

//unset($GLOBALS['SIMPLE_SUMMARY']);

?>
16 changes: 10 additions & 6 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
<?php
require_once '../examples/config/config.php';

require_once '../src/fitshelf/ClassLoader.php';
require_once 'PHPFIT.php';

$loader = new fitshelf\ClassLoader();
$loader->setSpaceMap($fitConfig->nameSpacedMap);
$loader->registerAutoLoad();
if (!class_exists('PHPFIT')) {
$fitConfig->nameSpacedMap[''] = '../examples/src';
$fitConfig->output = '../examples/'. $fitConfig->output;

require_once '../src/fitshelf/ClassLoader.php';
require_once 'PHPFIT.php';

$loader = new fitshelf\ClassLoader();
$loader->setSpaceMap($fitConfig->nameSpacedMap);
$loader->registerAutoLoad();
}

?>

0 comments on commit b44c1ab

Please sign in to comment.