<?php
namespace Hamdrew\AdventOfCode\Day3;

use Hamdrew\AdventOfCode\InputProvider;
use Hamdrew\AdventOfCode\TestWithContainer;

/**
 * @covers \Hamdrew\AdventOfCode\Day3\SolutionDay3
 */
class SolutionDay3Test extends TestWithContainer
{
    /**
     * @test
     * @runInSeparateProcess
     * @preserveGlobalState disabled
     */
    public function part1Solution()
    {
        $this->container->set(
            InputProvider::class,
            \Mockery::mock('alias:\Hamdrew\AdventOfCode\InputProvider')->shouldReceive('getInputFromFileForDay')
                ->with(3)->getMock()
        );
        \Mockery::mock('alias:\Hamdrew\AdventOfCode\Day3\RouteParser')
            ->shouldReceive('parse');
        \Mockery::mock('alias:\Hamdrew\AdventOfCode\Day3\RouteAnalyser')
            ->shouldReceive('uniqueVisitCount')->andReturn(123);
        $this->assertSame('123', $this->container->get(SolutionDay3::class)->part1());
    }

    /**
     * @test
     * @runInSeparateProcess
     * @preserveGlobalState disabled
     */
    public function part2Solution()
    {
        $instructions = \Mockery::mock('\Hamdrew\AdventOfCode\Day3\ComboInstructions');
        $instructions->shouldReceive('getSanta');
        $instructions->shouldReceive('getRoboSanta');
        $route = \Mockery::mock('\Hamdrew\AdventOfCode\Day3\Route')
            ->shouldReceive('getRoute')->andReturn([])->getMock();

        $this->container->set(
            InputProvider::class,
            \Mockery::mock('alias:\Hamdrew\AdventOfCode\InputProvider')->shouldReceive('getInputFromFileForDay')
                ->with(3)->getMock()
        );
        \Mockery::mock('alias:\Hamdrew\AdventOfCode\Day3\InstructionsSplitter')
            ->shouldReceive('splitInstructions')->andReturn($instructions);
        \Mockery::mock('alias:\Hamdrew\AdventOfCode\Day3\RouteParser')
            ->shouldReceive('parse')->andReturn($route);
        \Mockery::mock('alias:\Hamdrew\AdventOfCode\Day3\RouteAnalyser')
            ->shouldReceive('uniqueVisitCount')->andReturn(123);

        $this->assertSame('123', $this->container->get(SolutionDay3::class)->part2());
    }
}
