Пример #1
0
 public function testValidateInput()
 {
     $className = NamespaceSwitcher::getNamespace() . 'ValidatorWrapper';
     $class = new $className();
     $this->assertTrue($class->validateInput(10));
     $this->assertFalse($class->validateInput(-10));
 }
Пример #2
0
 public function testSumNumbersInStringObject()
 {
     $input = new SimpleExample('1,2,3,4,5');
     $className = NamespaceSwitcher::getNamespace() . 'ImprovedTypeHint';
     $output = $className::sumNumbersInString($input);
     $this->assertEquals(15, $output);
 }
Пример #3
0
 /**
  * @expectedException \RuntimeException
  */
 public function testExecuteWithErrorHandling()
 {
     $className = NamespaceSwitcher::getNamespace() . 'ErrorHandler';
     $handler = new $className();
     $handler->executeWithErrorHandling(function () {
         $array->ciao();
     });
 }
Пример #4
0
 /**
  * @dataProvider optionsDataProvider
  */
 public function testParseOptions($options)
 {
     $className = NamespaceSwitcher::getNamespace() . 'OptionsParser';
     $parser = new $className();
     $result = $parser->parseOptions($options);
     $this->assertEquals(isset($options['hostname']) ? $options['hostname'] : 'example.org', $result['hostname']);
     $this->assertEquals(isset($options['username']) ? $options['username'] : '******', $result['username']);
     $this->assertEquals(isset($options['password']) ? $options['password'] : '******', $result['password']);
 }
Пример #5
0
 public function testCompareByAge()
 {
     $personClassName = NamespaceSwitcher::getNamespace() . 'Person';
     $antonio = new $personClassName('Antonio', 34);
     $giovanni = new $personClassName('Giovanni', 12);
     $marco = new $personClassName('Marco', 23);
     $people = [$antonio, $giovanni, $marco];
     usort($people, [$personClassName, 'compareByAge']);
     $this->assertSame($giovanni, $people[0]);
     $this->assertSame($marco, $people[1]);
     $this->assertSame($antonio, $people[2]);
 }
Пример #6
0
 /**
  * @expectedException \DomainException
  */
 public function testCheckDateTimeWithDomainException()
 {
     $dates = [new \DateTime(), new \DateTime(), "2015-11-12 00:00:00"];
     $className = NamespaceSwitcher::getNamespace() . 'VariadicTypeError';
     $className::checkDateTime(...$dates);
 }