コード例 #1
0
 /**
  * Testing the encodeQuery method with a known encrypted result for a test key.
  *
  * @since 1.0
  */
 public function testEncodeQuery()
 {
     $config = ConfigProvider::getInstance();
     $oldKey = $config->get('security.encryption.key');
     $config->set('security.encryption.key', 'testkey12345678901234567');
     $params = 'act=ViewArticleTitle&title=Test_Title';
     $this->assertEquals('7eYCDOP1AFAv2Kc45D2eSgFM1dJ2mboM4fMMMjs3PP6cb8Qafsv0L06zZjWeIWRH', FrontController::encodeQuery($params), 'testing the encodeQuery method with a known encrypted result for a test key');
     $config->set('security.encryption.key', $oldKey);
 }
コード例 #2
0
 /**
  * Testing the doDELETE method.
  */
 public function testDoDELETE()
 {
     $config = ConfigProvider::getInstance();
     $sessionProvider = $config->get('session.provider.name');
     $session = SessionProviderFactory::getInstance($sessionProvider);
     $front = new FrontController();
     $controller = new ActiveRecordController();
     $securityParams = $controller->generateSecurityFields();
     $person = $this->createPersonObject('test');
     $person->save();
     $params = array('var1' => $securityParams[0], 'var2' => $securityParams[1]);
     $request = new Request(array('method' => 'DELETE', 'URI' => '/record/' . urlencode('Alpha\\Model\\Person') . '/' . $person->getOID(), 'params' => $params));
     $response = $front->process($request);
     $this->assertEquals(301, $response->getStatus(), 'Testing the doDELETE method');
     $this->assertTrue(strpos($response->getHeader('Location'), '/records/' . urlencode('Alpha\\Model\\Person')) !== false, 'Testing the doDELETE method');
     $person = $this->createPersonObject('test');
     $person->save();
     $params = array('var1' => $securityParams[0], 'var2' => $securityParams[1]);
     $request = new Request(array('method' => 'DELETE', 'URI' => '/tk/' . FrontController::encodeQuery('act=Alpha\\Controller\\ActiveRecordController&ActiveRecordType=Alpha\\Model\\Person&ActiveRecordOID=' . $person->getOID()), 'params' => $params));
     $response = $front->process($request);
     $this->assertEquals(301, $response->getStatus(), 'Testing the doDELETE method');
     $this->assertTrue(strpos($response->getHeader('Location'), '/tk/') !== false, 'Testing the doDELETE method');
     $person = $this->createPersonObject('test');
     $person->save();
     $request = new Request(array('method' => 'DELETE', 'URI' => '/record/' . urlencode('Alpha\\Model\\Person') . '/' . $person->getOID(), 'params' => $params, 'headers' => array('Accept' => 'application/json')));
     $response = $front->process($request);
     $this->assertEquals(200, $response->getStatus(), 'Testing the doDELETE method');
     $this->assertEquals('application/json', $response->getHeader('Content-Type'), 'Testing the doDELETE method');
     $this->assertEquals('deleted', json_decode($response->getBody())->message, 'Testing the doDELETE method');
 }