aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'tests/plugins')
-rw-r--r--tests/plugins/PluginIssoTest.php25
-rw-r--r--tests/plugins/PluginMarkdownTest.php42
2 files changed, 58 insertions, 9 deletions
diff --git a/tests/plugins/PluginIssoTest.php b/tests/plugins/PluginIssoTest.php
index 1f545c7d..6b7904dd 100644
--- a/tests/plugins/PluginIssoTest.php
+++ b/tests/plugins/PluginIssoTest.php
@@ -47,12 +47,14 @@ class PluginIssoTest extends PHPUnit_Framework_TestCase
47 $conf->set('plugins.ISSO_SERVER', 'value'); 47 $conf->set('plugins.ISSO_SERVER', 'value');
48 48
49 $str = 'http://randomstr.com/test'; 49 $str = 'http://randomstr.com/test';
50 $date = '20161118_100001';
50 $data = array( 51 $data = array(
51 'title' => $str, 52 'title' => $str,
52 'links' => array( 53 'links' => array(
53 array( 54 array(
55 'id' => 12,
54 'url' => $str, 56 'url' => $str,
55 'linkdate' => 'abc', 57 'created' => DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $date),
56 ) 58 )
57 ) 59 )
58 ); 60 );
@@ -65,7 +67,14 @@ class PluginIssoTest extends PHPUnit_Framework_TestCase
65 67
66 // plugin data 68 // plugin data
67 $this->assertEquals(1, count($data['plugin_end_zone'])); 69 $this->assertEquals(1, count($data['plugin_end_zone']));
68 $this->assertNotFalse(strpos($data['plugin_end_zone'][0], 'abc')); 70 $this->assertNotFalse(strpos(
71 $data['plugin_end_zone'][0],
72 'data-isso-id="'. $data['links'][0]['id'] .'"'
73 ));
74 $this->assertNotFalse(strpos(
75 $data['plugin_end_zone'][0],
76 'data-title="'. $data['links'][0]['id'] .'"'
77 ));
69 $this->assertNotFalse(strpos($data['plugin_end_zone'][0], 'embed.min.js')); 78 $this->assertNotFalse(strpos($data['plugin_end_zone'][0], 'embed.min.js'));
70 } 79 }
71 80
@@ -78,16 +87,20 @@ class PluginIssoTest extends PHPUnit_Framework_TestCase
78 $conf->set('plugins.ISSO_SERVER', 'value'); 87 $conf->set('plugins.ISSO_SERVER', 'value');
79 88
80 $str = 'http://randomstr.com/test'; 89 $str = 'http://randomstr.com/test';
90 $date1 = '20161118_100001';
91 $date2 = '20161118_100002';
81 $data = array( 92 $data = array(
82 'title' => $str, 93 'title' => $str,
83 'links' => array( 94 'links' => array(
84 array( 95 array(
96 'id' => 12,
85 'url' => $str, 97 'url' => $str,
86 'linkdate' => 'abc', 98 'created' => DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $date1),
87 ), 99 ),
88 array( 100 array(
101 'id' => 13,
89 'url' => $str . '2', 102 'url' => $str . '2',
90 'linkdate' => 'abc2', 103 'created' => DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $date2),
91 ), 104 ),
92 ) 105 )
93 ); 106 );
@@ -106,12 +119,14 @@ class PluginIssoTest extends PHPUnit_Framework_TestCase
106 $conf->set('plugins.ISSO_SERVER', 'value'); 119 $conf->set('plugins.ISSO_SERVER', 'value');
107 120
108 $str = 'http://randomstr.com/test'; 121 $str = 'http://randomstr.com/test';
122 $date = '20161118_100001';
109 $data = array( 123 $data = array(
110 'title' => $str, 124 'title' => $str,
111 'links' => array( 125 'links' => array(
112 array( 126 array(
127 'id' => 12,
113 'url' => $str, 128 'url' => $str,
114 'linkdate' => 'abc', 129 'created' => DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $date),
115 ) 130 )
116 ), 131 ),
117 'search_term' => $str 132 'search_term' => $str
diff --git a/tests/plugins/PluginMarkdownTest.php b/tests/plugins/PluginMarkdownTest.php
index 12bdda24..4a67b2dc 100644
--- a/tests/plugins/PluginMarkdownTest.php
+++ b/tests/plugins/PluginMarkdownTest.php
@@ -8,8 +8,8 @@ require_once 'application/Utils.php';
8require_once 'plugins/markdown/markdown.php'; 8require_once 'plugins/markdown/markdown.php';
9 9
10/** 10/**
11 * Class PlugQrcodeTest 11 * Class PluginMarkdownTest
12 * Unit test for the QR-Code plugin 12 * Unit test for the Markdown plugin
13 */ 13 */
14class PluginMarkdownTest extends PHPUnit_Framework_TestCase 14class PluginMarkdownTest extends PHPUnit_Framework_TestCase
15{ 15{
@@ -130,8 +130,11 @@ class PluginMarkdownTest extends PHPUnit_Framework_TestCase
130 )) 130 ))
131 ); 131 );
132 132
133 $data = hook_markdown_render_linklist($data); 133 $processed = hook_markdown_render_linklist($data);
134 $this->assertEquals($str, $data['links'][0]['description']); 134 $this->assertEquals($str, $processed['links'][0]['description']);
135
136 $processed = hook_markdown_render_feed($data);
137 $this->assertEquals($str, $processed['links'][0]['description']);
135 138
136 $data = array( 139 $data = array(
137 // Columns data 140 // Columns data
@@ -153,6 +156,37 @@ class PluginMarkdownTest extends PHPUnit_Framework_TestCase
153 } 156 }
154 157
155 /** 158 /**
159 * Test that a close value to nomarkdown is not understand as nomarkdown (previous value `.nomarkdown`).
160 */
161 function testNoMarkdownNotExcactlyMatching()
162 {
163 $str = 'All _work_ and `no play` makes Jack a *dull* boy.';
164 $data = array(
165 'links' => array(array(
166 'description' => $str,
167 'tags' => '.' . NO_MD_TAG,
168 'taglist' => array('.'. NO_MD_TAG),
169 ))
170 );
171
172 $data = hook_markdown_render_feed($data);
173 $this->assertContains('<em>', $data['links'][0]['description']);
174 }
175
176 /**
177 * Test hashtag links processed with markdown.
178 */
179 function testMarkdownHashtagLinks()
180 {
181 $md = file_get_contents('tests/plugins/resources/markdown.md');
182 $md = format_description($md);
183 $html = file_get_contents('tests/plugins/resources/markdown.html');
184
185 $data = process_markdown($md);
186 $this->assertEquals($html, $data);
187 }
188
189 /**
156 * Test hashtag links processed with markdown. 190 * Test hashtag links processed with markdown.
157 */ 191 */
158 function testMarkdownHashtagLinks() 192 function testMarkdownHashtagLinks()