Ejemplo n.º 1
0
 public function testMatchesWithConditionsIsFalse()
 {
     $route = new \Slim\Route('/hello/:first/and/:second', function () {
     });
     $route->conditions(array('first' => '[a-z]{3,}'));
     $this->assertFalse($route->matches('/hello/Josh/and/John'));
 }
Ejemplo n.º 2
0
 /**
  * Test route default conditions
  *
  * Pre-conditions:
  * Route class has default conditions;
  *
  * Post-conditions:
  * Case A: Route instance has default conditions;
  * Case B: Route instance has newly merged conditions;
  */
 public function testRouteDefaultConditions()
 {
     \Slim\Route::setDefaultConditions(array('id' => '\\d+'));
     $r = new \Slim\Route('/foo', function () {
     });
     //Case A
     $this->assertEquals(\Slim\Route::getDefaultConditions(), $r->getConditions());
     //Case B
     $r->conditions(array('name' => '[a-z]{2,5}'));
     $c = $r->getConditions();
     $this->assertArrayHasKey('id', $c);
     $this->assertArrayHasKey('name', $c);
 }