added tests and fixed leftover array entries
This commit is contained in:
parent
69d10cf8d0
commit
3bd176d4fc
|
@ -36,17 +36,18 @@ final class CsvxmlAvailableFields {
|
|||
* @param boolean $required Determines whether the field is required. Defaults
|
||||
to false.
|
||||
*
|
||||
* @return array
|
||||
* @return FieldEntry
|
||||
*/
|
||||
private function _getSimpleAvailableFieldEntry(string $nameTL = "", string $explica = "", array $dependsOn = [], array $allowedValues = [], string $remark = "", bool $required = false):array {
|
||||
return [
|
||||
"required" => $required,
|
||||
"allowedValues" => $allowedValues,
|
||||
"dependsOn" => $dependsOn,
|
||||
"remark" => $remark,
|
||||
"name_human_readable" => $nameTL,
|
||||
"explica" => $explica,
|
||||
];
|
||||
private function _getSimpleAvailableFieldEntry(string $nameTL = "", string $explica = "", array $dependsOn = [], array $allowedValues = [], string $remark = "", bool $required = false):FieldEntry
|
||||
{
|
||||
return new FieldEntry(
|
||||
$required,
|
||||
$allowedValues,
|
||||
$dependsOn,
|
||||
$remark,
|
||||
$nameTL,
|
||||
$explica
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
@ -59,9 +60,10 @@ final class CsvxmlAvailableFields {
|
|||
* @param string $type Event type name (e.g. production).
|
||||
* @param integer $number Number of event of this type.
|
||||
*
|
||||
* @return array
|
||||
* @return FieldEntry
|
||||
*/
|
||||
private function _generateGenericFullEvent(array $event, MDTlLoader $tlLoader, string $typeName, string $type, int $number):array {
|
||||
private function _generateGenericFullEvent(array $event, MDTlLoader $tlLoader, string $typeName, string $type, int $number):array
|
||||
{
|
||||
|
||||
return [
|
||||
"{$type}_when{$number}" => $this->_getSimpleAvailableFieldEntry("{$typeName}: {$event['when']}", "", ["{$type}_when_sure{$number}"]),
|
||||
|
|
33
tests/CsvxmlAvailableFieldsTest.php
Normal file
33
tests/CsvxmlAvailableFieldsTest.php
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?PHP
|
||||
/**
|
||||
* This script contains tests for the home page.
|
||||
*
|
||||
* @author Joshua Ramon Enslin <joshua@jrenslin.de>
|
||||
*/
|
||||
declare(strict_types = 1);
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
require_once __DIR__ . "/../functions/functions.php";
|
||||
|
||||
/**
|
||||
* Test class for the start page.
|
||||
*/
|
||||
final class CsvxmlAvailableFieldsTest extends TestCase {
|
||||
/**
|
||||
* Test for HTML output.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testOutput():void {
|
||||
|
||||
$fieldsGetter = new CsvxmlAvailableFields('en');
|
||||
$availableFields = $fieldsGetter->getFields();
|
||||
|
||||
foreach ($availableFields as $type) {
|
||||
foreach ($type as $name => $entry) {
|
||||
self::assertTrue($entry instanceof FieldEntry, $name . " is not a FieldEntry");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user