1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2026-10-24 18:59:20 +03:00
Files
bookstack/tests/View/ViewBlockDefaultsTest.php
Dan Brown 01b29515c8 Layouts: Updated view block ids/labels to be static
So that their metadata can be read without having to create instances
and fullfill dependancy injection just to list.

Also added title to interface prefs page.
2026-08-16 10:41:43 +01:00

37 lines
1013 B
PHP

<?php
namespace Tests\View;
use BookStack\View\ViewBlockDefaults;
use Tests\TestCase;
class ViewBlockDefaultsTest extends TestCase
{
public function test_each_has_a_unique_id_and_non_key_label()
{
$locations = ViewBlockDefaults::getLocations();
$classes = [];
$trueById = [];
foreach ($locations as $location) {
$blocksByPosition = ViewBlockDefaults::getForLocation($location);
foreach ($blocksByPosition as $blocks) {
array_push($classes, ...$blocks);
}
}
$blocks = array_unique($classes);
foreach ($blocks as $block) {
$id = $block::getId();
$this->assertArrayNotHasKey($id, $trueById);
$trueById[$id] = true;
$label = $block::getLabel();
$this->assertIsString($label);
$this->assertDoesNotMatchRegularExpression('/^[a-z]{1,10}\./', $label);
}
$this->assertGreaterThan(10, count($trueById));
}
}