/
githubmirror
/
joomla-cms
Обзор
Документация
Войти
/
githubmirror
/
joomla-cms
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
5.4-dev
tests/Unit/Libraries/Cms/Form/Rule/CalendarRuleTest.php
69 строк
2 KB
Richard Fath
Joomla! 5.4.3 Release Candidate 1
06 фев 2026, 20:27
06 фев 2026, 20:27
09d26dc
Код
Авторство
О чём код?
<?php /** * @package Joomla.UnitTest * @subpackage Form * * @copyright (C) 2026 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\Tests\Unit\Libraries\Cms\Form\Rule; use Joomla\CMS\Form\Rule\CalendarRule; use Joomla\Tests\Unit\UnitTestCase; /** * Test class for CalendarRule. * * @since 5.4.3 */ class CalendarRuleTest extends UnitTestCase { /** * Test data for the testRule method * * @return array * * @since 5.4.3 */ public function dataTest(): array { $xml = new \SimpleXMLElement('<field name="unittest" type="text" validate="calendar" />'); return [ [true, $xml, ''], [true, $xml, 'now'], [true, $xml, 'NOW'], [true, $xml, 'Now'], [true, $xml, '2026-05-01'], [true, $xml, '2026-05-01 00:00:00'], [true, $xml, '2028-10-13 14:15:16'], [false, $xml, 'test'], [false, $xml, '2026-05-01 12:65:00'], [false, $xml, '2026-05-01 26:30:00'], [false, $xml, '2026-13-01'], ]; } /** * Tests the CalendarRule::test method. * * @param bool $expected The expected test result * @param \SimpleXMLElement $element The SimpleXMLElement object representing the `<field>` tag for the form field object. * @param string $value The form field value to validate. * * @return void * * @since 5.4.3 * @dataProvider dataTest */ public function testRule(bool $expected, \SimpleXMLElement $element, string $value): void { $this->assertEquals($expected, (new CalendarRule())->test($element, $value)); } }