public function testChargeChildren()
 {
     $toystory = new Movie('Toy Story', Movie::CHILDREN);
     $this->assertEquals(1.5, $toystory->getCharge(2));
     $this->assertEquals(1.5, $toystory->getCharge(3));
     $this->assertEquals(3, $toystory->getCharge(4));
 }
            expect($toystory->getPriceCode())->toBe(Movie::CHILDREN);
        });
        it("returns the `Movie::NEW_RELEASE` price for newly released movies", function () {
            $skyfall = new Movie('Skyfall', Movie::NEW_RELEASE);
            expect($skyfall->getPriceCode())->toBe(Movie::NEW_RELEASE);
        });
        it("throws an `InvalidArgumentException` when using an invalid price code", function () {
            $closure = function () {
                $killbill = new Movie('Kill Bill', 999);
            };
            expect($closure)->toThrow(new InvalidArgumentException("Incorrect Price Code"));
        });
    });
    describe("->getCharge()", function () {
        it("gets regular movie charge", function () {
            $sw = new Movie('Star Wars', Movie::REGULAR);
            expect($sw->getCharge(1))->toBe(2);
            expect($sw->getCharge(3))->toBe(3.5);
        });
        it("gets children movie charge", function () {
            $toystory = new Movie('Toy Story', Movie::CHILDREN);
            expect($toystory->getCharge(2))->toBe(1.5);
            expect($toystory->getCharge(3))->toBe(1.5);
            expect($toystory->getCharge(4))->toBe(3.0);
        });
        it("gets new released movie charge", function () {
            $skyfall = new Movie('Skyfall', Movie::NEW_RELEASE);
            expect($skyfall->getCharge(2))->toBe(6);
        });
    });
});
Beispiel #3
0
 public function getCharge()
 {
     return $this->movie->getCharge($this->daysRented);
 }