public function testIsValid() { $TestVar = new Base(); $this->assertTrue(Base::isValid($TestVar)); $this->assertTrue(Object::isValid($TestVar)); $TestVar = new RESTProcessorA_underTest_isValid(); $this->assertTrue(RESTProcessorA_underTest_isValid::isValid($TestVar)); $this->assertTrue(RESTProcessorA::isValid($TestVar)); $this->assertTrue(ProcessorA::isValid($TestVar)); $this->assertTrue(Object::isValid($TestVar)); $TestVar = new ProcessorA_underTest_isValid(); $this->assertTrue(ProcessorA_underTest_isValid::isValid($TestVar)); $this->assertTrue(ProcessorA::isValid($TestVar)); $this->assertTrue(Object::isValid($TestVar)); $TestVar = new RESTController(); $this->assertTrue(RESTController::isValid($TestVar)); $this->assertTrue(FrontControllerA::isValid($TestVar)); $this->assertTrue(Object::isValid($TestVar)); $TestVar = new FrontControllerA_underTest_isValid(); $this->assertTrue(FrontControllerA_underTest_isValid::isValid($TestVar)); $this->assertTrue(FrontControllerA::isValid($TestVar)); $this->assertTrue(Object::isValid($TestVar)); $TestVar = new ModelA_underTest_isValid(); $this->assertTrue(ModelA_underTest_isValid::isValid($TestVar)); $this->assertTrue(ModelA::isValid($TestVar)); }
/** * @fixme */ public function testGetDefaultViewWithAcceptHeader() { $o = new RESTController(); $oRequest = new PopulatedRESTRequest(); $oRequest->setHttpAccept('application/json'); vsc::getEnv()->setHttpRequest($oRequest); $oDefaultView = $o->getView(); $this->assertInstanceOf(JsonView::class, $oDefaultView); $this->assertInstanceOf(ViewA::class, $oDefaultView); $oRequest->setHttpAccept('application/xml'); $oDefaultView = $o->getView(); // $this->assertInstanceOf(XmlView::class, $oDefaultView); $this->assertInstanceOf(ViewA::class, $oDefaultView); $oRequest->setHttpAccept('application/pdf'); $oDefaultView = $o->getDefaultView(); // $this->assertInstanceOf(StaticFileView::class, $oDefaultView); $this->assertInstanceOf(ViewA::class, $oDefaultView); // $oRequest->setHttpAccept('image/*'); $oDefaultView = $o->getDefaultView(); // $this->assertInstanceOf(StaticFileView::class, $oDefaultView); $this->assertInstanceOf(ViewA::class, $oDefaultView); }
public function testWithNonAuthenticatedProcessorAndMapRequiringAuthentication() { $o = new RESTController(); $_SERVER['PHP_AUTH_USER'] = '******'; $_SERVER['PHP_AUTH_PW'] = '123#'; $_SERVER['CONTENT_TYPE'] = 'application/json'; $_SERVER['REQUEST_METHOD'] = 'GET'; $m = new ProcessorMap(__FILE__, '.*'); $m->setAuthenticationType(HttpAuthenticationA::BASIC); $p = new RESTProcessorA_underTest_getResponse(); $p->validRequestMethods = [HttpRequestTypes::GET]; $p->setMap($m); $r = $o->getResponse(new RESTRequest(), $p); $this->assertInstanceOf(HttpResponse::class, $r); $this->assertEquals(HttpResponseType::NOT_AUTHORIZED, $r->getStatus()); $err = ['message' => 'This resource requires authentication but doesn\'t support any authorization scheme', 'error_code' => HttpResponseType::NOT_AUTHORIZED]; $this->assertJsonStringEqualsJsonString(json_encode($err), $r->getOutput()); }