Example #1
0
function RegisterReservations(SlimServer $server, SlimWebServiceRegistry $registry)
{
    $readService = new ReservationsWebService($server, new ReservationViewRepository(), new PrivacyFilter(new ReservationAuthorization(PluginManager::Instance()->LoadAuthorization())), new AttributeService(new AttributeRepository()));
    $writeService = new ReservationWriteWebService($server, new ReservationSaveController(new ReservationPresenterFactory()));
    $category = new SlimWebServiceRegistryCategory('Reservations');
    $category->AddSecurePost('/', array($writeService, 'Create'), WebServices::CreateReservation);
    $category->AddSecureGet('/', array($readService, 'GetReservations'), WebServices::AllReservations);
    $category->AddSecureGet('/:referenceNumber', array($readService, 'GetReservation'), WebServices::GetReservation);
    $category->AddSecurePost('/:referenceNumber', array($writeService, 'Update'), WebServices::UpdateReservation);
    $category->AddSecurePost('/:referenceNumber/Approval', array($writeService, 'Approve'), WebServices::ApproveReservation);
    $category->AddSecureDelete('/:referenceNumber', array($writeService, 'Delete'), WebServices::DeleteReservation);
    $registry->AddCategory($category);
}
 public function testRegistersSecureRoute()
 {
     $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->AddSecurePost($c1p1, $callback, $c1p1name);
     $category1->AddSecureGet($c1p2, $callback, $c1p2name);
     $category1->AddSecureDelete($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));
 }