Skip to content
Snippets Groups Projects
Commit 98cb8e27 authored by catch's avatar catch
Browse files

Issue #3523649 by znerol: Extract testUriHost from UuidValidatorTest into its own class

(cherry picked from commit cca39816)
parent 54b69d41
Branches
Tags
9 merge requests!12686Draft: Issue #3535330: Assets paths in CSS no longer rewritten when aggregation is enabled,!12661Issue #3255804 by godotislate, longwave, berdir, alexpott, catch, andypost,...,!12660Issue #3255804 by godotislate, longwave, berdir, alexpott, catch, andypost,...,!12618Issue #3522970 by longwave, smustgrave: Remove unused BrowserTestBase::$originalContainer,!12473Issue #3521639 by mstrelan, smustgrave for 11.2,!12462Issue #3523109 by ghost of drupal past, donquixote, nicxvan, dww, larowlan,...,!12357Issue #3529639 by mradcliffe, smustgrave, solomon.yifru: replacing a depricated css,!8811Issue #3129179: Provide some way to rebuild the persistent bundle field map,!7916Remove taxonomy dependency on node module - 11.x
Pipeline #509100 passed with warnings
Pipeline: drupal

#509103

    <?php
    declare(strict_types=1);
    namespace Drupal\KernelTests\Core\Validation;
    use Drupal\KernelTests\KernelTestBase;
    /**
    * Tests the UriHost validator.
    *
    * @group Validation
    */
    class UriHostValidatorTest extends KernelTestBase {
    /**
    * {@inheritdoc}
    */
    protected static $modules = ['config_test'];
    /**
    * {@inheritdoc}
    */
    protected function setUp(): void {
    parent::setUp();
    $this->installConfig('config_test');
    }
    /**
    * @see \Drupal\Core\Validation\Plugin\Validation\Constraint\UriHostConstraint
    */
    public function testUriHost(): void {
    $typed_config_manager = \Drupal::service('config.typed');
    /** @var \Drupal\Core\Config\Schema\TypedConfigInterface $typed_config */
    $typed_config = $typed_config_manager->get('config_test.validation');
    // Test valid names.
    $typed_config->get('host')->setValue('example.com');
    $this->assertCount(0, $typed_config->validate());
    $typed_config->get('host')->setValue('example.com.');
    $this->assertCount(0, $typed_config->validate());
    $typed_config->get('host')->setValue('default');
    $this->assertCount(0, $typed_config->validate());
    // Test invalid names.
    $typed_config->get('host')->setValue('.example.com');
    $this->assertCount(1, $typed_config->validate());
    // Test valid IPv6 literals.
    $typed_config->get('host')->setValue('[::1]');
    $this->assertCount(0, $typed_config->validate());
    $typed_config->get('host')->setValue('[2001:DB8::]');
    $this->assertCount(0, $typed_config->validate());
    $typed_config->get('host')->setValue('[2001:db8:dd54:4473:bd6e:52db:10b3:4abe]');
    $this->assertCount(0, $typed_config->validate());
    // Test invalid IPv6 literals.
    $typed_config->get('host')->setValue('::1');
    $this->assertCount(1, $typed_config->validate());
    // Test valid IPv4 addresses.
    $typed_config->get('host')->setValue('127.0.0.1');
    $this->assertCount(0, $typed_config->validate());
    $typed_config->get('host')->setValue('192.0.2.254');
    $this->assertCount(0, $typed_config->validate());
    }
    }
    ......@@ -44,48 +44,4 @@ public function testUuid(): void {
    $this->assertCount(1, $typed_config->validate());
    }
    /**
    * @see \Drupal\Core\Validation\Plugin\Validation\Constraint\UriHostConstraint
    */
    public function testUriHost(): void {
    $typed_config_manager = \Drupal::service('config.typed');
    /** @var \Drupal\Core\Config\Schema\TypedConfigInterface $typed_config */
    $typed_config = $typed_config_manager->get('config_test.validation');
    // Test valid names.
    $typed_config->get('host')->setValue('example.com');
    $this->assertCount(0, $typed_config->validate());
    $typed_config->get('host')->setValue('example.com.');
    $this->assertCount(0, $typed_config->validate());
    $typed_config->get('host')->setValue('default');
    $this->assertCount(0, $typed_config->validate());
    // Test invalid names.
    $typed_config->get('host')->setValue('.example.com');
    $this->assertCount(1, $typed_config->validate());
    // Test valid IPv6 literals.
    $typed_config->get('host')->setValue('[::1]');
    $this->assertCount(0, $typed_config->validate());
    $typed_config->get('host')->setValue('[2001:DB8::]');
    $this->assertCount(0, $typed_config->validate());
    $typed_config->get('host')->setValue('[2001:db8:dd54:4473:bd6e:52db:10b3:4abe]');
    $this->assertCount(0, $typed_config->validate());
    // Test invalid IPv6 literals.
    $typed_config->get('host')->setValue('::1');
    $this->assertCount(1, $typed_config->validate());
    // Test valid IPv4 addresses.
    $typed_config->get('host')->setValue('127.0.0.1');
    $this->assertCount(0, $typed_config->validate());
    $typed_config->get('host')->setValue('192.0.2.254');
    $this->assertCount(0, $typed_config->validate());
    }
    }
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Please register or to comment