diff options
Diffstat (limited to 'tests/plugins')
-rw-r--r-- | tests/plugins/PluginAddlinkTest.php | 2 | ||||
-rw-r--r-- | tests/plugins/PluginArchiveorgTest.php | 37 | ||||
-rw-r--r-- | tests/plugins/PluginDefaultColorsTest.php | 4 | ||||
-rw-r--r-- | tests/plugins/PluginIssoTest.php | 23 | ||||
-rw-r--r-- | tests/plugins/PluginPlayvideosTest.php | 2 | ||||
-rw-r--r-- | tests/plugins/PluginPubsubhubbubTest.php | 2 | ||||
-rw-r--r-- | tests/plugins/PluginQrcodeTest.php | 2 | ||||
-rw-r--r-- | tests/plugins/PluginWallabagTest.php | 2 | ||||
-rw-r--r-- | tests/plugins/WallabagInstanceTest.php | 2 |
9 files changed, 47 insertions, 29 deletions
diff --git a/tests/plugins/PluginAddlinkTest.php b/tests/plugins/PluginAddlinkTest.php index aa5c6988..1f60d289 100644 --- a/tests/plugins/PluginAddlinkTest.php +++ b/tests/plugins/PluginAddlinkTest.php | |||
@@ -14,7 +14,7 @@ class PluginAddlinkTest extends \PHPUnit\Framework\TestCase | |||
14 | /** | 14 | /** |
15 | * Reset plugin path. | 15 | * Reset plugin path. |
16 | */ | 16 | */ |
17 | public function setUp() | 17 | protected function setUp(): void |
18 | { | 18 | { |
19 | PluginManager::$PLUGINS_PATH = 'plugins'; | 19 | PluginManager::$PLUGINS_PATH = 'plugins'; |
20 | } | 20 | } |
diff --git a/tests/plugins/PluginArchiveorgTest.php b/tests/plugins/PluginArchiveorgTest.php index b9a67adb..9c19752c 100644 --- a/tests/plugins/PluginArchiveorgTest.php +++ b/tests/plugins/PluginArchiveorgTest.php | |||
@@ -1,10 +1,12 @@ | |||
1 | <?php | 1 | <?php |
2 | |||
2 | namespace Shaarli\Plugin\Archiveorg; | 3 | namespace Shaarli\Plugin\Archiveorg; |
3 | 4 | ||
4 | /** | 5 | /** |
5 | * PluginArchiveorgTest.php | 6 | * PluginArchiveorgTest.php |
6 | */ | 7 | */ |
7 | 8 | ||
9 | use PHPUnit\Framework\TestCase; | ||
8 | use Shaarli\Plugin\PluginManager; | 10 | use Shaarli\Plugin\PluginManager; |
9 | 11 | ||
10 | require_once 'plugins/archiveorg/archiveorg.php'; | 12 | require_once 'plugins/archiveorg/archiveorg.php'; |
@@ -13,20 +15,35 @@ require_once 'plugins/archiveorg/archiveorg.php'; | |||
13 | * Class PluginArchiveorgTest | 15 | * Class PluginArchiveorgTest |
14 | * Unit test for the archiveorg plugin | 16 | * Unit test for the archiveorg plugin |
15 | */ | 17 | */ |
16 | class PluginArchiveorgTest extends \PHPUnit\Framework\TestCase | 18 | class PluginArchiveorgTest extends TestCase |
17 | { | 19 | { |
20 | protected $savedScriptName; | ||
21 | |||
18 | /** | 22 | /** |
19 | * Reset plugin path | 23 | * Reset plugin path |
20 | */ | 24 | */ |
21 | public function setUp() | 25 | public function setUp(): void |
22 | { | 26 | { |
23 | PluginManager::$PLUGINS_PATH = 'plugins'; | 27 | PluginManager::$PLUGINS_PATH = 'plugins'; |
28 | |||
29 | // plugins manipulate global vars | ||
30 | $_SERVER['SERVER_PORT'] = '80'; | ||
31 | $_SERVER['SERVER_NAME'] = 'shaarli.shaarli'; | ||
32 | $this->savedScriptName = $_SERVER['SCRIPT_NAME'] ?? null; | ||
33 | $_SERVER['SCRIPT_NAME'] = '/index.php'; | ||
34 | } | ||
35 | |||
36 | public function tearDown(): void | ||
37 | { | ||
38 | unset($_SERVER['SERVER_PORT']); | ||
39 | unset($_SERVER['SERVER_NAME']); | ||
40 | $_SERVER['SCRIPT_NAME'] = $this->savedScriptName; | ||
24 | } | 41 | } |
25 | 42 | ||
26 | /** | 43 | /** |
27 | * Test render_linklist hook on external bookmarks. | 44 | * Test render_linklist hook on external bookmarks. |
28 | */ | 45 | */ |
29 | public function testArchiveorgLinklistOnExternalLinks() | 46 | public function testArchiveorgLinklistOnExternalLinks(): void |
30 | { | 47 | { |
31 | $str = 'http://randomstr.com/test'; | 48 | $str = 'http://randomstr.com/test'; |
32 | 49 | ||
@@ -56,16 +73,16 @@ class PluginArchiveorgTest extends \PHPUnit\Framework\TestCase | |||
56 | /** | 73 | /** |
57 | * Test render_linklist hook on internal bookmarks. | 74 | * Test render_linklist hook on internal bookmarks. |
58 | */ | 75 | */ |
59 | public function testArchiveorgLinklistOnInternalLinks() | 76 | public function testArchiveorgLinklistOnInternalLinks(): void |
60 | { | 77 | { |
61 | $internalLink1 = 'http://shaarli.shaarli/?qvMAqg'; | 78 | $internalLink1 = 'http://shaarli.shaarli/shaare/qvMAqg'; |
62 | $internalLinkRealURL1 = '?qvMAqg'; | 79 | $internalLinkRealURL1 = '/shaare/qvMAqg'; |
63 | 80 | ||
64 | $internalLink2 = 'http://shaarli.shaarli/?2_7zww'; | 81 | $internalLink2 = 'http://shaarli.shaarli/shaare/2_7zww'; |
65 | $internalLinkRealURL2 = '?2_7zww'; | 82 | $internalLinkRealURL2 = '/shaare/2_7zww'; |
66 | 83 | ||
67 | $internalLink3 = 'http://shaarli.shaarli/?z7u-_Q'; | 84 | $internalLink3 = 'http://shaarli.shaarli/shaare/z7u-_Q'; |
68 | $internalLinkRealURL3 = '?z7u-_Q'; | 85 | $internalLinkRealURL3 = '/shaare/z7u-_Q'; |
69 | 86 | ||
70 | $data = array( | 87 | $data = array( |
71 | 'title' => $internalLink1, | 88 | 'title' => $internalLink1, |
diff --git a/tests/plugins/PluginDefaultColorsTest.php b/tests/plugins/PluginDefaultColorsTest.php index 9835dfa3..240bb4b2 100644 --- a/tests/plugins/PluginDefaultColorsTest.php +++ b/tests/plugins/PluginDefaultColorsTest.php | |||
@@ -19,7 +19,7 @@ class PluginDefaultColorsTest extends TestCase | |||
19 | /** | 19 | /** |
20 | * Reset plugin path | 20 | * Reset plugin path |
21 | */ | 21 | */ |
22 | public function setUp() | 22 | protected function setUp(): void |
23 | { | 23 | { |
24 | PluginManager::$PLUGINS_PATH = 'sandbox'; | 24 | PluginManager::$PLUGINS_PATH = 'sandbox'; |
25 | mkdir(PluginManager::$PLUGINS_PATH . '/default_colors/'); | 25 | mkdir(PluginManager::$PLUGINS_PATH . '/default_colors/'); |
@@ -32,7 +32,7 @@ class PluginDefaultColorsTest extends TestCase | |||
32 | /** | 32 | /** |
33 | * Remove sandbox files and folder | 33 | * Remove sandbox files and folder |
34 | */ | 34 | */ |
35 | public function tearDown() | 35 | protected function tearDown(): void |
36 | { | 36 | { |
37 | if (file_exists('sandbox/default_colors/default_colors.css.template')) { | 37 | if (file_exists('sandbox/default_colors/default_colors.css.template')) { |
38 | unlink('sandbox/default_colors/default_colors.css.template'); | 38 | unlink('sandbox/default_colors/default_colors.css.template'); |
diff --git a/tests/plugins/PluginIssoTest.php b/tests/plugins/PluginIssoTest.php index 99477205..2bbb93d2 100644 --- a/tests/plugins/PluginIssoTest.php +++ b/tests/plugins/PluginIssoTest.php | |||
@@ -2,6 +2,7 @@ | |||
2 | namespace Shaarli\Plugin\Isso; | 2 | namespace Shaarli\Plugin\Isso; |
3 | 3 | ||
4 | use DateTime; | 4 | use DateTime; |
5 | use PHPUnit\Framework\TestCase; | ||
5 | use Shaarli\Bookmark\Bookmark; | 6 | use Shaarli\Bookmark\Bookmark; |
6 | use Shaarli\Config\ConfigManager; | 7 | use Shaarli\Config\ConfigManager; |
7 | use Shaarli\Plugin\PluginManager; | 8 | use Shaarli\Plugin\PluginManager; |
@@ -13,12 +14,12 @@ require_once 'plugins/isso/isso.php'; | |||
13 | * | 14 | * |
14 | * Test the Isso plugin (comment system). | 15 | * Test the Isso plugin (comment system). |
15 | */ | 16 | */ |
16 | class PluginIssoTest extends \PHPUnit\Framework\TestCase | 17 | class PluginIssoTest extends TestCase |
17 | { | 18 | { |
18 | /** | 19 | /** |
19 | * Reset plugin path | 20 | * Reset plugin path |
20 | */ | 21 | */ |
21 | public function setUp() | 22 | public function setUp(): void |
22 | { | 23 | { |
23 | PluginManager::$PLUGINS_PATH = 'plugins'; | 24 | PluginManager::$PLUGINS_PATH = 'plugins'; |
24 | } | 25 | } |
@@ -26,7 +27,7 @@ class PluginIssoTest extends \PHPUnit\Framework\TestCase | |||
26 | /** | 27 | /** |
27 | * Test Isso init without errors. | 28 | * Test Isso init without errors. |
28 | */ | 29 | */ |
29 | public function testIssoInitNoError() | 30 | public function testIssoInitNoError(): void |
30 | { | 31 | { |
31 | $conf = new ConfigManager(''); | 32 | $conf = new ConfigManager(''); |
32 | $conf->set('plugins.ISSO_SERVER', 'value'); | 33 | $conf->set('plugins.ISSO_SERVER', 'value'); |
@@ -37,7 +38,7 @@ class PluginIssoTest extends \PHPUnit\Framework\TestCase | |||
37 | /** | 38 | /** |
38 | * Test Isso init with errors. | 39 | * Test Isso init with errors. |
39 | */ | 40 | */ |
40 | public function testIssoInitError() | 41 | public function testIssoInitError(): void |
41 | { | 42 | { |
42 | $conf = new ConfigManager(''); | 43 | $conf = new ConfigManager(''); |
43 | $errors = isso_init($conf); | 44 | $errors = isso_init($conf); |
@@ -47,7 +48,7 @@ class PluginIssoTest extends \PHPUnit\Framework\TestCase | |||
47 | /** | 48 | /** |
48 | * Test render_linklist hook with valid settings to display the comment form. | 49 | * Test render_linklist hook with valid settings to display the comment form. |
49 | */ | 50 | */ |
50 | public function testIssoDisplayed() | 51 | public function testIssoDisplayed(): void |
51 | { | 52 | { |
52 | $conf = new ConfigManager(''); | 53 | $conf = new ConfigManager(''); |
53 | $conf->set('plugins.ISSO_SERVER', 'value'); | 54 | $conf->set('plugins.ISSO_SERVER', 'value'); |
@@ -87,7 +88,7 @@ class PluginIssoTest extends \PHPUnit\Framework\TestCase | |||
87 | /** | 88 | /** |
88 | * Test isso plugin when multiple bookmarks are displayed (shouldn't be displayed). | 89 | * Test isso plugin when multiple bookmarks are displayed (shouldn't be displayed). |
89 | */ | 90 | */ |
90 | public function testIssoMultipleLinks() | 91 | public function testIssoMultipleLinks(): void |
91 | { | 92 | { |
92 | $conf = new ConfigManager(''); | 93 | $conf = new ConfigManager(''); |
93 | $conf->set('plugins.ISSO_SERVER', 'value'); | 94 | $conf->set('plugins.ISSO_SERVER', 'value'); |
@@ -115,14 +116,14 @@ class PluginIssoTest extends \PHPUnit\Framework\TestCase | |||
115 | 116 | ||
116 | $processed = hook_isso_render_linklist($data, $conf); | 117 | $processed = hook_isso_render_linklist($data, $conf); |
117 | // link_plugin should be added for the icon | 118 | // link_plugin should be added for the icon |
118 | $this->assertContains('<a href="?'. $short1 .'#isso-thread">', $processed['links'][0]['link_plugin'][0]); | 119 | $this->assertContains('<a href="/shaare/'. $short1 .'#isso-thread">', $processed['links'][0]['link_plugin'][0]); |
119 | $this->assertContains('<a href="?'. $short2 .'#isso-thread">', $processed['links'][1]['link_plugin'][0]); | 120 | $this->assertContains('<a href="/shaare/'. $short2 .'#isso-thread">', $processed['links'][1]['link_plugin'][0]); |
120 | } | 121 | } |
121 | 122 | ||
122 | /** | 123 | /** |
123 | * Test isso plugin when using search (shouldn't be displayed). | 124 | * Test isso plugin when using search (shouldn't be displayed). |
124 | */ | 125 | */ |
125 | public function testIssoNotDisplayedWhenSearch() | 126 | public function testIssoNotDisplayedWhenSearch(): void |
126 | { | 127 | { |
127 | $conf = new ConfigManager(''); | 128 | $conf = new ConfigManager(''); |
128 | $conf->set('plugins.ISSO_SERVER', 'value'); | 129 | $conf->set('plugins.ISSO_SERVER', 'value'); |
@@ -145,13 +146,13 @@ class PluginIssoTest extends \PHPUnit\Framework\TestCase | |||
145 | $processed = hook_isso_render_linklist($data, $conf); | 146 | $processed = hook_isso_render_linklist($data, $conf); |
146 | 147 | ||
147 | // link_plugin should be added for the icon | 148 | // link_plugin should be added for the icon |
148 | $this->assertContains('<a href="?'. $short1 .'#isso-thread">', $processed['links'][0]['link_plugin'][0]); | 149 | $this->assertContains('<a href="/shaare/'. $short1 .'#isso-thread">', $processed['links'][0]['link_plugin'][0]); |
149 | } | 150 | } |
150 | 151 | ||
151 | /** | 152 | /** |
152 | * Test isso plugin without server configuration (shouldn't be displayed). | 153 | * Test isso plugin without server configuration (shouldn't be displayed). |
153 | */ | 154 | */ |
154 | public function testIssoWithoutConf() | 155 | public function testIssoWithoutConf(): void |
155 | { | 156 | { |
156 | $data = 'abc'; | 157 | $data = 'abc'; |
157 | $conf = new ConfigManager(''); | 158 | $conf = new ConfigManager(''); |
diff --git a/tests/plugins/PluginPlayvideosTest.php b/tests/plugins/PluginPlayvideosTest.php index b7b6ce53..de1a1aec 100644 --- a/tests/plugins/PluginPlayvideosTest.php +++ b/tests/plugins/PluginPlayvideosTest.php | |||
@@ -19,7 +19,7 @@ class PluginPlayvideosTest extends \PHPUnit\Framework\TestCase | |||
19 | /** | 19 | /** |
20 | * Reset plugin path | 20 | * Reset plugin path |
21 | */ | 21 | */ |
22 | public function setUp() | 22 | protected function setUp(): void |
23 | { | 23 | { |
24 | PluginManager::$PLUGINS_PATH = 'plugins'; | 24 | PluginManager::$PLUGINS_PATH = 'plugins'; |
25 | } | 25 | } |
diff --git a/tests/plugins/PluginPubsubhubbubTest.php b/tests/plugins/PluginPubsubhubbubTest.php index e66f484e..d30c3703 100644 --- a/tests/plugins/PluginPubsubhubbubTest.php +++ b/tests/plugins/PluginPubsubhubbubTest.php | |||
@@ -21,7 +21,7 @@ class PluginPubsubhubbubTest extends \PHPUnit\Framework\TestCase | |||
21 | /** | 21 | /** |
22 | * Reset plugin path | 22 | * Reset plugin path |
23 | */ | 23 | */ |
24 | public function setUp() | 24 | protected function setUp(): void |
25 | { | 25 | { |
26 | PluginManager::$PLUGINS_PATH = 'plugins'; | 26 | PluginManager::$PLUGINS_PATH = 'plugins'; |
27 | } | 27 | } |
diff --git a/tests/plugins/PluginQrcodeTest.php b/tests/plugins/PluginQrcodeTest.php index c9f8c733..bc6be0eb 100644 --- a/tests/plugins/PluginQrcodeTest.php +++ b/tests/plugins/PluginQrcodeTest.php | |||
@@ -19,7 +19,7 @@ class PluginQrcodeTest extends \PHPUnit\Framework\TestCase | |||
19 | /** | 19 | /** |
20 | * Reset plugin path | 20 | * Reset plugin path |
21 | */ | 21 | */ |
22 | public function setUp() | 22 | protected function setUp(): void |
23 | { | 23 | { |
24 | PluginManager::$PLUGINS_PATH = 'plugins'; | 24 | PluginManager::$PLUGINS_PATH = 'plugins'; |
25 | } | 25 | } |
diff --git a/tests/plugins/PluginWallabagTest.php b/tests/plugins/PluginWallabagTest.php index 79751921..372929ea 100644 --- a/tests/plugins/PluginWallabagTest.php +++ b/tests/plugins/PluginWallabagTest.php | |||
@@ -15,7 +15,7 @@ class PluginWallabagTest extends \PHPUnit\Framework\TestCase | |||
15 | /** | 15 | /** |
16 | * Reset plugin path | 16 | * Reset plugin path |
17 | */ | 17 | */ |
18 | public function setUp() | 18 | protected function setUp(): void |
19 | { | 19 | { |
20 | PluginManager::$PLUGINS_PATH = 'plugins'; | 20 | PluginManager::$PLUGINS_PATH = 'plugins'; |
21 | } | 21 | } |
diff --git a/tests/plugins/WallabagInstanceTest.php b/tests/plugins/WallabagInstanceTest.php index a3cd9076..4cb0d4cc 100644 --- a/tests/plugins/WallabagInstanceTest.php +++ b/tests/plugins/WallabagInstanceTest.php | |||
@@ -14,7 +14,7 @@ class WallabagInstanceTest extends \PHPUnit\Framework\TestCase | |||
14 | /** | 14 | /** |
15 | * Reset plugin path | 15 | * Reset plugin path |
16 | */ | 16 | */ |
17 | public function setUp() | 17 | protected function setUp(): void |
18 | { | 18 | { |
19 | $this->instance = 'http://some.url'; | 19 | $this->instance = 'http://some.url'; |
20 | } | 20 | } |