Permalink
Browse files

Run fixtures using PHPunit.

  • Loading branch information...
1 parent 0227d01 commit 2d22111e084c437b9f7983f108e8b647695ae5aa @gocom gocom committed Oct 23, 2013
Showing with 64 additions and 3 deletions.
  1. +2 −0 .travis.yml
  2. +2 −1 composer.json
  3. +53 −2 test/Netcarver/Textile/Test/BasicTest.php
  4. +7 −0 test/bootstrap.php
View
@@ -1,4 +1,6 @@
language: php
php:
- 5.5
+before_script:
+ - composer install
script: phpunit --configuration phpunit.xml
View
@@ -15,7 +15,8 @@
"php": ">=5.3.0"
},
"require-dev": {
- "phpunit/phpunit": "3.7.*"
+ "phpunit/phpunit": "3.7.*",
+ "symfony/yaml": "2.3.*"
},
"extra": {
"branch-alias": {
@@ -1,11 +1,62 @@
<?php
namespace Netcarver\Textile\Test;
+use Symfony\Component\Yaml\Yaml;
class BasicTest extends \PHPUnit_Framework_TestCase
{
- public function testExample()
+ /**
+ * @dataProvider provider
+ */
+
+ public function testAdd($expect, $input, $name)
+ {
+ $this->assertEquals($expect, $input, 'In section: '.$name);
+ }
+
+ public function provider()
{
- $this->assertTrue(true);
+ chdir(dirname(dirname(dirname(__DIR__))));
+
+ $yaml = Yaml::parse('basic.yaml');
+
+ foreach ($yaml as $name => $test) {
+ if (!isset($test['input']) || !isset($test['expect'])) {
+ continue;
+ }
+
+ if (isset($test['assert']) && $test['assert'] === 'skip') {
+ continue;
+ }
+
+ $textile = new \Netcarver\Textile\Parser();
+
+ if (isset($test['setup'][0]))
+ {
+ foreach ($test['setup'][0] as $method => $value)
+ {
+ $textile->$method($value);
+ }
+ }
+
+ $expect = rtrim($test['expect']);
+ $input = $textile->textileThis($test['input']);
+
+ foreach (array('expect', 'input') as $variable)
+ {
+ $$variable = preg_replace(
+ array(
+ '/ id="(fn|note)[a-z0-9]*"/',
+ '/ href="#(fn|note)[a-z0-9]*"/',
+ ),
+ '',
+ $$variable
+ );
+ }
+
+ $out[] = array($expect, $input, $name);
+ }
+
+ return $out;
}
}
View
@@ -2,6 +2,13 @@
error_reporting(E_ALL);
+/*
include dirname(__DIR__) . '/src/Netcarver/Textile/Parser.php';
include dirname(__DIR__) . '/src/Netcarver/Textile/DataBag.php';
include dirname(__DIR__) . '/src/Netcarver/Textile/Tag.php';
+*/
+
+include dirname(__DIR__) . '/vendor/autoload.php';
+$loader = new \Composer\Autoload\ClassLoader();
+$loader->add('Netcarver\\Textile\\Test\\', __DIR__);
+$loader->register();

0 comments on commit 2d22111

Please sign in to comment.