svn: /pear/packages/Text_Wiki/trunk/ Text/Wiki/Render/Tiki/Image.php tests/Text_Wiki_Parse_Mediawiki_Tests.php tests/Text_Wiki_Render_Tiki_Tests.php
tests/fixtures/mediawiki_syntax.txt
| From: | Rodrigo Sampaio Primo | Date: | Sun, 02 Aug 2009 12:09:44 +0000 |
| Subject: | svn: /pear/packages/Text_Wiki/trunk/ Text/Wiki/Render/Tiki/Image.php tests/Text_Wiki_Parse_Mediawiki_Tests.php tests/Text_Wiki_Render_Tiki_Tests.php tests/fixtures/mediawiki_syntax.txt |
||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-56830@lists.php.net to get a copy of this message | ||
rodrigosprimo Sun, 02 Aug 2009 12:09:44 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=286660
Log:
Add prefix option for the configuration of the Tiki Image Render
Tests for the basic syntax of Mediawiki Table Parser
Changed paths:
U pear/packages/Text_Wiki/trunk/Text/Wiki/Render/Tiki/Image.php
U pear/packages/Text_Wiki/trunk/tests/Text_Wiki_Parse_Mediawiki_Tests.php
U pear/packages/Text_Wiki/trunk/tests/Text_Wiki_Render_Tiki_Tests.php
U pear/packages/Text_Wiki/trunk/tests/fixtures/mediawiki_syntax.txt
Modified: pear/packages/Text_Wiki/trunk/Text/Wiki/Render/Tiki/Image.php
===================================================================
--- pear/packages/Text_Wiki/trunk/Text/Wiki/Render/Tiki/Image.php 2009-08-02 11:51:56 UTC (rev
286659)
+++ pear/packages/Text_Wiki/trunk/Text/Wiki/Render/Tiki/Image.php 2009-08-02 12:09:44 UTC (rev
286660)
@@ -2,6 +2,15 @@
class Text_Wiki_Render_Tiki_Image extends Text_Wiki_Render {
/**
+ * Defines rule specific configuration
+ *
+ * @var array
+ */
+ var $conf = array(
+ 'prefix' => 'img/wiki_up/' // path to the wiki image directory
+ );
+
+ /**
*
* Renders a token into text matching the requested format.
*
@@ -16,10 +25,14 @@
function token($options)
{
- $img = '{img src=' . $options['src'];
+ $img = '{img src="';
+ if (!empty($this->conf['prefix']))
+ $img .= $this->conf['prefix'];
+ $img .= $options['src'] . '"';
+
if (is_array($options['attr'])) {
foreach ($options['attr'] as $var => $val) {
- $img .= ' '.$var.'='.$val;
+ $img .= ' '.$var.'="'.$val.'"';
}
}
$img .= '}';
Modified: pear/packages/Text_Wiki/trunk/tests/Text_Wiki_Parse_Mediawiki_Tests.php
===================================================================
--- pear/packages/Text_Wiki/trunk/tests/Text_Wiki_Parse_Mediawiki_Tests.php 2009-08-02 11:51:56 UTC
(rev 286659)
+++ pear/packages/Text_Wiki/trunk/tests/Text_Wiki_Parse_Mediawiki_Tests.php 2009-08-02 12:09:44 UTC
(rev 286660)
@@ -37,14 +37,14 @@
$suite->addTestSuite('Text_Wiki_Parse_Mediawiki_Heading_Test');
$suite->addTestSuite('Text_Wiki_Parse_Mediawiki_Horiz_Test');
$suite->addTestSuite('Text_Wiki_Parse_Mediawiki_List_Test');
- /*$suite->addTestSuite('Text_Wiki_Parse_Mediawiki_Newline_Test');*/
+ //$suite->addTestSuite('Text_Wiki_Parse_Mediawiki_Newline_Test');
$suite->addTestSuite('Text_Wiki_Parse_Mediawiki_Preformatted_Test');
$suite->addTestSuite('Text_Wiki_Parse_Mediawiki_Raw_Test');
$suite->addTestSuite('Text_Wiki_Parse_Mediawiki_Redirect_Test');
/*$suite->addTestSuite('Text_Wiki_Parse_Mediawiki_Subscript_Test');
- $suite->addTestSuite('Text_Wiki_Parse_Mediawiki_Superscript_Test');
+ $suite->addTestSuite('Text_Wiki_Parse_Mediawiki_Superscript_Test');*/
$suite->addTestSuite('Text_Wiki_Parse_Mediawiki_Table_Test');
- $suite->addTestSuite('Text_Wiki_Parse_Mediawiki_Tt_Test');*/
+ //$suite->addTestSuite('Text_Wiki_Parse_Mediawiki_Tt_Test');
$suite->addTestSuite('Text_Wiki_Parse_Mediawiki_Url_Test');
$suite->addTestSuite('Text_Wiki_Parse_Mediawiki_Wikilink_Test');
@@ -556,6 +556,79 @@
}
+class Text_Wiki_Parse_Mediawiki_Table_Test extends Text_Wiki_Parse_Mediawiki_SetUp_Tests
+{
+
+ public function testMediawikiParseTableProcess()
+ {
+
+ $matches = array(
+ 0 => '{|
+| A || B
+|-
+| C || D
+|}',
+ 1 => '
+',
+ 2 => '',
+ 3 => '| A || B
+|-
+| C || D
+'
+ );
+
+ $this->assertRegExp("/\d+?\d+?\d+? A \d+?\d+? B\d+?\d+?\d+?\d+? C
\d+?\d+? D \d+?\d+?\d+?/", $this->t->process($matches));
+
+ $tokens = array(
+ 487 => array(0 => 'Table', 1 => array('type' =>
'cell_start', 'attr' => '', 'span' => 1,
'rowspan' => 1, 'order' => 0)),
+ 488 => array(0 => 'Table', 1 => array('type' =>
'cell_end', 'attr' => '', 'span' => 1,
'rowspan' => 1, 'order' => 0)),
+ 489 => array(0 => 'Table', 1 => array('type' =>
'cell_start', 'attr' => '', 'span' => 1,
'rowspan' => 1, 'order' => 1)),
+ 490 => array(0 => 'Table', 1 => array('type' =>
'cell_end', 'attr' => '', 'span' => 1,
'rowspan' => 1, 'order' => 1)),
+ 491 => array(0 => 'Table', 1 => array('type' =>
'row_start', 'order' => 0, 'cols' => 2)),
+ 492 => array(0 => 'Table', 1 => array('type' =>
'row_end', 'order' => 0, 'cols' => 2)),
+ 493 => array(0 => 'Table', 1 => array('type' =>
'cell_start', 'attr' => '', 'span' => 1,
'rowspan' => 1, 'order' => 0)),
+ 494 => array(0 => 'Table', 1 => array('type' =>
'cell_end', 'attr' => '', 'span' => 1,
'rowspan' => 1, 'order' => 0)),
+ 495 => array(0 => 'Table', 1 => array('type' =>
'cell_start', 'attr' => '', 'span' => 1,
'rowspan' => 1, 'order' => 1)),
+ 496 => array(0 => 'Table', 1 => array('type' =>
'cell_end', 'attr' => '', 'span' => 1,
'rowspan' => 1, 'order' => 1)),
+ 497 => array(0 => 'Table', 1 => array('type' =>
'row_start', 'order' => 1, 'cols' => 2)),
+ 498 => array(0 => 'Table', 1 => array('type' =>
'row_end', 'order' => 1, 'cols' => 2)),
+ 499 => array(0 => 'Table', 1 => array('type' =>
'table_start', 'level' => 0, 'rows' => 2, 'cols' =>
2)),
+ 500 => array(0 => 'Table', 1 => array('type' =>
'table_end', 'level' => 0, 'rows' => 2, 'cols' =>
2))
+ );
+
+ $this->assertEquals(array_values($tokens),
array_values($this->t->wiki->tokens));
+ }
+
+ public function testMediawikiParseTableRegex()
+ {
+
+ $expectedResult = array(
+ 0 => array(
+ 0 => "{|
+| A || B
+|-
+| C || D
+|}",
+ ),
+ 1 => array(0 => " \n"),
+ 2 => array(0 => ''),
+ 3 => array(
+ 0 => "| A || B
+|-
+| C || D
+"
+ ),
+ 4 => array(
+ 0 => ''
+ )
+ );
+
+ $this->assertEquals($expectedResult, $this->matches);
+ }
+
+}
+
+
class Text_Wiki_Parse_Mediawiki_Wikilink_Test extends Text_Wiki_Parse_Mediawiki_SetUp_Tests
{
Modified: pear/packages/Text_Wiki/trunk/tests/Text_Wiki_Render_Tiki_Tests.php
===================================================================
--- pear/packages/Text_Wiki/trunk/tests/Text_Wiki_Render_Tiki_Tests.php 2009-08-02 11:51:56 UTC (rev
286659)
+++ pear/packages/Text_Wiki/trunk/tests/Text_Wiki_Render_Tiki_Tests.php 2009-08-02 12:09:44 UTC (rev
286660)
@@ -368,11 +368,15 @@
public function testTikiRenderImage()
{
$options = array('src' => 'src/image.jpg');
- $this->assertEquals('{img src=src/image.jpg}',
$this->t->token($options));
+ $this->assertEquals('{img src="img/wiki_up/src/image.jpg"}',
$this->t->token($options));
$options = array('src' => 'src/image.jpg', 'attr' =>
array());
- $this->assertEquals('{img src=src/image.jpg}',
$this->t->token($options));
+ $this->assertEquals('{img src="img/wiki_up/src/image.jpg"}',
$this->t->token($options));
$options = array('src' => 'src/image.jpg', 'attr' =>
array('width' => 600, 'height' => 500));
- $this->assertEquals('{img src=src/image.jpg width=600 height=500}',
$this->t->token($options));
+ $this->assertEquals('{img src="img/wiki_up/src/image.jpg"
width="600" height="500"}', $this->t->token($options));
+
+ $this->t->conf = array('prefix' => 'different/path/');
+ $options = array('src' => 'image.jpg');
+ $this->assertEquals('{img src="different/path/image.jpg"}',
$this->t->token($options));
}
}
Modified: pear/packages/Text_Wiki/trunk/tests/fixtures/mediawiki_syntax.txt
===================================================================
--- pear/packages/Text_Wiki/trunk/tests/fixtures/mediawiki_syntax.txt 2009-08-02 11:51:56 UTC (rev
286659)
+++ pear/packages/Text_Wiki/trunk/tests/fixtures/mediawiki_syntax.txt 2009-08-02 12:09:44 UTC (rev
286660)
@@ -64,6 +64,14 @@
Pellentesque sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus
elit quam, [[cursus]] nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec
sagittis turpis nec erat dictum a ultrices enim mollis.
+
+{|
+| A || B
+|-
+| C || D
+|}
+
+
<br />
<br />
Horizontal line: