kahlan\matcher\ToBeCloseTo::description PHP Method

description() public static method

Returns the description report.
public static description ( )
    public static function description()
    {
        return static::$_description;
    }

Usage Example

Beispiel #1
0
            expect(0)->not->toBeCloseTo(0.01);
        });
        it("passes if the difference is lower than the precision", function () {
            expect(0)->toBeCloseTo(0.01, 1);
        });
        it("fails if the difference is higher than the precision", function () {
            expect(0)->not->toBeCloseTo(0.1, 1);
        });
        it("passes if the difference with the round is lower than the default two decimal", function () {
            expect(1.23)->toBeCloseTo(1.225);
            expect(1.23)->toBeCloseTo(1.234);
        });
        it("fails if the difference with the round is lower than the default two decimal", function () {
            expect(1.23)->not->toBeCloseTo(1.2249999);
        });
        it("return false if actual or expected are not a numeric value", function () {
            expect("string")->not->toBeCloseTo(1);
            expect(1)->not->toBeCloseTo("string");
        });
    });
    describe("::description()", function () {
        it("returns the description message", function () {
            ToBeCloseTo::match(1.23, 1.22499991, 2);
            $actual = ToBeCloseTo::description();
            expect($actual['description'])->toBe('be close to expected relying to a precision of 2.');
            expect((string) $actual['data']['actual'])->toBe((string) 1.23);
            expect((string) $actual['data']['expected'])->toBe((string) 1.22499991);
            expect((string) $actual['data']['gap is >='])->toBe((string) 0.005);
        });
    });
});