public function testRegistersAdminRoute()
 {
     $callback = array($this, 'cb');
     $slim = new TestSlim();
     $registry = new SlimWebServiceRegistry($slim);
     $c1Name = 'Something';
     $category1 = new SlimWebServiceRegistryCategory($c1Name);
     $c1p1 = '/post/1/';
     $c1p2 = '/get/:1';
     $c1p3 = '/delete/:1';
     $c1p1name = 'c1p1name';
     $c1p2name = 'c1p2name';
     $c1p3name = 'c1p3name';
     $category1->AddAdminPost($c1p1, $callback, $c1p1name);
     $category1->AddAdminGet($c1p2, $callback, $c1p2name);
     $category1->AddAdminDelete($c1p3, $callback, $c1p3name);
     $registry->AddCategory($category1);
     $this->assertEquals('/Something/post/1', $slim->posts[0]->route);
     $this->assertEquals($callback, $slim->posts[0]->callback);
     $this->assertEquals($c1p1name, $slim->posts[0]->name());
     $this->assertEquals('/Something/get/:1', $slim->gets[0]->route);
     $this->assertEquals($c1p2name, $slim->gets[0]->name());
     $this->assertEquals($callback, $slim->gets[0]->callback);
     $this->assertEquals('/Something/delete/:1', $slim->deletes[0]->route);
     $this->assertEquals($c1p3name, $slim->deletes[0]->name());
     $this->assertEquals($callback, $slim->deletes[0]->callback);
     $this->assertTrue($registry->IsSecure($c1p1name));
     $this->assertTrue($registry->IsSecure($c1p2name));
     $this->assertTrue($registry->IsSecure($c1p3name));
     $this->assertTrue($registry->IsLimitedToAdmin($c1p1name));
     $this->assertTrue($registry->IsLimitedToAdmin($c1p2name));
     $this->assertTrue($registry->IsLimitedToAdmin($c1p3name));
 }
Ejemplo n.º 2
0
function RegisterUsers(SlimServer $server, SlimWebServiceRegistry $registry)
{
    $attributeService = new AttributeService(new AttributeRepository());
    $webService = new UsersWebService($server, new UserRepositoryFactory(), $attributeService);
    $writeWebService = new UsersWriteWebService($server, new UserSaveController(new ManageUsersServiceFactory(), new UserRequestValidator($attributeService, new UserRepository())));
    $category = new SlimWebServiceRegistryCategory('Users');
    $category->AddSecureGet('/', array($webService, 'GetUsers'), WebServices::AllUsers);
    $category->AddSecureGet('/:userId', array($webService, 'GetUser'), WebServices::GetUser);
    $category->AddAdminPost('/', array($writeWebService, 'Create'), WebServices::CreateUser);
    $category->AddAdminPost('/:userId', array($writeWebService, 'Update'), WebServices::UpdateUser);
    $category->AddAdminDelete('/:userId', array($writeWebService, 'Delete'), WebServices::DeleteUser);
    $registry->AddCategory($category);
}
Ejemplo n.º 3
0
function RegisterAttributes(SlimServer $server, SlimWebServiceRegistry $registry)
{
    $webService = new AttributesWebService($server, new AttributeService(new AttributeRepository()));
    $writeWebService = new AttributesWriteWebService($server, new AttributeSaveController(new AttributeRepository()));
    $category = new SlimWebServiceRegistryCategory('Attributes');
    $category->AddSecureGet('Category/:categoryId', array($webService, 'GetAttributes'), WebServices::AllCustomAttributes);
    $category->AddSecureGet('/:attributeId', array($webService, 'GetAttribute'), WebServices::GetCustomAttribute);
    $category->AddAdminPost('/', array($writeWebService, 'Create'), WebServices::CreateCustomAttribute);
    $category->AddAdminPost('/:attributeId', array($writeWebService, 'Update'), WebServices::UpdateCustomAttribute);
    $category->AddAdminDelete('/:attributeId', array($writeWebService, 'Delete'), WebServices::DeleteCustomAttribute);
    $registry->AddCategory($category);
}