8
0
daux.io/tests/Format/HTML/ConfigTest.php

55 Zeilen
1.8 KiB
PHP

<?php
namespace Todaymade\Daux\Format\HTML;
use PHPUnit\Framework\TestCase;
2020-04-22 22:24:52 +02:00
use Todaymade\Daux\Config as MainConfig;
class ConfigTest extends TestCase
{
2020-04-22 21:55:53 +02:00
public 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'];
return [
[[], null],
2017-09-13 21:43:40 +02:00
[['edit_on_github' => 'dauxio/daux.io/blob/master/docs'], $github_result],
// 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],
// 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],
// 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/']],
2020-04-22 22:24:52 +02:00
['name' => 'Bitbucket', 'basepath' => 'https://bitbucket.org/dauxio/daux.io/src/master/docs'],
],
];
}
/**
* @dataProvider providerEditOn
2020-04-22 22:24:52 +02:00
*
* @param mixed $value
* @param mixed $expected
*/
public function testEditOn($value, $expected)
{
$config = new Config($value);
$this->assertEquals($expected, $config->getEditOn());
}
}