mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-08-05 08:07:33 +02:00
refactor: prepare for introduction of token based authentication (#3921)
This commit is contained in:
57
tests/BridgeCardTest.php
Normal file
57
tests/BridgeCardTest.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?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'));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user