protected function addSwitchByOrder(DefinedSwitches $expectedOptions, $name, $arg, $isDefaultValue = false)
 {
     $parsedOption = new ParsedSwitch($expectedOptions->getSwitchByName($name));
     $parsedOption->addToInvokeCount();
     $parsedOption->addValue($arg);
     if ($isDefaultValue) {
         $parsedOption->setIsUsingDefaultValue();
     }
     $this->switchesByOrder[] = $parsedOption;
 }
 public function testCanRetrieveSwitchByName()
 {
     $switchName = 'help';
     $switchDesc = 'Display this help message';
     $obj = new DefinedSwitches();
     $origSwitch = $obj->addSwitch($switchName, $switchDesc);
     $origSwitch->setWithShortSwitch('h');
     // did it work?
     $this->assertTrue($obj->testHasSwitchByName($switchName));
     $retrievedSwitch = $obj->getSwitchByName($switchName);
     $this->assertSame($origSwitch, $retrievedSwitch);
     // what happens if we look for a switch that does
     // not exist?
     $notASwitchName = 'version';
     $this->assertFalse($obj->testHasSwitchByName($notASwitchName));
     $caughtException = false;
     try {
         $retrievedSwitch = $obj->getSwitchByName($notASwitchName);
     } catch (\Exception $e) {
         $caughtException = true;
     }
     $this->assertTrue($caughtException);
 }