New rows no longer accept 4_5 (the builder does not offer it). On update, the flexType of every non-desktop breakpoint (tablet, phone, …) is format-checked against the builder list like desktop. Guide updated. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01At3V6SjwbMe6eMzVGW3Hs7
52 lines
2.3 KiB
PHP
52 lines
2.3 KiB
PHP
<?php
|
||
|
||
declare(strict_types=1);
|
||
|
||
namespace LIT\MCP\Tests\Unit\Integrations\Divi\Compose;
|
||
|
||
use LIT\MCP\Integrations\Divi\Compose\ColumnWidths;
|
||
use PHPUnit\Framework\TestCase;
|
||
|
||
final class ColumnWidthsTest extends TestCase
|
||
{
|
||
/** Ruling S41: column widths on update follow the rules of "columns". */
|
||
public function testRowWidthsAreChecked(): void
|
||
{
|
||
self::assertNull(ColumnWidths::rowError(['8_24', '16_24']));
|
||
self::assertNull(ColumnWidths::rowError(['1_5', '1_5', '1_5', '1_5', '1_5']));
|
||
self::assertNotNull(ColumnWidths::rowError(['12_24', '16_24']));
|
||
self::assertNotNull(ColumnWidths::rowError(['1_13', '12_13']));
|
||
self::assertNotNull(ColumnWidths::rowError(['x', '24_24']));
|
||
self::assertNotNull(ColumnWidths::rowError([]));
|
||
}
|
||
|
||
public function testParseTurnsFractionsIntoFlexTypes(): void
|
||
{
|
||
self::assertSame(['widths' => ['8_24', '16_24'], 'error' => null], ColumnWidths::parse('1_3, 2_3'));
|
||
self::assertSame(['24_24'], ColumnWidths::parse(42)['widths']);
|
||
self::assertStringContainsString('erwartet', (string) ColumnWidths::parse('abc')['error']);
|
||
self::assertStringContainsString('1_13', (string) ColumnWidths::parse('1_13,12_13')['error']);
|
||
self::assertStringContainsString('volle Zeile', (string) ColumnWidths::parse('1_2,1_3')['error']);
|
||
}
|
||
|
||
/** Ruling S49: new rows use only widths the builder offers – 4_5 is no builder column class. */
|
||
public function testFourFifthsIsNoInsertWidth(): void
|
||
{
|
||
self::assertSame(['widths' => ['24_24'], 'error' => 'Spaltenbreite 4_5 gibt es in Divi nicht'], ColumnWidths::parse('1_5,4_5'));
|
||
self::assertNotNull(ColumnWidths::rowError(['1_5', '4_5']));
|
||
self::assertSame(['widths' => ['1_5', '2_5', '2_5'], 'error' => null], ColumnWidths::parse('1_5,2_5,2_5'));
|
||
}
|
||
|
||
/** Ruling S43: the builder's column classes. */
|
||
public function testColumnClassesAreTheBuilderList(): void
|
||
{
|
||
foreach (['1_24', '24_24', '1_5', '3_5', '1_11', 'none'] as $class) {
|
||
self::assertTrue(ColumnWidths::isColumnClass($class), $class);
|
||
}
|
||
|
||
foreach (['0_24', '25_24', '1_2', '4_5', '1_13', '', null, 8] as $class) {
|
||
self::assertFalse(ColumnWidths::isColumnClass($class), var_export($class, true));
|
||
}
|
||
}
|
||
}
|