xref: /plugin/farmer/_test/core.test.php (revision 5b5c8486c2fd499fa1aa5be2b0fd2e2fcb622f06)
185becf1bSAndreas Gohr<?php
2*5b5c8486SAndreas Gohr
3*5b5c8486SAndreas Gohrnamespace plugin\farmer\test;
485becf1bSAndreas Gohr
585becf1bSAndreas Gohrrequire_once(__DIR__ . '/../DokuWikiFarmCore.php');
685becf1bSAndreas Gohr
7*5b5c8486SAndreas Gohrclass DokuWikiFarmCore extends \DokuWikiFarmCore
8*5b5c8486SAndreas Gohr{
9*5b5c8486SAndreas Gohr    /** @noinspection PhpMissingParentConstructorInspection */
10*5b5c8486SAndreas Gohr    public function __construct()
11*5b5c8486SAndreas Gohr    {
12*5b5c8486SAndreas Gohr        $this->loadConfig();
13*5b5c8486SAndreas Gohr        // we do not intitialize anyting else here because it's already too late and DOKU_INC is already set
14*5b5c8486SAndreas Gohr    }
15*5b5c8486SAndreas Gohr
16*5b5c8486SAndreas Gohr
17*5b5c8486SAndreas Gohr    public function getAnimalNamesForHost($host)
18*5b5c8486SAndreas Gohr    {
1985becf1bSAndreas Gohr        return parent::getAnimalNamesForHost($host);
2085becf1bSAndreas Gohr    }
2185becf1bSAndreas Gohr}
2285becf1bSAndreas Gohr
2385becf1bSAndreas Gohr
2485becf1bSAndreas Gohr/**
2585becf1bSAndreas Gohr * @group plugin_farmer
2685becf1bSAndreas Gohr * @group plugins
2785becf1bSAndreas Gohr */
28*5b5c8486SAndreas Gohrclass core_plugin_farmer_test extends \DokuWikiTest
29*5b5c8486SAndreas Gohr{
3085becf1bSAndreas Gohr
31*5b5c8486SAndreas Gohr    protected $pluginsEnabled = ['farmer'];
3285becf1bSAndreas Gohr
3385becf1bSAndreas Gohr
34*5b5c8486SAndreas Gohr    public function test_hostsAnimals()
35*5b5c8486SAndreas Gohr    {
3685becf1bSAndreas Gohr        $core = new DokuWikiFarmCore();
3785becf1bSAndreas Gohr
3885becf1bSAndreas Gohr        $input = 'www.foobar.example.com:8000';
39*5b5c8486SAndreas Gohr        $expect = [
4085becf1bSAndreas Gohr            'www.foobar.example.com.8000',
4185becf1bSAndreas Gohr            'foobar.example.com.8000',
4285becf1bSAndreas Gohr            'www.foobar.example.com',
4385becf1bSAndreas Gohr            'foobar.example.com',
44bfecda9bSAndreas Gohr            'www.foobar.example',
4585becf1bSAndreas Gohr            'foobar.example',
4685becf1bSAndreas Gohr            'www.foobar',
4785becf1bSAndreas Gohr            'foobar',
4885becf1bSAndreas Gohr            'www',
49*5b5c8486SAndreas Gohr        ];
5085becf1bSAndreas Gohr
5185becf1bSAndreas Gohr        $this->assertEquals($expect, $core->getAnimalNamesForHost($input));
5285becf1bSAndreas Gohr    }
5385becf1bSAndreas Gohr}
54