/** * @covers Phossa\Route\Context\Result::setParameter * @todo Implement testSetParameter(). */ public function testSetParameter() { // set scalar $this->object->setParameter('name', 'name1'); $this->assertEquals('name1', $this->object->getParameter('name')); // set array $this->assertEquals('phossa', $this->object->getParameter('id')); $this->object->setParameter(['name' => 'name1', 'id' => 'wow']); $this->assertEquals('name1', $this->object->getParameter('name')); $this->assertEquals('wow', $this->object->getParameter('id')); }
/** * test regex combination, test GCB * * @covers Phossa\Route\Collector\Collector::match */ public function testMatch31() { $this->object = new Collector(new ParserGcb(), ['chunk' => 3]); $this->object->addRoute(new Route('GET,POST', '/blog1[/{section:xd}][/{year:d}[/{month:d}[/{date:d}]]]', null, ['section' => 'list'])); $this->object->addRoute(new Route('GET,POST', '/blog2[/{section:xd}][/{year:d}[/{month:d}[/{date:d}]]]', null, ['section' => 'list'])); $this->object->addRoute(new Route('GET,POST', '/blog3[/{section:xd}][/{year:d}[/{month:d}[/{date:d}]]]', null, ['section' => 'list'])); $this->object->addRoute(new Route('GET,POST', '/blog4[/{section:xd}][/{year:d}[/{month:d}[/{date:d}]]]', null, ['section' => 'list'])); $this->object->addRoute(new Route('GET,POST', '/blog5[/{section:xd}][/{year:d}[/{month:d}[/{date:d}]]]', null, ['section' => 'list'])); $this->object->addRoute(new Route('GET,POST', '/blog6[/{section:xd}][/{year:d}[/{month:d}[/{date:d}]]]', null, ['section' => 'list'])); $this->object->addRoute(new Route('GET,POST', '/blog7[/{section:xd}][/{year:d}[/{month:d}[/{date:d}]]]', null, ['section' => 'list'])); $res1 = new Result(new Request('GET', '/blog7/')); if ($this->invokeMethod('match', [$res1])) { $this->assertEquals(Status::OK, $res1->getStatus()); $this->assertEquals(['section' => 'list'], $res1->getParameter()); } else { throw new \Exception('bad'); } }