mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2024-11-26 03:16:33 +03:00
57 lines
1.9 KiB
PHP
57 lines
1.9 KiB
PHP
|
<?php
|
||
|
|
||
|
declare(strict_types=1);
|
||
|
|
||
|
namespace RssBridge\Tests;
|
||
|
|
||
|
use BridgeCard;
|
||
|
use PHPUnit\Framework\TestCase;
|
||
|
|
||
|
class BridgeCardTest extends TestCase
|
||
|
{
|
||
|
public function test()
|
||
|
{
|
||
|
$sut = new BridgeCard();
|
||
|
$this->assertSame('', BridgeCard::getInputAttributes([]));
|
||
|
$this->assertSame(' required pattern="\d+"', BridgeCard::getInputAttributes(['required' => true, 'pattern' => '\d+']));
|
||
|
|
||
|
$entry = [
|
||
|
'defaultValue' => 'checked',
|
||
|
];
|
||
|
$this->assertSame('<input id="id" type="checkbox" name="name" checked />' . "\n", BridgeCard::getCheckboxInput($entry, 'id', 'name'));
|
||
|
|
||
|
$entry = [
|
||
|
'defaultValue' => 42,
|
||
|
'exampleValue' => 43,
|
||
|
];
|
||
|
$this->assertSame('<input id="id" type="number" value="42" placeholder="43" name="name" />' . "\n", BridgeCard::getNumberInput($entry, 'id', 'name'));
|
||
|
|
||
|
$entry = [
|
||
|
'defaultValue' => 'yo1',
|
||
|
'exampleValue' => 'yo2',
|
||
|
];
|
||
|
$this->assertSame('<input id="id" type="text" value="yo1" placeholder="yo2" name="name" />' . "\n", BridgeCard::getTextInput($entry, 'id', 'name'));
|
||
|
|
||
|
$entry = [
|
||
|
'values' => [],
|
||
|
];
|
||
|
$this->assertSame('<select id="id" name="name" ></select>', BridgeCard::getListInput($entry, 'id', 'name'));
|
||
|
|
||
|
$entry = [
|
||
|
'defaultValue' => 2,
|
||
|
'values' => [
|
||
|
'foo' => 'bar',
|
||
|
],
|
||
|
];
|
||
|
$this->assertSame('<select id="id" name="name" ><option value="bar">foo</option></select>', BridgeCard::getListInput($entry, 'id', 'name'));
|
||
|
|
||
|
// optgroup
|
||
|
$entry = [
|
||
|
'defaultValue' => 2,
|
||
|
'values' => ['kek' => [
|
||
|
'f' => 'b',
|
||
|
]],
|
||
|
];
|
||
|
$this->assertSame('<select id="id" name="name" ><optgroup label="kek"><option value="b">f</option></optgroup></select>', BridgeCard::getListInput($entry, 'id', 'name'));
|
||
|
}
|
||
|
}
|