cli-barcode PHP
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 

40 řádky
1.1 KiB

  1. <?php
  2. namespace Ulrichsg\Getopt;
  3. class ArgumentTest extends \PHPUnit_Framework_TestCase
  4. {
  5. public function testConstructor()
  6. {
  7. $argument1 = new Argument();
  8. $argument2 = new Argument(10);
  9. $this->assertFalse($argument1->hasDefaultValue());
  10. $this->assertEquals(10, $argument2->getDefaultValue());
  11. }
  12. public function testSetDefaultValueNotScalar()
  13. {
  14. $this->setExpectedException('InvalidArgumentException');
  15. $argument = new Argument();
  16. $argument->setDefaultValue(array());
  17. }
  18. public function testValidates()
  19. {
  20. $test = $this;
  21. $argument = new Argument();
  22. $argument->setValidation(function($arg) use ($test, $argument) {
  23. $test->assertEquals('test', $arg);
  24. return true;
  25. });
  26. $this->assertTrue($argument->hasValidation());
  27. $this->assertTrue($argument->validates('test'));
  28. }
  29. public function testSetValidationUncallable()
  30. {
  31. $this->setExpectedException('InvalidArgumentException');
  32. $argument = new Argument();
  33. $argument->setValidation('');
  34. }
  35. }