From 39a1513b96944c7dc59a9431c9d812916aea9105 Mon Sep 17 00:00:00 2001 From: Mark Prins Date: Sat, 28 May 2016 12:47:15 +0200 Subject: [PATCH] set up for testing (#2) set up for testing --- .travis.yml | 27 ++++++++++++++++++ README.md | 5 ++++ _test/general.test.php | 62 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 94 insertions(+) create mode 100644 .travis.yml create mode 100644 _test/general.test.php diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..b76cf0e --- /dev/null +++ b/.travis.yml @@ -0,0 +1,27 @@ +language: php + +php: + - "7.0" + - "5.6" + - "5.5" + - "5.4" + - "5.3" + +env: + - DOKUWIKI=master + - DOKUWIKI=stable + - DOKUWIKI=old-stable + +before_install: + - wget https://raw.github.com/splitbrain/dokuwiki-travis/master/travis.sh + +install: + - sh travis.sh + +script: + - cd _test && PRESERVE_TMP=false phpunit --stderr --group plugin_webmaster --verbose --debug + +matrix: + allow_failures: + - php: "7.0" + env: DOKUWIKI=old-stable diff --git a/README.md b/README.md index a1a7483..311b42e 100644 --- a/README.md +++ b/README.md @@ -2,3 +2,8 @@ dokuwiki-plugin-webmaster ========================= Adds webmaster site verification keys for Google, Bing and Yandex to your wiki pages. + +[![Build Status](https://travis-ci.org/mprins/dokuwiki-plugin-webmaster.svg?branch=master)](https://travis-ci.org/mprins/dokuwiki-plugin-webmaster) + +[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/mprins/dokuwiki-plugin-webmaster/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/mprins/dokuwiki-plugin-webmaster/?branch=master) + diff --git a/_test/general.test.php b/_test/general.test.php new file mode 100644 index 0000000..5e2820f --- /dev/null +++ b/_test/general.test.php @@ -0,0 +1,62 @@ + + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/** + * General tests for the webmaster plugin + * + * @group plugin_webmaster + * @group plugins + */ +class general_plugin_webmaster_test extends DokuWikiTest { + + protected $pluginsEnabled = array('webmaster'); + + /** + * Simple test to make sure the plugin.info.txt is in correct format + */ + public function test_plugininfo() { + $file = __DIR__ . '/../plugin.info.txt'; + $this->assertFileExists($file); + + $info = confToHash($file); + + $this->assertArrayHasKey('base', $info); + $this->assertArrayHasKey('author', $info); + $this->assertArrayHasKey('email', $info); + $this->assertArrayHasKey('date', $info); + $this->assertArrayHasKey('name', $info); + $this->assertArrayHasKey('desc', $info); + $this->assertArrayHasKey('url', $info); + + $this->assertEquals('webmaster', $info['base']); + $this->assertRegExp('/^https?:\/\//', $info['url']); + $this->assertTrue(mail_isvalid($info['email'])); + $this->assertRegExp('/^\d\d\d\d-\d\d-\d\d$/', $info['date']); + $this->assertTrue(false !== strtotime($info['date'])); + } + + /** + * test if plugin is loaded. + */ + public function test_plugin_webmaster_isloaded() { + global $plugin_controller; + $this->assertTrue( + in_array('webmaster', $plugin_controller->getList()), + "webmaster plugin is loaded" + ); + } +}