2016-09-30 22:24:33 +02:00
|
|
|
<?php namespace Todaymade\Daux\Format\HTML;
|
|
|
|
|
|
|
|
use Todaymade\Daux\Config as MainConfig;
|
|
|
|
|
|
|
|
class ConfigTest extends \PHPUnit_Framework_TestCase
|
|
|
|
{
|
|
|
|
function testHTMLConfigCreation() {
|
|
|
|
$config = new MainConfig(['html' => ['edit_on' => 'test']]);
|
|
|
|
|
|
|
|
$this->assertInstanceOf(Config::class, $config->getHTML());
|
|
|
|
$this->assertEquals('test', $config->getHTML()['edit_on']);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function providerEditOn()
|
|
|
|
{
|
2017-09-13 21:43:40 +02:00
|
|
|
$github_result = ['name' => 'GitHub', 'basepath' => 'https://github.com/dauxio/daux.io/blob/master/docs'];
|
2016-09-30 22:24:33 +02:00
|
|
|
|
|
|
|
return [
|
|
|
|
[[], null],
|
2017-09-13 21:43:40 +02:00
|
|
|
[['edit_on_github' => 'dauxio/daux.io/blob/master/docs'], $github_result],
|
2016-09-30 22:24:33 +02:00
|
|
|
|
|
|
|
// Allow formatting in many ways
|
2017-09-13 21:43:40 +02:00
|
|
|
[['edit_on_github' => 'dauxio/daux.io/blob/master/docs/'], $github_result],
|
|
|
|
[['edit_on_github' => '/dauxio/daux.io/blob/master/docs'], $github_result],
|
|
|
|
[['edit_on_github' => 'https://github.com/dauxio/daux.io/blob/master/docs/'], $github_result],
|
|
|
|
[['edit_on_github' => 'http://github.com/dauxio/daux.io/blob/master/docs/'], $github_result],
|
2016-09-30 22:24:33 +02:00
|
|
|
|
|
|
|
// Fallback if a string is provided to 'edit_on'
|
2017-09-13 21:43:40 +02:00
|
|
|
[['edit_on' => 'dauxio/daux.io/blob/master/docs'], $github_result],
|
2016-09-30 22:24:33 +02:00
|
|
|
|
|
|
|
// Support any provider
|
|
|
|
[
|
2017-09-13 21:43:40 +02:00
|
|
|
['edit_on' => ['name' => 'Bitbucket', 'basepath' => 'https://bitbucket.org/dauxio/daux.io/src/master/docs/']],
|
|
|
|
['name' => 'Bitbucket', 'basepath' => 'https://bitbucket.org/dauxio/daux.io/src/master/docs']
|
2016-09-30 22:24:33 +02:00
|
|
|
]
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider providerEditOn
|
|
|
|
*/
|
|
|
|
public function testEditOn($value, $expected)
|
|
|
|
{
|
|
|
|
$config = new Config($value);
|
|
|
|
|
|
|
|
$this->assertEquals($expected, $config->getEditOn());
|
|
|
|
}
|
|
|
|
}
|