/** * @test * @covers ::getSignal * @covers \Hamdrew\AdventOfCode\Day7\CircuitComponent::getSignal * @covers \Hamdrew\AdventOfCode\Day7\CircuitComponent::setSignal */ public function returnsCachedSignal() { $signal = 123; $source = \Mockery::mock('\\Hamdrew\\AdventOfCode\\Day7\\CircuitComponent')->shouldReceive('getSignal')->andReturn($signal)->once()->getMock(); $wire = new Wire('test', $source); $wire->getSignal(); $this->assertSame($signal, $wire->getSignal()); }
/** * @inheritDoc */ public function getSignal() { $signal = parent::getSignal(); if (is_null($signal)) { $input = $this->source->getSignal(); if (!is_null($input)) { $signal = SixteenBitMask::mask(~$input); $this->setSignal($signal); } } return $signal; }
public function testCanSetAndGetSignal() { $wire = new Wire('a'); $wire->setSignal(123); $this->assertEquals(123, $wire->getSignal()); }