Ejemplo n.º 1
0
 public function test_get_registerWorkflow()
 {
     $workflow = new MockWorkflow();
     $mapper = $this->getMock('Midgard\\CreatePHP\\RdfMapperInterface');
     $restHandler = new RestService($mapper);
     $restHandler->registerWorkflow('mock', $workflow);
     $expected = array(array('name' => "mockbutton", 'label' => 'Mock Label', 'action' => array('type' => "backbone_destroy"), 'type' => "button"));
     $this->assertEquals($expected, $restHandler->getWorkflows('test1'));
 }
Ejemplo n.º 2
0
 public function testRunPost()
 {
     $this->mapper->expects($this->once())->method('prepareObject')->with($this->equalTo($this->child_type))->will($this->returnValue('testmodel'));
     $this->type->expects($this->any())->method('getRevOptions')->will($this->returnValue(array('dcterms:partOf')));
     $this->type->expects($this->any())->method('createWithObject')->will($this->returnValue($this->entity));
     $rest = new RestService($this->mapper);
     $data = array('<http://purl.org/dc/terms/title>' => 'the title', '<http://purl.org/dc/terms/partOf>' => array('</parent/subject>'));
     $return = $rest->run($data, $this->type, null, RestService::HTTP_POST);
     $this->assertEquals(array('@subject' => '</the/subject>', '<http://purl.org/dc/terms/title>' => 'stored title'), $return);
 }
Ejemplo n.º 3
0
 /**
  * Get available Workflows for a document.
  *
  * @param Request $request
  * @param string  $subject
  *
  * @return Response
  *
  * @throws AccessDeniedException If getting workflows for this document is
  *                               not allowed by the access checker.
  */
 public function workflowsAction(Request $request, $subject)
 {
     if (!$this->accessChecker->check($request)) {
         throw new AccessDeniedException();
     }
     $result = $this->restHandler->getWorkflows($subject);
     $view = View::create($result)->setFormat('json');
     return $this->viewHandler->handle($view, $request);
 }