public function it_should_be_able_to_report_the_highest_possible_happiness_change(Permutations $permutations, Person $david, Person $alice, Person $bob, Person $carol) { $realPerms = new Permutations(); $permutations->calculate([0, 1, 2, 3])->shouldBeCalled()->willReturn($realPerms->calculate([0, 1, 2, 3])); $david->happinessChange("Alice")->shouldBeCalled()->willReturn(46); $david->happinessChange("Carol")->shouldBeCalled()->willReturn(41); $david->happinessChange("Bob")->shouldBeCalled()->willReturn(-7); $alice->happinessChange("David")->shouldBeCalled()->willReturn(-2); $alice->happinessChange("Bob")->shouldBeCalled()->willReturn(54); $alice->happinessChange("Carol")->shouldBeCalled()->willReturn(-79); $bob->happinessChange("Alice")->shouldBeCalled()->willReturn(83); $bob->happinessChange("Carol")->shouldBeCalled()->willReturn(-7); $bob->happinessChange("David")->shouldBeCalled()->willReturn(-63); $carol->happinessChange("Bob")->shouldBeCalled()->willReturn(60); $carol->happinessChange("David")->shouldBeCalled()->willReturn(55); $carol->happinessChange("Alice")->shouldBeCalled()->willReturn(-62); $david->name()->shouldBeCalled()->willReturn("David"); $alice->name()->shouldBeCalled()->willReturn("Alice"); $bob->name()->shouldBeCalled()->willReturn("Bob"); $carol->name()->shouldBeCalled()->willReturn("Carol"); $this->highestHappinessChange([$david, $alice, $bob, $carol])->happinessChange()->shouldBe(330); }
public function it_should_be_able_to_calculate_the_longest_possible_route(Permutations $calc, CitiesCollection $cities, City $london, City $belfast, City $dublin) { $london->beConstructedWith(["London", ["Dublin" => 464, "Belfast" => 518]]); $london->distanceTo("Belfast")->shouldBeCalled()->willReturn(518); $london->distanceTo("Dublin")->shouldBeCalled()->willReturn(464); $london->getName()->shouldBeCalled()->willReturn("London"); $belfast->beConstructedWith(["Belfast", ["Dublin" => 141, "London" => 518]]); $belfast->getName()->shouldBeCalled()->willReturn("Belfast"); $belfast->distanceTo("Dublin")->shouldBeCalled()->willReturn(141); $belfast->distanceTo("London")->shouldBeCalled()->willReturn(518); $dublin->beConstructedWith(["Dublin", ["London" => 464, "Belfast" => 141]]); $dublin->distanceTo("Belfast")->shouldBeCalled()->willReturn(141); $dublin->distanceTo("London")->shouldBeCalled()->willReturn(464); $dublin->getName()->shouldBeCalled()->willReturn("Dublin"); $keys = [0, 1, 2]; $cities->keys()->shouldBeCalled()->willReturn($keys); $cities->offsetGet(0)->shouldBeCalled()->willReturn($london); $cities->offsetGet(1)->shouldBeCalled()->willReturn($belfast); $cities->offsetGet(2)->shouldBeCalled()->willReturn($dublin); $calc->calculate($keys)->shouldBeCalled()->willReturn([[0, 1, 2], [0, 2, 1], [1, 2, 0], [1, 0, 2], [2, 1, 0], [2, 0, 1]]); $longestJourney = $this->calculateLongestRoute(); $longestJourney->shouldBeAnInstanceOf(SantaJourney::class); $longestJourney->distance()->shouldBe(982); }