/** * @covers getColoredMessage */ public function testGetColoredMessage() { $messageList = ['info' => 'infomessage', 'success' => 'successmessage', 'warning' => 'warningmessage', 'danger' => 'dangermessage']; $reflection = new \ReflectionClass($this->object); $revlectionProperty = $reflection->getProperty('pattern'); $revlectionProperty->setAccessible(TRUE); $objectPattern = $revlectionProperty->getValue($this->object); foreach ($messageList as $messageImportance => $messageText) { $this->assertStringMatchesFormat(sprintf($objectPattern[$messageImportance], $messageText), getColoredMessage($messageText, $messageImportance)); } }
public function changeNYM() { // Connect to the TOR server using password authentication $tc = new TorControl(['hostname' => 'localhost', 'port' => 9051, 'password' => 'new_tor_password', 'authmethod' => 1]); $tc->connect(); $tc->authenticate(); $res = $tc->executeCommand('SIGNAL NEWNYM'); echo getColoredMessage('NYM: ' . $res[0]['code'] . ': ' . $res[0]['message'] . PHP_EOL, 'warning'); $tc->quit(); }