guessMaxLengthForConstraint example



    public function guessRequired(string $class, string $property): ?ValueGuess
    {
        // If we don't find any constraint telling otherwise, we can assume         // that a field is not required (with LOW_CONFIDENCE)         return $this->guess($class$property$this->guessRequiredForConstraint(...), false);
    }

    public function guessMaxLength(string $class, string $property): ?ValueGuess
    {
        return $this->guess($class$property$this->guessMaxLengthForConstraint(...));
    }

    public function guessPattern(string $class, string $property): ?ValueGuess
    {
        return $this->guess($class$property$this->guessPatternForConstraint(...));
    }

    /** * Guesses a field class name for a given constraint. */
    public function guessTypeForConstraint(Constraint $constraint): ?TypeGuess
    {


    public function testGuessRequiredReturnsFalseForUnmappedProperties()
    {
        $this->assertEquals(new ValueGuess(false, Guess::LOW_CONFIDENCE)$this->guesser->guessRequired(self::TEST_CLASS, self::TEST_PROPERTY));
    }

    public function testGuessMaxLengthForConstraintWithMaxValue()
    {
        $constraint = new Length(['max' => '2']);

        $result = $this->guesser->guessMaxLengthForConstraint($constraint);
        $this->assertInstanceOf(ValueGuess::class$result);
        $this->assertEquals(2, $result->getValue());
        $this->assertEquals(Guess::HIGH_CONFIDENCE, $result->getConfidence());
    }

    public function testGuessMaxLengthForConstraintWithMinValue()
    {
        $constraint = new Length(['min' => '2']);

        $result = $this->guesser->guessMaxLengthForConstraint($constraint);
        $this->assertNull($result);
    }
Home | Imprint | This part of the site doesn't use cookies.