Skip to content

Commit

Permalink
Update tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
yunosh committed Sep 6, 2017
1 parent eb93c1a commit 6fd808e
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 58 deletions.
2 changes: 1 addition & 1 deletion test/Wicked/Autoload.php
Expand Up @@ -19,7 +19,7 @@
*/

Horde_Test_Autoload::addPrefix('Wicked', __DIR__ . '/../../lib');
Horde_Test_Autoload::addPrefix('Text/Wiki/Render/Rst', __DIR__ . '/../../lib/Text_Wiki/Render/Rst');
Horde_Test_Autoload::addPrefix('Text_Wiki', __DIR__ . '/../../lib/Text_Wiki');

/** Load the basic test definition */
require_once __DIR__ . '/TestCase.php';
10 changes: 8 additions & 2 deletions test/Wicked/TestCase.php
Expand Up @@ -28,8 +28,14 @@
* @link http://www.horde.org/apps/wicked
* @license http://www.horde.org/licenses/gpl GNU General Public License, version 2
*/
class Wicked_TestCase extends PHPUnit_Framework_TestCase
class Wicked_TestCase extends Horde_Test_Case
{
public function setUp()
{
$text_wiki = __DIR__ . '/../../lib/Text_Wiki';
set_include_path($text_wiki . PATH_SEPARATOR . get_include_path());
}

protected function unstrictPearTestingMode()
{
$this->_old_errorreporting = error_reporting(E_ALL & ~(E_STRICT | E_DEPRECATED));
Expand All @@ -50,4 +56,4 @@ protected function protectAgainstPearError($result)
}
return $result;
}
}
}
97 changes: 42 additions & 55 deletions test/Wicked/Unit/RstTest.php
Expand Up @@ -30,103 +30,98 @@
*/
class Wicked_Unit_RstTest extends Wicked_TestCase
{
public function setUp()
protected function _getWiki()
{
$this->markTestIncomplete();
$this->unstrictPearTestingMode();
}

public function tearDown()
{
$this->revertTestingMode();
$wiki = new Text_Wiki_Default();
$wiki->insertRule('Heading2', 'Heading');
$wiki->deleteRule('Heading');
$wiki->loadParseObj('Paragraph');
$skip = $wiki->parseObj['Paragraph']->getConf('skip');
$skip[] = 'heading2';
$wiki->setParseConf('Paragraph', 'skip', $skip);
$wiki->insertRule('Toc2', 'Toc');
$wiki->deleteRule('Toc');
return $wiki;
}

public function testEmpty()
{
$wiki = new Text_Wiki_Default();
$this->assertEquals(
'',
$this->protectAgainstPearError($wiki->transform('', 'Rst'))
$this->protectAgainstPearError($this->_getWiki()->transform('', 'Rst'))
);
}

public function testHeaderOne()
{
$wiki = new Text_Wiki_Default();
$this->assertEquals(
'=========
HEADER
=========
'========
HEADER
========
',
$this->protectAgainstPearError($wiki->transform('+ HEADER', 'Rst'))
$this->protectAgainstPearError($this->_getWiki()->transform('+ HEADER', 'Rst'))
);
}

public function testHeaderTwo()
{
$wiki = new Text_Wiki_Default();
$this->assertEquals(
'--------
HEADER
--------
',
$this->protectAgainstPearError($wiki->transform('++HEADER', 'Rst'))
$this->protectAgainstPearError($this->_getWiki()->transform('++HEADER', 'Rst'))
);
}

public function testHeaderThree()
{
$wiki = new Text_Wiki_Default();
$this->assertEquals(
'HEADER
======
',
$this->protectAgainstPearError($wiki->transform('+++HEADER', 'Rst'))
$this->protectAgainstPearError($this->_getWiki()->transform('+++HEADER', 'Rst'))
);
}

public function testHeaderFour()
{
$wiki = new Text_Wiki_Default();
$this->assertEquals(
'HEADER
******
',
$this->protectAgainstPearError($wiki->transform('++++HEADER', 'Rst'))
$this->protectAgainstPearError($this->_getWiki()->transform('++++HEADER', 'Rst'))
);
}

public function testHeaderFive()
{
$wiki = new Text_Wiki_Default();
$this->assertEquals(
'HEADER
------
',
$this->protectAgainstPearError($wiki->transform('+++++HEADER', 'Rst'))
$this->protectAgainstPearError($this->_getWiki()->transform('+++++HEADER', 'Rst'))
);
}

public function testHeaderSix()
{
$wiki = new Text_Wiki_Default();
$this->assertEquals(
'HEADER
``````
',
$this->protectAgainstPearError($wiki->transform('++++++HEADER', 'Rst'))
$this->protectAgainstPearError($this->_getWiki()->transform('++++++HEADER', 'Rst'))
);
}

public function testToc()
{
$wiki = new Text_Wiki_Default();
$this->assertEquals(
'.. contents:: Contents
.. section-numbering::
Expand All @@ -146,7 +141,7 @@ public function testToc()
``
',
$this->protectAgainstPearError($wiki->transform('
$this->protectAgainstPearError($this->_getWiki()->transform('
[[toc]]
+H
Expand All @@ -161,14 +156,13 @@ public function testToc()

public function testPlainUrl()
{
$wiki = new Text_Wiki_Default();
$this->assertEquals(
'Further information on Horde and the latest version can be obtained at
`` ``http://www.horde.org/apps/horde
',
$this->protectAgainstPearError($wiki->transform('Further information on Horde and the latest version can be obtained at
$this->protectAgainstPearError($this->_getWiki()->transform('Further information on Horde and the latest version can be obtained at
{{ }}http://www.horde.org/apps/horde
Expand All @@ -178,13 +172,12 @@ public function testPlainUrl()

public function testPlainEmbeddedUrl()
{
$wiki = new Text_Wiki_Default();
$this->assertEquals(
'There
is a list of Horde applications and projects at http://www.horde.org/apps.
',
$this->protectAgainstPearError($wiki->transform('There
$this->protectAgainstPearError($this->_getWiki()->transform('There
is a list of Horde applications and projects at http://www.horde.org/apps.
', 'Rst'))
Expand All @@ -193,32 +186,29 @@ public function testPlainEmbeddedUrl()

public function testNamedUrl()
{
$wiki = new Text_Wiki_Default();
$this->assertEquals(
'certification mark of the `Open Source Initiative`_.
.. _`Open Source Initiative`: http://www.opensource.org/
',
$this->protectAgainstPearError($wiki->transform('certification mark of the [http://www.opensource.org/ Open Source Initiative].
$this->protectAgainstPearError($this->_getWiki()->transform('certification mark of the [http://www.opensource.org/ Open Source Initiative].
', 'Rst'))
);
}

public function testLiteral()
{
$wiki = new Text_Wiki_Default();
$this->assertEquals(
'in the ``docs/`` directory
',
$this->protectAgainstPearError($wiki->transform('in the ``docs/`` directory', 'Rst'))
$this->protectAgainstPearError($this->_getWiki()->transform('in the ``docs/`` directory', 'Rst'))
);
}

public function testFreelink()
{
$wiki = new Text_Wiki_Default();
$this->assertEquals(
'The following documentation is available in the Horde distribution:
Expand All @@ -229,7 +219,7 @@ public function testFreelink()
.. _`COPYING`: http://www.horde.org/licenses/lgpl
.. _`docs/CHANGES`: CHANGES',
$this->protectAgainstPearError($wiki->transform('The following documentation is available in the Horde distribution:
$this->protectAgainstPearError($this->_getWiki()->transform('The following documentation is available in the Horde distribution:
: [http://www.horde.org/licenses/lgpl COPYING] : Copyright and license information
: ((CHANGES|docs/CHANGES)) : Changes by release
Expand All @@ -239,14 +229,13 @@ public function testFreelink()

public function testCode()
{
$wiki = new Text_Wiki_Default();
$this->assertEquals(
'::
test
',
$this->protectAgainstPearError($wiki->transform('
$this->protectAgainstPearError($this->_getWiki()->transform('
<code>
test
</code>
Expand All @@ -256,24 +245,22 @@ public function testCode()

public function testBold()
{
$wiki = new Text_Wiki_Default();
$this->assertEquals(
'**bold**
',
$this->protectAgainstPearError($wiki->transform("'''bold'''", 'Rst'))
$this->protectAgainstPearError($this->_getWiki()->transform("'''bold'''", 'Rst'))
);
}

public function testDeflist()
{
$wiki = new Text_Wiki_Default();
$this->assertEquals(
':The term: A definition
:Another term: Another definition
',
$this->protectAgainstPearError($wiki->transform('
$this->protectAgainstPearError($this->_getWiki()->transform('
: The term : A definition
: Another term : Another definition
', 'Rst'))
Expand All @@ -282,14 +269,13 @@ public function testDeflist()

public function testLongDeflist()
{
$wiki = new Text_Wiki_Default();
$this->assertEquals(
':The term: A long long long long long long long long long long long long
long definition
:Another term: Another definition
',
$this->protectAgainstPearError($wiki->transform('
$this->protectAgainstPearError($this->_getWiki()->transform('
: The term : A long long long long long long long long long long long long long definition
: Another term : Another definition
', 'Rst'))
Expand All @@ -298,12 +284,12 @@ public function testLongDeflist()

public function testBulletlist()
{
$wiki = new Text_Wiki_Default();
$this->assertEquals(
'* A
* B
',
$this->protectAgainstPearError($wiki->transform('
$this->protectAgainstPearError($this->_getWiki()->transform('
* A
* B
', 'Rst'))
Expand All @@ -312,12 +298,13 @@ public function testBulletlist()

public function testTwoLevelBulletlist()
{
$wiki = new Text_Wiki_Default();
$this->assertEquals(
'* A
* B
',
$this->protectAgainstPearError($wiki->transform('
$this->protectAgainstPearError($this->_getWiki()->transform('
* A
* B
', 'Rst'))
Expand All @@ -326,12 +313,12 @@ public function testTwoLevelBulletlist()

public function testNumberedList()
{
$wiki = new Text_Wiki_Default();
$this->assertEquals(
'1. A
2. B
',
$this->protectAgainstPearError($wiki->transform('
$this->protectAgainstPearError($this->_getWiki()->transform('
# A
# B
', 'Rst'))
Expand All @@ -340,12 +327,13 @@ public function testNumberedList()

public function testTwoLevelNumberedList()
{
$wiki = new Text_Wiki_Default();
$this->assertEquals(
'1. A
1. B
',
$this->protectAgainstPearError($wiki->transform('
$this->protectAgainstPearError($this->_getWiki()->transform('
# A
# B
', 'Rst'))
Expand All @@ -355,11 +343,10 @@ public function testTwoLevelNumberedList()
public function testFixtureCliModular()
{
$fixture = __DIR__ . '/../fixtures/cli_modular';
$wiki = new Text_Wiki_Default();
$this->assertEquals(
file_get_contents($fixture . '.rst'),
$this->protectAgainstPearError(
$wiki->transform(file_get_contents($fixture . '.wiki'), 'Rst')
$this->_getWiki()->transform(file_get_contents($fixture . '.wiki'), 'Rst')
)
);
}
Expand Down

0 comments on commit 6fd808e

Please sign in to comment.