コード例 #1
0
 public function testRegistersCategoryWithSlim()
 {
     $callback = array($this, 'cb');
     $slim = new TestSlim();
     $registry = new SlimWebServiceRegistry($slim);
     $c1Name = 'Something';
     $c2Name = 'SomethingElse';
     $category1 = new SlimWebServiceRegistryCategory($c1Name);
     $category2 = new SlimWebServiceRegistryCategory($c2Name);
     $c1p1 = '/post/1/';
     $c1p2 = '/get/:1';
     $c1p3 = '/delete/:1';
     $c2p1 = 'post/2/';
     $c2p2 = 'get/:2';
     $c2p3 = 'delete/:2';
     $c1p1name = 'c1p1name';
     $c1p2name = 'c1p2name';
     $c1p3name = 'c1p3name';
     $category1->AddPost($c1p1, $callback, $c1p1name);
     $category1->AddGet($c1p2, $callback, $c1p2name);
     $category1->AddDelete($c1p3, $callback, $c1p3name);
     $category2->AddPost($c2p1, $callback, '2');
     $category2->AddGet($c2p2, $callback, '3');
     $category2->AddDelete($c2p3, $callback, '4');
     $registry->AddCategory($category1);
     $registry->AddCategory($category2);
     $this->assertEquals('/Something/post/1', $slim->posts[0]->route);
     $this->assertEquals($callback, $slim->posts[0]->callback);
     $this->assertEquals($c1p1name, $slim->posts[0]->name());
     $this->assertFalse($registry->IsSecure($c1p1name));
     $this->assertEquals('/Something/get/:1', $slim->gets[0]->route);
     $this->assertEquals($c1p2name, $slim->gets[0]->name());
     $this->assertEquals($callback, $slim->gets[0]->callback);
     $this->assertFalse($registry->IsSecure($c1p2name));
     $this->assertEquals('/Something/delete/:1', $slim->deletes[0]->route);
     $this->assertEquals($c1p3name, $slim->deletes[0]->name());
     $this->assertEquals($callback, $slim->deletes[0]->callback);
     $this->assertFalse($registry->IsSecure($c1p3name));
     $this->assertEquals('/SomethingElse/post/2', $slim->posts[1]->route);
     $this->assertEquals($callback, $slim->posts[1]->callback);
     $this->assertEquals('/SomethingElse/get/:2', $slim->gets[1]->route);
     $this->assertEquals($callback, $slim->gets[1]->callback);
     $this->assertEquals('/SomethingElse/delete/:2', $slim->deletes[1]->route);
     $this->assertEquals($callback, $slim->deletes[1]->callback);
 }