Count example

->method('getDefinitions')
      ->willReturn($definitions);

    $this->accessManager->expects($this->any())
      ->method('checkNamedRoute')
      ->willReturn(AccessResult::allowed());

    $this->moduleHandler->expects($this->exactly(2))
      ->method('alter')
      ->withConsecutive(
        ['contextual_links_plugins'],
        ['contextual_links', new Count(2), 'group1', ['key' => 'value']],
      );

    $result = $this->contextualLinkManager->getContextualLinksArrayByGroup('group1', ['key' => 'value']);
    $this->assertCount(2, $result);
    foreach (['test_plugin1', 'test_plugin2'] as $plugin_id) {
      $definition = $definitions[$plugin_id];
      $this->assertEquals($definition['weight']$result[$plugin_id]['weight']);
      $this->assertEquals($definition['title']$result[$plugin_id]['title']);
      $this->assertEquals($definition['route_name']$result[$plugin_id]['route_name']);
      $this->assertEquals($definition['options']$result[$plugin_id]['localized_options']);
    }
  }
new Negative(),
            ]],
            ['FOO', [
                new Choice(['choices' => ['bar', 'BAR']]),
                new Regex(['pattern' => '/foo/i']),
            ]],
            ['fr', [
                new Country(),
                new Language(),
            ]],
            [[1, 3, 5][
                new Count(['min' => 5]),
                new Unique(),
            ]],
        ];
    }

    /** * @dataProvider getInvalidCombinations */
    public function testInvalidCombinationsWithDefaultMessage($value$constraints)
    {
        $atLeastOneOf = new AtLeastOneOf(['constraints' => $constraints]);
        
abstract class CountValidatorTestCase extends ConstraintValidatorTestCase
{
    protected function createValidator(): CountValidator
    {
        return new CountValidator();
    }

    abstract protected static function createCollection(array $content);

    public function testNullIsValid()
    {
        $this->validator->validate(null, new Count(6));

        $this->assertNoViolation();
    }

    public function testExpectsCountableType()
    {
        $this->expectException(UnexpectedValueException::class);
        $this->validator->validate(new \stdClass()new Count(5));
    }

    public static function getThreeOrLessElements()
    {
Home | Imprint | This part of the site doesn't use cookies.