/** * @param array $params * @param array $expectedParams * * @dataProvider paramsDataProvider */ public function testRouteParameters($params, array $expectedParams) { $map = []; foreach ($params as $name => $value) { $map[] = [$name, null, $value]; } $this->route->expects($this->any())->method('getMatchedParam')->willReturnMap($map); $this->haikunator->expects($this->atLeastOnce())->method('__invoke')->with($expectedParams); $this->command->__invoke($this->route, $this->console); }
public function testEverythingInOne() { Haikunator::$ADJECTIVES = ['green']; Haikunator::$NOUNS = ['reindeer']; $haikunate = Haikunator::haikunate(["delimiter" => ".", "tokenLength" => 8, "tokenChars" => "l"]); $this->assertRegExp("/(green)(\\.)(reindeer)(\\.)(llllllll)\$/i", $haikunate); }
/** * @param Route $route */ protected function setAdjectivesFromRoute(Route $route) { $adjectives = $route->getMatchedParam('adjectives'); if (!empty($adjectives)) { Haikunator::$ADJECTIVES = $this->getValuesFromFileIfExists($adjectives); } }
public function testCanBeUsedAsCallable() { Haikunator::$ADJECTIVES = ['green']; Haikunator::$NOUNS = ['reindeer']; $haikunator = new Haikunator(); $this->assertTrue(is_callable($haikunator)); $params = ['tokenLength' => 0]; $this->assertSame($haikunator($params), Haikunator::haikunate($params)); }