SystemSqlDefaultsTest.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. /**
  3. * Defaults a fresh install gets from install/sql/system.sql. Read from the SQL itself, so a site whose admin
  4. * changed a setting in Studio does not fail the suite.
  5. */
  6. class SystemSqlDefaultsTest extends \PHPUnit\Framework\TestCase
  7. {
  8. private static function systemSql(): string
  9. {
  10. $sSql = file_get_contents(__DIR__ . '/../../../install/sql/system.sql');
  11. if ($sSql === false)
  12. self::fail('install/sql/system.sql is not readable.');
  13. return $sSql;
  14. }
  15. public function testHomeCreatePostBlockIsContentOnly(): void
  16. {
  17. // The home page's create-post block: designbox_id follows object, cell, module, title_system and title.
  18. $bFound = preg_match("/\\('sys_home', \\d+, 'system', '_sys_page_block_title_sys_create_post', '_sys_page_block_title_create_post', (\\d+),/", self::systemSql(), $aMatch);
  19. $this->assertSame(1, $bFound, 'system.sql adds the create-post block to the home page.');
  20. $this->assertSame(0, (int)$aMatch[1], 'It shows only its form: the content-only design box (BX_DB_CONTENT_ONLY).');
  21. }
  22. public function testPoweredByBadgeFollowsTheFooterColour(): void
  23. {
  24. $bFound = preg_match("/\\('sys_footer', 'system', 'powered_by', [^\\n]*?'_blank', '(<svg.*?<\\/svg>)'/", self::systemSql(), $aMatch);
  25. $this->assertSame(1, $bFound, 'system.sql adds the powered-by badge to the footer menu.');
  26. $this->assertStringContainsString('fill="currentColor"', $aMatch[1], 'The badge draws in the footer link colour, so it reads in light and dark.');
  27. $this->assertDoesNotMatchRegularExpression('/(fill|stroke)="#/', $aMatch[1], 'No fixed colour that would vanish on one of the two schemes.');
  28. }
  29. }