1<?php 2/* 3 * Copyright (c) 2016 Mark C. Prins <mprins@users.sf.net> 4 * 5 * Permission to use, copy, modify, and distribute this software for any 6 * purpose with or without fee is hereby granted, provided that the above 7 * copyright notice and this permission notice appear in all copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 */ 17namespace dokuwiki\plugin\spatialhelper\test; 18 19use dokuwiki\MailUtils; 20use DokuWikiTest; 21/** 22 * General tests for the spatialhelper plugin. 23 * 24 * @group plugin_spatialhelper 25 * @group plugins 26 */ 27class spatialhelper_plugin_test extends DokuWikiTest 28{ 29 30 protected $pluginsEnabled = array('spatialhelper'); 31 32 /** 33 * Simple test to make sure the plugin.info.txt is in correct format. 34 */ 35 final public function test_plugininfo(): void 36 { 37 $file = __DIR__ . '/../plugin.info.txt'; 38 self::assertFileExists($file); 39 40 $info = confToHash($file); 41 42 self::assertArrayHasKey('base', $info); 43 self::assertArrayHasKey('author', $info); 44 self::assertArrayHasKey('email', $info); 45 self::assertArrayHasKey('date', $info); 46 self::assertArrayHasKey('name', $info); 47 self::assertArrayHasKey('desc', $info); 48 self::assertArrayHasKey('url', $info); 49 50 self::assertEquals('spatialhelper', $info['base']); 51 self::assertMatchesRegularExpression('/^https?:\/\//', $info['url']); 52 self::assertTrue(MailUtils::isValid($info['email'])); 53 self::assertMatchesRegularExpression('/^\d\d\d\d-\d\d-\d\d$/', $info['date']); 54 self::assertNotFalse(strtotime($info['date'])); 55 } 56 57 /** 58 * test if plugin is loaded. 59 */ 60 final public function test_plugin_spatialhelper_isloaded(): void 61 { 62 global $plugin_controller; 63 self::assertContains( 64 'spatialhelper', 65 $plugin_controller->getList(), 66 "spatialhelper plugin is loaded" 67 ); 68 } 69} 70