ComparisonTest_Class example



    public static function provideValidComparisons(): array
    {
        return [
            [3, 3],
            [3, '3'],
            ['a', 'a'],
            [new \DateTime('2000-01-01')new \DateTime('2000-01-01')],
            [new \DateTime('2000-01-01'), '2000-01-01'],
            [new \DateTime('2000-01-01 UTC'), '2000-01-01 UTC'],
            [new ComparisonTest_Class(5)new ComparisonTest_Class(5)],
            [null, 1],
        ];
    }

    public static function provideValidComparisonsToPropertyPath(): array
    {
        return [
            [5],
        ];
    }

    
        // not take care of identical objects         $comparisons = self::provideInvalidComparisons();

        date_default_timezone_set($timezone);

        return $comparisons;
    }

    public static function provideInvalidComparisons(): array
    {
        $date = new \DateTime('2000-01-01');
        $object = new ComparisonTest_Class(2);

        $comparisons = [
            [3, '3', 3, '3', 'int'],
            ['a', '"a"', 'a', '"a"', 'string'],
            [$date, 'Jan 1, 2000, 12:00 AM', $date, 'Jan 1, 2000, 12:00 AM', 'DateTime'],
            [$object, '2', $object, '2', __NAMESPACE__.'\ComparisonTest_Class'],
        ];

        return $comparisons;
    }

    
return $comparisons;
    }

    /** * @dataProvider provideValidComparisonsToPropertyPath */
    public function testValidComparisonToPropertyPath($comparedValue)
    {
        $constraint = $this->createConstraint(['propertyPath' => 'value']);

        $object = new ComparisonTest_Class(5);

        $this->setObject($object);

        $this->validator->validate($comparedValue$constraint);

        $this->assertNoViolation();
    }

    public function testNoViolationOnNullObjectWithPropertyPath()
    {
        $constraint = $this->createConstraint(['propertyPath' => 'propertyPath']);

        

        return GreaterThan::TOO_LOW_ERROR;
    }

    public static function provideValidComparisons(): array
    {
        return [
            [2, 1],
            [new \DateTime('2005/01/01')new \DateTime('2001/01/01')],
            [new \DateTime('2005/01/01'), '2001/01/01'],
            [new \DateTime('2005/01/01 UTC'), '2001/01/01 UTC'],
            [new ComparisonTest_Class(5)new ComparisonTest_Class(4)],
            ['333', '22'],
            [null, 1],
        ];
    }

    public static function provideValidComparisonsToPropertyPath(): array
    {
        return [
            [6],
        ];
    }

    
return NotEqualTo::IS_EQUAL_ERROR;
    }

    public static function provideValidComparisons(): array
    {
        return [
            [1, 2],
            ['22', '333'],
            [new \DateTime('2001-01-01')new \DateTime('2000-01-01')],
            [new \DateTime('2001-01-01'), '2000-01-01'],
            [new \DateTime('2001-01-01 UTC'), '2000-01-01 UTC'],
            [new ComparisonTest_Class(6)new ComparisonTest_Class(5)],
            [null, 1],
        ];
    }

    public static function provideValidComparisonsToPropertyPath(): array
    {
        return [
            [0],
        ];
    }

    
public static function provideValidComparisons(): array
    {
        return [
            [1, 2],
            [1, 1],
            [new \DateTime('2000-01-01')new \DateTime('2000-01-01')],
            [new \DateTime('2000-01-01')new \DateTime('2020-01-01')],
            [new \DateTime('2000-01-01'), '2000-01-01'],
            [new \DateTime('2000-01-01'), '2020-01-01'],
            [new \DateTime('2000-01-01 UTC'), '2000-01-01 UTC'],
            [new \DateTime('2000-01-01 UTC'), '2020-01-01 UTC'],
            [new ComparisonTest_Class(4)new ComparisonTest_Class(5)],
            [new ComparisonTest_Class(5)new ComparisonTest_Class(5)],
            ['a', 'a'],
            ['a', 'z'],
            [null, 1],
        ];
    }

    public static function provideValidComparisonsToPropertyPath(): array
    {
        return [
            [4],
            [
        // not take care of identical objects         $comparisons = self::provideValidComparisons();

        date_default_timezone_set($timezone);

        return $comparisons;
    }

    public static function provideValidComparisons(): array
    {
        $date = new \DateTime('2000-01-01');
        $object = new ComparisonTest_Class(2);

        $comparisons = [
            [3, 3],
            ['a', 'a'],
            [$date$date],
            [$object$object],
            [null, 1],
        ];

        $immutableDate = new \DateTimeImmutable('2000-01-01');
        $comparisons[] = [$immutableDate$immutableDate];

        

        return LessThan::TOO_HIGH_ERROR;
    }

    public static function provideValidComparisons(): array
    {
        return [
            [1, 2],
            [new \DateTime('2000-01-01')new \DateTime('2010-01-01')],
            [new \DateTime('2000-01-01'), '2010-01-01'],
            [new \DateTime('2000-01-01 UTC'), '2010-01-01 UTC'],
            [new ComparisonTest_Class(4)new ComparisonTest_Class(5)],
            ['22', '333'],
            [null, 1],
        ];
    }

    public static function provideValidComparisonsToPropertyPath(): array
    {
        return [
            [4],
        ];
    }

    
Home | Imprint | This part of the site doesn't use cookies.