Example #1
0
 /** @test */
 public function TestParseCommandOption()
 {
     /*//
     	test that input data as expected the way they come from _SERVER['argv']
     	parses as valid option switches.
     	//*/
     $this->AssertFalse(Nether\Console\Client::ParseCommandOption('onlytest'));
     ///////
     ///////
     $option = Nether\Console\Client::ParseCommandOption('--onlytest');
     $this->AssertTrue(array_key_exists('onlytest', $option) && $option['onlytest'] === true, 'test long option with boolean value');
     $option = Nether\Console\Client::ParseCommandOption('--onlytest=true');
     $this->AssertTrue(array_key_exists('onlytest', $option) && $option['onlytest'] === 'true', 'test long option with string value');
     $option = Nether\Console\Client::ParseCommandOption('--onlytest=true for sure');
     $this->AssertTrue(array_key_exists('onlytest', $option) && $option['onlytest'] === 'true for sure', 'test long option with spaced string value');
     ///////
     ///////
     $option = Nether\Console\Client::ParseCommandOption('-zomg');
     $this->AssertTrue(is_array($option) && count($option) === 4, 'test single character options parsing');
     foreach (['z', 'o', 'm', 'g'] as $l) {
         $this->AssertTrue(array_key_exists($l, $option) && $option[$l] === true, 'test single character option values');
     }
     unset($l);
     ///////
     ///////
     $option = Nether\Console\Client::ParseCommandOption('-zomg=bbq');
     $this->AssertTrue(is_array($option) && count($option) === 4, 'test single character options parsing with final string value');
     foreach (['z' => true, 'o' => true, 'm' => true, 'g' => 'bbq'] as $l => $v) {
         $this->AssertTrue(array_key_exists($l, $option) && $option[$l] === $v, 'test single character option values with final string value');
     }
     unset($l, $v);
     ///////
     ///////
     return;
 }