/
githubmirror
/
joomla-cms
Обзор
Документация
Войти
/
githubmirror
/
joomla-cms
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
5.4-dev
tests/Unit/Libraries/Cms/Form/Rule/BooleanRuleTest.php
70 строк
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\BooleanRule; use Joomla\Tests\Unit\UnitTestCase; /** * Test class for BooleanRule. * * @since 5.4.3 */ class BooleanRuleTest 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="boolean" />'); return [ [true, $xml, 'true'], [true, $xml, 'false'], [true, $xml, '0'], [true, $xml, '1'], [true, $xml, 'TRUE'], [true, $xml, 'FALSE'], [true, $xml, 'True'], [true, $xml, 'False'], [false, $xml, ''], [false, $xml, 'tu re'], [false, $xml, 'false1'], [false, $xml, 'none'], ]; } /** * Tests the BooleanRule::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 BooleanRule())->test($element, $value)); } }