Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/old/vendor/phpgt/dom/test/phpunit/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/vendor/phpgt/dom/test/phpunit/FormTest.php
<?php
namespace Gt\Dom\Test;

use PHPUnit\Framework\TestCase;
use Gt\Dom\HTMLDocument;
use Gt\Dom\Test\Helper\Helper;

class FormTest extends TestCase {
	public function testMultipleRadioCanNotBeCheckedViaProperty() {
		$document = new HTMLDocument(Helper::HTML_FORM_WITH_RADIOS);
		$whiteRadio = $document->querySelector("input[value=white]");
		$blackRadio = $document->querySelector("input[value=black]");

		$whiteRadio->checked = true;

		self::assertTrue(
			$whiteRadio->hasAttribute("checked"),
			"Checked attribute should be present on white radio after setting property on white."
		);
		self::assertFalse(
			$blackRadio->hasAttribute("checked"),
			"Checked attribute should not be present on black radio after setting property on white."
		);

		$blackRadio->checked = true;

		self::assertFalse(
			$whiteRadio->hasAttribute("checked"),
			"Checked attribute should not be present on white after setting property on black."
		);
		self::assertTrue(
			$blackRadio->hasAttribute("checked"),
			"Checked attribute should be present on black after setting property on black."
		);
	}

	public function testIfRadioChangesToUncheckedWhenSettingCheckedToFalse() {
        $document = new HTMLDocument(Helper::HTML_FORM_WITH_RADIOS);
        $whiteRadio = $document->querySelector("input[value=white]");

        $whiteRadio->checked = true;

        self::assertTrue(
            $whiteRadio->hasAttribute("checked"),
            "Checked attribute should be present on white radio after setting property on white."
        );

        $whiteRadio->checked = false;

        self::assertFalse($whiteRadio->hasAttribute("checked"),
            "Checked attribute should not be present on white radio after unsetting property on white.");
    }

	public function testMultipleSelectOptionCanNotBeCheckedViaProperty() {
		$document = new HTMLDocument(Helper::HTML_FORM_WITH_RADIOS);
		$under18option = $document->querySelector("option[value='0-17']");
		$youngAdultOption = $document->querySelector("option[value='18-35']");

		$under18option->selected = true;

		self::assertTrue($under18option->hasAttribute("selected"));
		self::assertFalse($youngAdultOption->hasAttribute("selected"));

		$youngAdultOption->selected = true;

		self::assertFalse($under18option->hasAttribute("selected"));
		self::assertTrue($youngAdultOption->hasAttribute("selected"));
	}

	public function testIfSelectOptionChangesToUnselectedWhenSettingSelectedToFalse() {
        $document = new HTMLDocument(Helper::HTML_FORM_WITH_RADIOS);
        $under18option = $document->querySelector("option[value='0-17']");

        $under18option->selected = true;

        self::assertTrue($under18option->hasAttribute("selected"));

        $under18option->selected = false;

        self::assertFalse($under18option->hasAttribute("selected"));

    }

	public function testMultipleSelectOptionCanBeCheckedViaPropertyWhenSelectMultiple() {
		$document = new HTMLDocument(Helper::HTML_FORM_WITH_RADIOS);
		$phpOption = $document->querySelector("option[value='php']");
		$haskellOption = $document->querySelector("option[value='haskell']");

		$phpOption->selected = true;
		$haskellOption->selected = true;

		self::assertTrue($phpOption->selected);
		self::assertTrue($haskellOption->selected);
	}
}

Spamworldpro Mini