*/
public function filterDay($request)
{
- return $this->bookmarkFilter->filter(BookmarkFilter::$FILTER_DAY, $request);
+ $visibility = $this->isLoggedIn ? BookmarkFilter::$ALL : BookmarkFilter::$PUBLIC;
+
+ return $this->bookmarkFilter->filter(BookmarkFilter::$FILTER_DAY, $request, false, $visibility);
}
/**
return $this->filterTags($request, $casesensitive, $visibility);
}
case self::$FILTER_DAY:
- return $this->filterDay($request);
+ return $this->filterDay($request, $visibility);
default:
return $this->noFilter($visibility);
}
* print_r($mydb->filterDay('20120125'));
*
* @param string $day day to filter.
- *
+ * @param string $visibility return only all/private/public bookmarks.
+
* @return array all link matching given day.
*
* @throws Exception if date format is invalid.
*/
- public function filterDay($day)
+ public function filterDay($day, $visibility)
{
if (!checkDateFormat('Ymd', $day)) {
throw new Exception('Invalid date format');
}
$filtered = [];
- foreach ($this->bookmarks as $key => $l) {
- if ($l->getCreated()->format('Ymd') == $day) {
- $filtered[$key] = $l;
+ foreach ($this->bookmarks as $key => $bookmark) {
+ if ($visibility === static::$PUBLIC && $bookmark->isPrivate()) {
+ continue;
+ }
+
+ if ($bookmark->getCreated()->format('Ymd') == $day) {
+ $filtered[$key] = $bookmark;
}
}
namespace Shaarli\Front\Controller\Admin;
-use Shaarli\Container\ShaarliContainer;
use Shaarli\Front\Controller\Visitor\ShaarliVisitorController;
-use Shaarli\Front\Exception\UnauthorizedException;
use Shaarli\Front\Exception\WrongTokenException;
use Shaarli\Security\SessionManager;
use Slim\Http\Request;
$data = $this->container->feedBuilder->buildData($feedType, $request->getParams());
- $this->executePageHooks('render_feed', $data, $feedType);
+ $this->executePageHooks('render_feed', $data, 'feed.' . $feedType);
$this->assignAllView($data);
- $content = $this->render('feed.'. $feedType);
+ $content = $this->render('feed.' . $feedType);
$cache->cache($content);
'footer',
];
+ $parameters = $this->buildPluginParameters($template);
+
foreach ($common_hooks as $name) {
$pluginData = [];
$this->container->pluginManager->executeHooks(
'render_' . $name,
$pluginData,
- [
- 'target' => $template,
- 'loggedin' => $this->container->loginManager->isLoggedIn(),
- 'basePath' => $this->container->basePath,
- ]
+ $parameters
);
$this->assignView('plugins_' . $name, $pluginData);
}
protected function executePageHooks(string $hook, array &$data, string $template = null): void
{
- $params = [
- 'target' => $template,
- 'loggedin' => $this->container->loginManager->isLoggedIn(),
- 'basePath' => $this->container->basePath,
- ];
-
$this->container->pluginManager->executeHooks(
$hook,
$data,
- $params
+ $this->buildPluginParameters($template)
);
}
+ protected function buildPluginParameters(?string $template): array
+ {
+ return [
+ 'target' => $template,
+ 'loggedin' => $this->container->loginManager->isLoggedIn(),
+ 'basePath' => $this->container->basePath,
+ 'bookmarkService' => $this->container->bookmarkService
+ ];
+ }
+
/**
* Simple helper which prepend the base path to redirect path.
*
/** Legacy route: ?post= */
public function post(Request $request, Response $response): Response
{
- $parameters = count($request->getQueryParams()) > 0 ? '?' . http_build_query($request->getQueryParams()) : '';
$route = '/admin/shaare';
+ $buildParameters = function (?array $parameters, bool $encode) {
+ if ($encode) {
+ $parameters = array_map('urlencode', $parameters);
+ }
+
+ return count($parameters) > 0 ? '?' . http_build_query($parameters) : '';
+ };
+
if (!$this->container->loginManager->isLoggedIn()) {
+ $parameters = $buildParameters($request->getQueryParams(), true);
return $this->redirect($response, '/login?returnurl='. $this->getBasePath() . $route . $parameters);
}
+ $parameters = $buildParameters($request->getQueryParams(), false);
+
return $this->redirect($response, $route . $parameters);
}
public static $PAGE_PICWALL = 'picwall';
- public static $PAGE_TAGCLOUD = 'tagcloud';
+ public static $PAGE_TAGCLOUD = 'tag.cloud';
- public static $PAGE_TAGLIST = 'taglist';
+ public static $PAGE_TAGLIST = 'tag.list';
public static $PAGE_DAILY = 'daily';
- public static $PAGE_FEED_ATOM = 'atom';
+ public static $PAGE_FEED_ATOM = 'feed.atom';
- public static $PAGE_FEED_RSS = 'rss';
+ public static $PAGE_FEED_RSS = 'feed.rss';
public static $PAGE_TOOLS = 'tools';
public static $PAGE_ADDLINK = 'addlink';
- public static $PAGE_EDITLINK = 'edit_link';
+ public static $PAGE_EDITLINK = 'editlink';
public static $PAGE_DELETELINK = 'delete_link';
public static $PAGE_THUMBS_UPDATE = 'thumbs_update';
public static $GET_TOKEN = 'token';
-
- /**
- * Reproducing renderPage() if hell, to avoid regression.
- *
- * This highlights how bad this needs to be rewrite,
- * but let's focus on plugins for now.
- *
- * @param string $query $_SERVER['QUERY_STRING'].
- * @param array $get $_SERVER['GET'].
- * @param bool $loggedIn true if authenticated user.
- *
- * @return string page found.
- */
- public static function findPage($query, $get, $loggedIn)
- {
- $loggedIn = ($loggedIn === true) ? true : false;
-
- if (empty($query) && !isset($get['edit_link']) && !isset($get['post'])) {
- return self::$PAGE_LINKLIST;
- }
-
- if (startsWith($query, 'do=' . self::$PAGE_LOGIN) && $loggedIn === false) {
- return self::$PAGE_LOGIN;
- }
-
- if (startsWith($query, 'do=' . self::$PAGE_PICWALL)) {
- return self::$PAGE_PICWALL;
- }
-
- if (startsWith($query, 'do=' . self::$PAGE_TAGCLOUD)) {
- return self::$PAGE_TAGCLOUD;
- }
-
- if (startsWith($query, 'do=' . self::$PAGE_TAGLIST)) {
- return self::$PAGE_TAGLIST;
- }
-
- if (startsWith($query, 'do=' . self::$PAGE_OPENSEARCH)) {
- return self::$PAGE_OPENSEARCH;
- }
-
- if (startsWith($query, 'do=' . self::$PAGE_DAILY)) {
- return self::$PAGE_DAILY;
- }
-
- if (startsWith($query, 'do=' . self::$PAGE_FEED_ATOM)) {
- return self::$PAGE_FEED_ATOM;
- }
-
- if (startsWith($query, 'do=' . self::$PAGE_FEED_RSS)) {
- return self::$PAGE_FEED_RSS;
- }
-
- if (startsWith($query, 'do=' . self::$PAGE_THUMBS_UPDATE)) {
- return self::$PAGE_THUMBS_UPDATE;
- }
-
- if (startsWith($query, 'do=' . self::$AJAX_THUMB_UPDATE)) {
- return self::$AJAX_THUMB_UPDATE;
- }
-
- // At this point, only loggedin pages.
- if (!$loggedIn) {
- return self::$PAGE_LINKLIST;
- }
-
- if (startsWith($query, 'do=' . self::$PAGE_TOOLS)) {
- return self::$PAGE_TOOLS;
- }
-
- if (startsWith($query, 'do=' . self::$PAGE_CHANGEPASSWORD)) {
- return self::$PAGE_CHANGEPASSWORD;
- }
-
- if (startsWith($query, 'do=' . self::$PAGE_CONFIGURE)) {
- return self::$PAGE_CONFIGURE;
- }
-
- if (startsWith($query, 'do=' . self::$PAGE_CHANGETAG)) {
- return self::$PAGE_CHANGETAG;
- }
-
- if (startsWith($query, 'do=' . self::$PAGE_ADDLINK)) {
- return self::$PAGE_ADDLINK;
- }
-
- if (isset($get['edit_link']) || isset($get['post'])) {
- return self::$PAGE_EDITLINK;
- }
-
- if (isset($get['delete_link'])) {
- return self::$PAGE_DELETELINK;
- }
-
- if (isset($get[self::$PAGE_CHANGE_VISIBILITY])) {
- return self::$PAGE_CHANGE_VISIBILITY;
- }
-
- if (startsWith($query, 'do=' . self::$PAGE_PINLINK)) {
- return self::$PAGE_PINLINK;
- }
-
- if (startsWith($query, 'do=' . self::$PAGE_EXPORT)) {
- return self::$PAGE_EXPORT;
- }
-
- if (startsWith($query, 'do=' . self::$PAGE_IMPORT)) {
- return self::$PAGE_IMPORT;
- }
-
- if (startsWith($query, 'do=' . self::$PAGE_PLUGINSADMIN)) {
- return self::$PAGE_PLUGINSADMIN;
- }
-
- if (startsWith($query, 'do=' . self::$PAGE_SAVE_PLUGINSADMIN)) {
- return self::$PAGE_SAVE_PLUGINSADMIN;
- }
-
- if (startsWith($query, 'do=' . self::$GET_TOKEN)) {
- return self::$GET_TOKEN;
- }
-
- return self::$PAGE_LINKLIST;
- }
}
$data['_BASE_PATH_'] = $params['basePath'];
}
+ if (isset($params['bookmarkService'])) {
+ $data['_BOOKMARK_SERVICE_'] = $params['bookmarkService'];
+ }
+
foreach ($this->loadedPlugins as $plugin) {
$hookFunction = $this->buildHookName($hook, $plugin);
return $data;
+#### Special data
+
+Special additional data are passed to every hook through the
+`$data` parameter to give you access to additional context, and services.
+
+Complete list:
+
+ * `_PAGE_` (string): if the current hook is used to render a template, its name is passed through this additional parameter.
+ * `_LOGGEDIN_` (bool): whether the user is logged in or not.
+ * `_BASE_PATH_` (string): if Shaarli instance is hosted under a subfolder, contains the subfolder path to `index.php` (e.g. `https://domain.tld/shaarli/` -> `/shaarli/`).
+ * `_BOOKMARK_SERVICE_` (`BookmarkServiceInterface`): bookmark service instance, for advanced usage.
+
+Example:
+
+```php
+if ($data['_PAGE_'] === TemplatePage::LINKLIST && $data['LOGGEDIN'] === true) {
+ // Do something for logged in users when the link list is rendered
+}
+```
+
#### Filling templates placeholder
Template placeholders are displayed in template in specific places.
The data contained by this array can be altered before template rendering.
-For exemple, in linklist, it is possible to alter every title:
+For example, in linklist, it is possible to alter every title:
```php
// mind the reference if you want $data to be altered
`$data` is an array containing:
-- `_PAGE_`: current target page (eg: `linklist`, `picwall`, etc.).
-- `_LOGGEDIN_`: true if user is logged in, false otherwise.
+ - [Special data](#special-data)
##### Template placeholders
`$data` is an array containing:
-- `_PAGE_`: current target page (eg: `linklist`, `picwall`, etc.).
-- `_LOGGEDIN_`: true if user is logged in, false otherwise.
+ - [Special data](#special-data)
##### Template placeholders
`$data` is an array containing:
-- `_PAGE_`: current target page (eg: `linklist`, `picwall`, etc.).
-- `_LOGGEDIN_`: true if user is logged in, false otherwise.
+ - [Special data](#special-data)
##### Template placeholders
`$data` is an array containing:
-- `_LOGGEDIN_`: true if user is logged in, false otherwise.
-- All templates data, including links.
+ - All templates data, including links.
+ - [Special data](#special-data)
##### Template placeholders
`$data` is an array containing:
-- All templates data.
+ - All templates data.
+ - [Special data](#special-data)
##### Template placeholders
`$data` is an array containing:
-- All templates data.
+ - All templates data.
+ - [Special data](#special-data)
##### Template placeholders
`$data` is an array containing:
-- `_LOGGEDIN_`: true if user is logged in, false otherwise.
-- All templates data.
+ - All templates data.
+ - [Special data](#special-data)
##### Template placeholders
`$data` is an array containing:
-- `_LOGGEDIN_`: true if user is logged in, false otherwise.
-- All templates data.
+ - All templates data.
+ - [Special data](#special-data)
##### Template placeholders
`$data` is an array containing:
-- `_LOGGEDIN_`: true if user is logged in, false otherwise.
-- All templates data.
+ - All templates data.
+ - [Special data](#special-data)
##### Template placeholders
`$data` is an array containing:
-- `_LOGGEDIN_`: true if user is logged in, false otherwise.
-- All templates data, including links.
+ - All templates data, including links.
+ - [Special data](#special-data)
##### Template placeholders
`$data` is an array containing:
-- `_LOGGEDIN_`: true if user is logged in, false otherwise.
-- `_PAGE_`: containing either `rss` or `atom`.
-- All templates data, including links.
+ - All templates data, including links.
+ - [Special data](#special-data)
##### Template placeholders
- created
- updated
+Also [special data](#special-data).
+
#### delete_link
##### Data
-`$data` is an array containing the link being saved:
+`$data` is an array containing the link being deleted:
- id
- title
- created
- updated
+Also [special data](#special-data).
#### save_plugin_parameters
So if the plugin has a parameter called `MYPLUGIN_PARAMETER`,
the array will contain an entry with `MYPLUGIN_PARAMETER` as a key.
+Also [special data](#special-data).
## Guide for template designer
"eslint-plugin-import": "^2.8.0",
"extract-text-webpack-plugin": "^3.0.2",
"file-loader": "^1.1.6",
- "node-sass": "^4.12.0",
+ "node-sass": "^4.13.1",
"sass-lint": "^1.12.1",
"sass-loader": "^6.0.6",
"style-loader": "^0.19.1",
function hook_qrcode_render_footer($data)
{
if ($data['_PAGE_'] == TemplatePage::LINKLIST) {
- $data['js_files'][] = PluginManager::$PLUGINS_PATH . '/qrcode/shaarli-qrcode.js';
+ $data['js_files'][] = ($data['_BASE_PATH_'] ?? '') . '/' . PluginManager::$PLUGINS_PATH . '/qrcode/shaarli-qrcode.js';
}
return $data;
function hook_qrcode_render_includes($data)
{
if ($data['_PAGE_'] == TemplatePage::LINKLIST) {
- $data['css_files'][] = PluginManager::$PLUGINS_PATH . '/qrcode/qrcode.css';
+ $data['css_files'][] = ($data['_BASE_PATH_'] ?? '') . '/' . PluginManager::$PLUGINS_PATH . '/qrcode/qrcode.css';
}
return $data;
$this->assertEquals($expected, $tags, var_export($tags, true));
}
+ /**
+ * Test filterDay while logged in
+ */
+ public function testFilterDayLoggedIn(): void
+ {
+ $bookmarks = $this->privateLinkDB->filterDay('20121206');
+ $expectedIds = [4, 9, 1, 0];
+
+ static::assertCount(4, $bookmarks);
+ foreach ($bookmarks as $bookmark) {
+ $i = ($i ?? -1) + 1;
+ static::assertSame($expectedIds[$i], $bookmark->getId());
+ }
+ }
+
+ /**
+ * Test filterDay while logged out
+ */
+ public function testFilterDayLoggedOut(): void
+ {
+ $bookmarks = $this->publicLinkDB->filterDay('20121206');
+ $expectedIds = [4, 9, 1];
+
+ static::assertCount(3, $bookmarks);
+ foreach ($bookmarks as $bookmark) {
+ $i = ($i ?? -1) + 1;
+ static::assertSame($expectedIds[$i], $bookmark->getId());
+ }
+ }
+
/**
* Allows to test LinkDB's private methods
*
use PHPUnit\Framework\TestCase;
use ReferenceLinkDB;
use Shaarli\Config\ConfigManager;
-use Shaarli\Formatter\FormatterFactory;
use Shaarli\History;
/**
/**
* Instantiate linkFilter with ReferenceLinkDB data.
*/
- public static function setUpBeforeClass()
+ public static function setUpBeforeClass(): void
{
$conf = new ConfigManager('tests/utils/config/configJson');
$conf->set('resource.datastore', self::$testDatastore);
);
}
+ /**
+ * Return bookmarks for a given day
+ */
+ public function testFilterDayRestrictedVisibility(): void
+ {
+ $this->assertEquals(
+ 3,
+ count(self::$linkFilter->filter(BookmarkFilter::$FILTER_DAY, '20121206', false, BookmarkFilter::$PUBLIC))
+ );
+ }
+
/**
* 404 - day not found
*/
static::assertSame('data', $data['content']);
static::assertArrayHasKey('loggedin', $param);
- static::assertSame('rss', $param['target']);
+ static::assertSame('feed.rss', $param['target']);
})
;
static::assertSame('data', $data['content']);
static::assertArrayHasKey('loggedin', $param);
- static::assertSame('atom', $param['target']);
+ static::assertSame('feed.atom', $param['target']);
})
;
static::assertSame('data', $data['content']);
static::assertArrayHasKey('loggedin', $param);
- static::assertSame('atom', $param['target']);
+ static::assertSame('feed.atom', $param['target']);
})
;
+++ /dev/null
-<?php
-
-namespace Shaarli\Legacy;
-
-use PHPUnit\Framework\TestCase;
-
-/**
- * Unit tests for Router
- */
-class LegacyRouterTest extends TestCase
-{
- /**
- * Test findPage: login page output.
- * Valid: page should be return.
- *
- * @return void
- */
- public function testFindPageLoginValid()
- {
- $this->assertEquals(
- LegacyRouter::$PAGE_LOGIN,
- LegacyRouter::findPage('do=login', array(), false)
- );
-
- $this->assertEquals(
- LegacyRouter::$PAGE_LOGIN,
- LegacyRouter::findPage('do=login', array(), 1)
- );
-
- $this->assertEquals(
- LegacyRouter::$PAGE_LOGIN,
- LegacyRouter::findPage('do=login&stuff', array(), false)
- );
- }
-
- /**
- * Test findPage: login page output.
- * Invalid: page shouldn't be return.
- *
- * @return void
- */
- public function testFindPageLoginInvalid()
- {
- $this->assertNotEquals(
- LegacyRouter::$PAGE_LOGIN,
- LegacyRouter::findPage('do=login', array(), true)
- );
-
- $this->assertNotEquals(
- LegacyRouter::$PAGE_LOGIN,
- LegacyRouter::findPage('do=other', array(), false)
- );
- }
-
- /**
- * Test findPage: picwall page output.
- * Valid: page should be return.
- *
- * @return void
- */
- public function testFindPagePicwallValid()
- {
- $this->assertEquals(
- LegacyRouter::$PAGE_PICWALL,
- LegacyRouter::findPage('do=picwall', array(), false)
- );
-
- $this->assertEquals(
- LegacyRouter::$PAGE_PICWALL,
- LegacyRouter::findPage('do=picwall', array(), true)
- );
- }
-
- /**
- * Test findPage: picwall page output.
- * Invalid: page shouldn't be return.
- *
- * @return void
- */
- public function testFindPagePicwallInvalid()
- {
- $this->assertEquals(
- LegacyRouter::$PAGE_PICWALL,
- LegacyRouter::findPage('do=picwall&stuff', array(), false)
- );
-
- $this->assertNotEquals(
- LegacyRouter::$PAGE_PICWALL,
- LegacyRouter::findPage('do=other', array(), false)
- );
- }
-
- /**
- * Test findPage: tagcloud page output.
- * Valid: page should be return.
- *
- * @return void
- */
- public function testFindPageTagcloudValid()
- {
- $this->assertEquals(
- LegacyRouter::$PAGE_TAGCLOUD,
- LegacyRouter::findPage('do=tagcloud', array(), false)
- );
-
- $this->assertEquals(
- LegacyRouter::$PAGE_TAGCLOUD,
- LegacyRouter::findPage('do=tagcloud', array(), true)
- );
-
- $this->assertEquals(
- LegacyRouter::$PAGE_TAGCLOUD,
- LegacyRouter::findPage('do=tagcloud&stuff', array(), false)
- );
- }
-
- /**
- * Test findPage: tagcloud page output.
- * Invalid: page shouldn't be return.
- *
- * @return void
- */
- public function testFindPageTagcloudInvalid()
- {
- $this->assertNotEquals(
- LegacyRouter::$PAGE_TAGCLOUD,
- LegacyRouter::findPage('do=other', array(), false)
- );
- }
-
- /**
- * Test findPage: linklist page output.
- * Valid: page should be return.
- *
- * @return void
- */
- public function testFindPageLinklistValid()
- {
- $this->assertEquals(
- LegacyRouter::$PAGE_LINKLIST,
- LegacyRouter::findPage('', array(), true)
- );
-
- $this->assertEquals(
- LegacyRouter::$PAGE_LINKLIST,
- LegacyRouter::findPage('whatever', array(), true)
- );
-
- $this->assertEquals(
- LegacyRouter::$PAGE_LINKLIST,
- LegacyRouter::findPage('whatever', array(), false)
- );
-
- $this->assertEquals(
- LegacyRouter::$PAGE_LINKLIST,
- LegacyRouter::findPage('do=tools', array(), false)
- );
- }
-
- /**
- * Test findPage: tools page output.
- * Valid: page should be return.
- *
- * @return void
- */
- public function testFindPageToolsValid()
- {
- $this->assertEquals(
- LegacyRouter::$PAGE_TOOLS,
- LegacyRouter::findPage('do=tools', array(), true)
- );
-
- $this->assertEquals(
- LegacyRouter::$PAGE_TOOLS,
- LegacyRouter::findPage('do=tools&stuff', array(), true)
- );
- }
-
- /**
- * Test findPage: tools page output.
- * Invalid: page shouldn't be return.
- *
- * @return void
- */
- public function testFindPageToolsInvalid()
- {
- $this->assertNotEquals(
- LegacyRouter::$PAGE_TOOLS,
- LegacyRouter::findPage('do=tools', array(), 1)
- );
-
- $this->assertNotEquals(
- LegacyRouter::$PAGE_TOOLS,
- LegacyRouter::findPage('do=tools', array(), false)
- );
-
- $this->assertNotEquals(
- LegacyRouter::$PAGE_TOOLS,
- LegacyRouter::findPage('do=other', array(), true)
- );
- }
-
- /**
- * Test findPage: changepasswd page output.
- * Valid: page should be return.
- *
- * @return void
- */
- public function testFindPageChangepasswdValid()
- {
- $this->assertEquals(
- LegacyRouter::$PAGE_CHANGEPASSWORD,
- LegacyRouter::findPage('do=changepasswd', array(), true)
- );
- $this->assertEquals(
- LegacyRouter::$PAGE_CHANGEPASSWORD,
- LegacyRouter::findPage('do=changepasswd&stuff', array(), true)
- );
- }
-
- /**
- * Test findPage: changepasswd page output.
- * Invalid: page shouldn't be return.
- *
- * @return void
- */
- public function testFindPageChangepasswdInvalid()
- {
- $this->assertNotEquals(
- LegacyRouter::$PAGE_CHANGEPASSWORD,
- LegacyRouter::findPage('do=changepasswd', array(), 1)
- );
-
- $this->assertNotEquals(
- LegacyRouter::$PAGE_CHANGEPASSWORD,
- LegacyRouter::findPage('do=changepasswd', array(), false)
- );
-
- $this->assertNotEquals(
- LegacyRouter::$PAGE_CHANGEPASSWORD,
- LegacyRouter::findPage('do=other', array(), true)
- );
- }
- /**
- * Test findPage: configure page output.
- * Valid: page should be return.
- *
- * @return void
- */
- public function testFindPageConfigureValid()
- {
- $this->assertEquals(
- LegacyRouter::$PAGE_CONFIGURE,
- LegacyRouter::findPage('do=configure', array(), true)
- );
-
- $this->assertEquals(
- LegacyRouter::$PAGE_CONFIGURE,
- LegacyRouter::findPage('do=configure&stuff', array(), true)
- );
- }
-
- /**
- * Test findPage: configure page output.
- * Invalid: page shouldn't be return.
- *
- * @return void
- */
- public function testFindPageConfigureInvalid()
- {
- $this->assertNotEquals(
- LegacyRouter::$PAGE_CONFIGURE,
- LegacyRouter::findPage('do=configure', array(), 1)
- );
-
- $this->assertNotEquals(
- LegacyRouter::$PAGE_CONFIGURE,
- LegacyRouter::findPage('do=configure', array(), false)
- );
-
- $this->assertNotEquals(
- LegacyRouter::$PAGE_CONFIGURE,
- LegacyRouter::findPage('do=other', array(), true)
- );
- }
-
- /**
- * Test findPage: changetag page output.
- * Valid: page should be return.
- *
- * @return void
- */
- public function testFindPageChangetagValid()
- {
- $this->assertEquals(
- LegacyRouter::$PAGE_CHANGETAG,
- LegacyRouter::findPage('do=changetag', array(), true)
- );
-
- $this->assertEquals(
- LegacyRouter::$PAGE_CHANGETAG,
- LegacyRouter::findPage('do=changetag&stuff', array(), true)
- );
- }
-
- /**
- * Test findPage: changetag page output.
- * Invalid: page shouldn't be return.
- *
- * @return void
- */
- public function testFindPageChangetagInvalid()
- {
- $this->assertNotEquals(
- LegacyRouter::$PAGE_CHANGETAG,
- LegacyRouter::findPage('do=changetag', array(), 1)
- );
-
- $this->assertNotEquals(
- LegacyRouter::$PAGE_CHANGETAG,
- LegacyRouter::findPage('do=changetag', array(), false)
- );
-
- $this->assertNotEquals(
- LegacyRouter::$PAGE_CHANGETAG,
- LegacyRouter::findPage('do=other', array(), true)
- );
- }
-
- /**
- * Test findPage: addlink page output.
- * Valid: page should be return.
- *
- * @return void
- */
- public function testFindPageAddlinkValid()
- {
- $this->assertEquals(
- LegacyRouter::$PAGE_ADDLINK,
- LegacyRouter::findPage('do=addlink', array(), true)
- );
-
- $this->assertEquals(
- LegacyRouter::$PAGE_ADDLINK,
- LegacyRouter::findPage('do=addlink&stuff', array(), true)
- );
- }
-
- /**
- * Test findPage: addlink page output.
- * Invalid: page shouldn't be return.
- *
- * @return void
- */
- public function testFindPageAddlinkInvalid()
- {
- $this->assertNotEquals(
- LegacyRouter::$PAGE_ADDLINK,
- LegacyRouter::findPage('do=addlink', array(), 1)
- );
-
- $this->assertNotEquals(
- LegacyRouter::$PAGE_ADDLINK,
- LegacyRouter::findPage('do=addlink', array(), false)
- );
-
- $this->assertNotEquals(
- LegacyRouter::$PAGE_ADDLINK,
- LegacyRouter::findPage('do=other', array(), true)
- );
- }
-
- /**
- * Test findPage: export page output.
- * Valid: page should be return.
- *
- * @return void
- */
- public function testFindPageExportValid()
- {
- $this->assertEquals(
- LegacyRouter::$PAGE_EXPORT,
- LegacyRouter::findPage('do=export', array(), true)
- );
-
- $this->assertEquals(
- LegacyRouter::$PAGE_EXPORT,
- LegacyRouter::findPage('do=export&stuff', array(), true)
- );
- }
-
- /**
- * Test findPage: export page output.
- * Invalid: page shouldn't be return.
- *
- * @return void
- */
- public function testFindPageExportInvalid()
- {
- $this->assertNotEquals(
- LegacyRouter::$PAGE_EXPORT,
- LegacyRouter::findPage('do=export', array(), 1)
- );
-
- $this->assertNotEquals(
- LegacyRouter::$PAGE_EXPORT,
- LegacyRouter::findPage('do=export', array(), false)
- );
-
- $this->assertNotEquals(
- LegacyRouter::$PAGE_EXPORT,
- LegacyRouter::findPage('do=other', array(), true)
- );
- }
-
- /**
- * Test findPage: import page output.
- * Valid: page should be return.
- *
- * @return void
- */
- public function testFindPageImportValid()
- {
- $this->assertEquals(
- LegacyRouter::$PAGE_IMPORT,
- LegacyRouter::findPage('do=import', array(), true)
- );
-
- $this->assertEquals(
- LegacyRouter::$PAGE_IMPORT,
- LegacyRouter::findPage('do=import&stuff', array(), true)
- );
- }
-
- /**
- * Test findPage: import page output.
- * Invalid: page shouldn't be return.
- *
- * @return void
- */
- public function testFindPageImportInvalid()
- {
- $this->assertNotEquals(
- LegacyRouter::$PAGE_IMPORT,
- LegacyRouter::findPage('do=import', array(), 1)
- );
-
- $this->assertNotEquals(
- LegacyRouter::$PAGE_IMPORT,
- LegacyRouter::findPage('do=import', array(), false)
- );
-
- $this->assertNotEquals(
- LegacyRouter::$PAGE_IMPORT,
- LegacyRouter::findPage('do=other', array(), true)
- );
- }
-
- /**
- * Test findPage: editlink page output.
- * Valid: page should be return.
- *
- * @return void
- */
- public function testFindPageEditlinkValid()
- {
- $this->assertEquals(
- LegacyRouter::$PAGE_EDITLINK,
- LegacyRouter::findPage('whatever', array('edit_link' => 1), true)
- );
-
- $this->assertEquals(
- LegacyRouter::$PAGE_EDITLINK,
- LegacyRouter::findPage('', array('edit_link' => 1), true)
- );
-
-
- $this->assertEquals(
- LegacyRouter::$PAGE_EDITLINK,
- LegacyRouter::findPage('whatever', array('post' => 1), true)
- );
-
- $this->assertEquals(
- LegacyRouter::$PAGE_EDITLINK,
- LegacyRouter::findPage('whatever', array('post' => 1, 'edit_link' => 1), true)
- );
- }
-
- /**
- * Test findPage: editlink page output.
- * Invalid: page shouldn't be return.
- *
- * @return void
- */
- public function testFindPageEditlinkInvalid()
- {
- $this->assertNotEquals(
- LegacyRouter::$PAGE_EDITLINK,
- LegacyRouter::findPage('whatever', array('edit_link' => 1), false)
- );
-
- $this->assertNotEquals(
- LegacyRouter::$PAGE_EDITLINK,
- LegacyRouter::findPage('whatever', array('edit_link' => 1), 1)
- );
-
- $this->assertNotEquals(
- LegacyRouter::$PAGE_EDITLINK,
- LegacyRouter::findPage('whatever', array(), true)
- );
- }
-}
resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773"
integrity sha1-0CJTc662Uq3BvILklFM5qEJ1R3M=
-lodash@^4.0.0, lodash@^4.17.11, lodash@^4.17.4, lodash@^4.3.0, lodash@~4.17.10:
- version "4.17.19"
- resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b"
- integrity sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==
+lodash@^4.0.0, lodash@^4.17.11, lodash@^4.17.15, lodash@^4.17.4, lodash@^4.3.0, lodash@~4.17.10:
+ version "4.17.20"
+ resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52"
+ integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==
longest@^1.0.1:
version "1.0.1"
semver "^5.3.0"
tar "^4"
-node-sass@^4.12.0:
- version "4.12.0"
- resolved "https://registry.yarnpkg.com/node-sass/-/node-sass-4.12.0.tgz#0914f531932380114a30cc5fa4fa63233a25f017"
- integrity sha512-A1Iv4oN+Iel6EPv77/HddXErL2a+gZ4uBeZUy+a8O35CFYTXhgA8MgLCWBtwpGZdCvTvQ9d+bQxX/QC36GDPpQ==
+node-sass@^4.13.1:
+ version "4.13.1"
+ resolved "https://registry.yarnpkg.com/node-sass/-/node-sass-4.13.1.tgz#9db5689696bb2eec2c32b98bfea4c7a2e992d0a3"
+ integrity sha512-TTWFx+ZhyDx1Biiez2nB0L3YrCZ/8oHagaDalbuBSlqXgUPsdkUSzJsVxeDO9LtPB49+Fh3WQl3slABo6AotNw==
dependencies:
async-foreach "^0.1.3"
chalk "^1.1.1"
get-stdin "^4.0.1"
glob "^7.0.3"
in-publish "^2.0.0"
- lodash "^4.17.11"
+ lodash "^4.17.15"
meow "^3.7.0"
mkdirp "^0.5.1"
nan "^2.13.2"