public function testSendPacketAsMaster() { $packet = new Packet(); $this->driver->expects($this->once())->method('write')->with($packet); $this->posix->expects($this->once())->method('getPid')->willReturn(10); $this->signalHandler->expects($this->once())->method('send')->willReturnCallback(function ($signal) { $this->assertInstanceOf('\\Thruster\\Components\\PosixSignalHandler\\Signal', $signal); $this->assertSame(SIGUSR1, $signal->getSignalNo()); $this->assertSame(10, $signal->getDestination()); return $this->signalHandler; }); $this->connection->setMasterMode(); $this->connection->sendPacket($packet); }
/** * Adds connection to list and sets connection to master mode * * @param Connection $connection * * @return $this */ public function addConnection(Connection $connection) { $connection->setMasterMode(); $connection->onPacketReceived([$this, 'receivedPacket']); $this->connections[$connection->getPid()] = $connection; return $this; }