Ejemplo n.º 1
0
 public function testValidateInput()
 {
     $className = NamespaceSwitcher::getNamespace() . 'ValidatorWrapper';
     $class = new $className();
     $this->assertTrue($class->validateInput(10));
     $this->assertFalse($class->validateInput(-10));
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 3
0
 /**
  * @expectedException \RuntimeException
  */
 public function testExecuteWithErrorHandling()
 {
     $className = NamespaceSwitcher::getNamespace() . 'ErrorHandler';
     $handler = new $className();
     $handler->executeWithErrorHandling(function () {
         $array->ciao();
     });
 }
Ejemplo n.º 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']);
 }
Ejemplo n.º 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]);
 }
Ejemplo n.º 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);
 }