152fa4f27SMark Prins<?php 252fa4f27SMark Prins/* 352fa4f27SMark Prins * Copyright (c) 2016 Mark C. Prins <mprins@users.sf.net> 452fa4f27SMark Prins * 552fa4f27SMark Prins * Permission to use, copy, modify, and distribute this software for any 652fa4f27SMark Prins * purpose with or without fee is hereby granted, provided that the above 752fa4f27SMark Prins * copyright notice and this permission notice appear in all copies. 852fa4f27SMark Prins * 952fa4f27SMark Prins * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 1052fa4f27SMark Prins * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 1152fa4f27SMark Prins * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 1252fa4f27SMark Prins * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 1352fa4f27SMark Prins * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 1452fa4f27SMark Prins * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 1552fa4f27SMark Prins * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 1652fa4f27SMark Prins */ 1752fa4f27SMark Prins 1852fa4f27SMark Prins/** 1952fa4f27SMark Prins * General tests for the backlinks plugin 2052fa4f27SMark Prins * 2152fa4f27SMark Prins * @group plugin_backlinks 2252fa4f27SMark Prins * @group plugins 2352fa4f27SMark Prins */ 24*c271718aSMark Prinsclass general_plugin_backlinks_test extends DokuWikiTest 25*c271718aSMark Prins{ 2652fa4f27SMark Prins 2752fa4f27SMark Prins protected $pluginsEnabled = array('backlinks'); 2852fa4f27SMark Prins 2952fa4f27SMark Prins /** 3052fa4f27SMark Prins * Simple test to make sure the plugin.info.txt is in correct format 3152fa4f27SMark Prins */ 32*c271718aSMark Prins public function testPluginInfo(): void 33*c271718aSMark Prins { 3452fa4f27SMark Prins $file = __DIR__ . '/../plugin.info.txt'; 3552fa4f27SMark Prins $this->assertFileExists($file); 3652fa4f27SMark Prins 3752fa4f27SMark Prins $info = confToHash($file); 3852fa4f27SMark Prins 3952fa4f27SMark Prins $this->assertArrayHasKey('base', $info); 4052fa4f27SMark Prins $this->assertArrayHasKey('author', $info); 4152fa4f27SMark Prins $this->assertArrayHasKey('email', $info); 4252fa4f27SMark Prins $this->assertArrayHasKey('date', $info); 4352fa4f27SMark Prins $this->assertArrayHasKey('name', $info); 4452fa4f27SMark Prins $this->assertArrayHasKey('desc', $info); 4552fa4f27SMark Prins $this->assertArrayHasKey('url', $info); 4652fa4f27SMark Prins 4752fa4f27SMark Prins $this->assertEquals('backlinks', $info['base']); 48*c271718aSMark Prins $this->assertMatchesRegularExpression('/^https?:\/\//', $info['url']); 4952fa4f27SMark Prins $this->assertTrue(mail_isvalid($info['email'])); 50*c271718aSMark Prins $this->assertMatchesRegularExpression('/^\d\d\d\d-\d\d-\d\d$/', $info['date']); 5152fa4f27SMark Prins $this->assertTrue(false !== strtotime($info['date'])); 5252fa4f27SMark Prins } 5352fa4f27SMark Prins 54c3465203SMark Prins /** 55c3465203SMark Prins * test if plugin is loaded. 56c3465203SMark Prins */ 57*c271718aSMark Prins public function testPluginBacklinksIsLoaded(): void 58*c271718aSMark Prins { 5952fa4f27SMark Prins global $plugin_controller; 601ed0f63eSMark Prins $this->assertContains( 61*c271718aSMark Prins 'backlinks', 62*c271718aSMark Prins $plugin_controller->getList(), 63*c271718aSMark Prins "backlinks plugin is loaded" 6452fa4f27SMark Prins ); 6552fa4f27SMark Prins } 6652fa4f27SMark Prins} 67