public function testValidateInput() { $className = NamespaceSwitcher::getNamespace() . 'ValidatorWrapper'; $class = new $className(); $this->assertTrue($class->validateInput(10)); $this->assertFalse($class->validateInput(-10)); }
public function testSumNumbersInStringObject() { $input = new SimpleExample('1,2,3,4,5'); $className = NamespaceSwitcher::getNamespace() . 'ImprovedTypeHint'; $output = $className::sumNumbersInString($input); $this->assertEquals(15, $output); }
/** * @expectedException \RuntimeException */ public function testExecuteWithErrorHandling() { $className = NamespaceSwitcher::getNamespace() . 'ErrorHandler'; $handler = new $className(); $handler->executeWithErrorHandling(function () { $array->ciao(); }); }
/** * @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']); }
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]); }
/** * @expectedException \DomainException */ public function testCheckDateTimeWithDomainException() { $dates = [new \DateTime(), new \DateTime(), "2015-11-12 00:00:00"]; $className = NamespaceSwitcher::getNamespace() . 'VariadicTypeError'; $className::checkDateTime(...$dates); }