Add tests for PMA_isAllowedDomain

Signed-off-by: Michal Čihař <michal@cihar.com>
This commit is contained in:
Michal Čihař 2016-07-18 16:36:55 +02:00
parent 1543be7138
commit 7e6edaf756

View File

@ -0,0 +1,52 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Test for PMA_isAllowedDomain
*
* @package PhpMyAdmin-test
*/
/*
* Include to test.
*/
require_once 'libraries/core.lib.php';
class PMA_isAllowedDomain_test extends PHPUnit_Framework_TestCase
{
/**
* Test for unserializing
*
* @param string $url URL to test
* @param mixed $expected Expected result
*
* @return void
*
* @dataProvider provideURLs
*/
function testIsAllowedDomain($url, $expected)
{
$_SERVER['SERVER_NAME'] = 'server.local';
$this->assertEquals(
$expected,
PMA_isAllowedDomain($url)
);
}
/**
* Test data provider
*
* @return array
*/
function provideURLs()
{
return array(
array('https://www.phpmyadmin.net/', true),
array('http://duckduckgo.com\\@github.com', true),
array('https://github.com/', true),
array('https://server.local/', true),
);
}
}