public function testGetFirstParameter()
 {
     $o = new PopulatedRequest();
     $this->assertEquals('module', $o->getFirstParameter());
     $o->setTaintedVars(array('ana' => uniqid('val:')));
     $this->assertEquals('ana', $o->getFirstParameter());
 }
Example #2
0
 public function testHasCookieVar()
 {
     $o = new PopulatedRequest();
     // Cookie var
     $this->assertTrue($o->hasCookieVar('user'));
     // 'user' => 'asddsasdad234'
 }
Example #3
0
 public function testGetVars()
 {
     $o = new PopulatedRequest();
     $ExistingTaintedVars = array('module' => 'test', 'cucu' => 'mucu', 'height' => 143);
     $ExistingGetVars = array('cucu' => 'pasare', 'ana' => 'are', 'mere' => '', 'test' => 123);
     $ExistingPostVars = array('postone' => 'are', 'ana' => '');
     $ExistingCookieVars = array('user' => 'asddsasdad234');
     $ExistingVars = array();
     $VarOrder = $o->getVarOrder();
     foreach ($VarOrder as $sMethod) {
         switch ($sMethod) {
             case 'S':
                 break;
             case 'C':
                 $ExistingVars = array_merge($ExistingVars, $ExistingCookieVars);
                 break;
             case 'P':
                 $ExistingVars = array_merge($ExistingVars, $ExistingPostVars);
                 break;
             case 'G':
                 $ExistingVars = array_merge($ExistingVars, $ExistingGetVars);
                 break;
         }
     }
     $this->assertEquals(array_merge($ExistingTaintedVars, $ExistingVars), $o->getVars());
 }
Example #4
0
 public function testHasGetVarsAfterUnset()
 {
     $o = new PopulatedRequest();
     $o->setGetVars(null);
     $this->assertFalse($o->hasGetVars());
     $o->setGetVars(array('ana' => 'mere'));
     $this->assertTrue($o->hasGetVars());
 }
Example #5
0
 public function testHasPostVar()
 {
     $o = new PopulatedRequest();
     // POST var
     $this->assertTrue($o->hasPostVar('postone'));
     // 'postone' => 'are', 'ana' => ''
     $this->assertTrue($o->hasPostVar('ana'));
 }
Example #6
0
 public function testHasGetVar()
 {
     $o = new PopulatedRequest();
     // GET var
     $this->assertTrue($o->hasGetVar('cucu'));
     // 'cucu' => 'pasare','ana' => 'are', 'mere' => '', 'test' => 123
     $this->assertTrue($o->hasGetVar('ana'));
     $this->assertTrue($o->hasGetVar('test'));
 }
Example #7
0
 public function testGetVarOrder()
 {
     $o = new PopulatedRequest();
     $sOrder = ini_get('variables_order');
     for ($i = 0; $i < 4; $i++) {
         // reversing the order
         $VarOrder[$i] = substr($sOrder, $i, 1);
     }
     $this->assertSame($VarOrder, $o->getVarOrder());
 }
Example #8
0
 public function testSetTaintedVars()
 {
     $o = new PopulatedRequest();
     $ExistingTaintedVars = array('module' => 'test', 'cucu' => 'mucu', 'height' => 143);
     $this->assertEquals($ExistingTaintedVars, $o->getTaintedVars());
     $NewTaintedVars = array('ana' => uniqid('val1:'), 'are' => uniqid('val2:'), 'mere' => uniqid('val3:'));
     $o->setTaintedVars($NewTaintedVars);
     $this->assertNotEquals($ExistingTaintedVars, $o->getTaintedVars());
     $this->assertEquals(array_merge($ExistingTaintedVars, $NewTaintedVars), $o->getTaintedVars());
 }
Example #9
0
 public function testHasSessionVar()
 {
     PopulatedRequest::startSession();
     $o = new PopulatedRequest();
     $o->setSessionVar('ala', uniqid('ala:'));
     $o->setSessionVar('bala', '##');
     // Session var
     $this->assertTrue($o->hasSessionVar('ala'));
     // 'ala' => uniqid('ala:'), 'bala' => '##'
     $this->assertTrue($o->hasSessionVar('bala'));
 }
 public function testGetProcessController404()
 {
     $sFixturePath = VSC_FIXTURE_PATH . 'config' . DIRECTORY_SEPARATOR;
     $o = new RwDispatcher();
     $o->loadSiteMap($sFixturePath . 'map.php');
     $oRequest = new PopulatedRequest();
     $oRequest->setUri(uniqid());
     vsc::getEnv()->setHttpRequest($oRequest);
     $oProcess = $o->getProcessController();
     $this->assertInstanceOf(NotFoundProcessor::class, $oProcess);
 }
Example #11
0
 public function testGetTaintedVars()
 {
     $o = new PopulatedRequest();
     $ExistingTaintedVars = array('module' => 'test', 'cucu' => 'mucu', 'height' => 143);
     $this->assertEquals($ExistingTaintedVars, $o->getTaintedVars());
     $NewTaintedVars = array_merge($ExistingTaintedVars, array('ana' => uniqid('val1:'), 'are' => uniqid('val2:'), 'mere' => uniqid('val3:')));
     $o->setTaintedVars($NewTaintedVars);
     $this->assertEquals($NewTaintedVars, $o->getTaintedVars());
     $RandomInexistentVars = array(uniqid('key_') => uniqid('val:'), uniqid('key_') => uniqid('val:'), 'tst' => uniqid('val:'));
     foreach ($RandomInexistentVars as $Key => $Value) {
         $this->assertArrayNotHasKey($Key, $o->getTaintedVars());
     }
 }
Example #12
0
 public function testIsDelete()
 {
     $o = new PopulatedRequest();
     $o->setHttpMethod(HttpRequestTypes::DELETE);
     $this->assertFalse($o->isHead());
     $this->assertFalse($o->isGet());
     $this->assertFalse($o->isPost());
     $this->assertFalse($o->isPut());
     $this->assertTrue($o->isDelete());
 }
Example #13
0
 public function testAccepts()
 {
     $o = new PopulatedRequest();
     $Everything = '*/*';
     $Image = 'image/*';
     $Png = 'image/png';
     $Gif = 'image/gif';
     $Application = 'application/*';
     $Xml = 'application/xml';
     $Json = 'application/json';
     $o->setHttpAccept($Png);
     $this->assertFalse($o->accepts($Everything));
     $this->assertFalse($o->accepts($Application));
     $this->assertFalse($o->accepts($Xml));
     $this->assertFalse($o->accepts($Json));
     $this->assertFalse($o->accepts($Image));
     $this->assertTrue($o->accepts($Png));
     $this->assertFalse($o->accepts($Gif));
     $o->setHttpAccept($Gif);
     $this->assertFalse($o->accepts($Everything));
     $this->assertFalse($o->accepts($Application));
     $this->assertFalse($o->accepts($Xml));
     $this->assertFalse($o->accepts($Json));
     $this->assertFalse($o->accepts($Image));
     $this->assertFalse($o->accepts($Png));
     $this->assertTrue($o->accepts($Gif));
     $o->setHttpAccept($Image);
     $this->assertFalse($o->accepts($Everything));
     $this->assertFalse($o->accepts($Application));
     $this->assertFalse($o->accepts($Xml));
     $this->assertFalse($o->accepts($Json));
     $this->assertTrue($o->accepts($Image));
     $this->assertTrue($o->accepts($Png));
     $this->assertTrue($o->accepts($Gif));
     $o->setHttpAccept($Application);
     $this->assertFalse($o->accepts($Everything));
     $this->assertTrue($o->accepts($Application));
     $this->assertTrue($o->accepts($Xml));
     $this->assertTrue($o->accepts($Json));
     $this->assertFalse($o->accepts($Image));
     $this->assertFalse($o->accepts($Png));
     $this->assertFalse($o->accepts($Gif));
     $o->setHttpAccept($Json);
     $this->assertFalse($o->accepts($Everything));
     $this->assertFalse($o->accepts($Application));
     $this->assertFalse($o->accepts($Xml));
     $this->assertTrue($o->accepts($Json));
     $this->assertFalse($o->accepts($Image));
     $this->assertFalse($o->accepts($Png));
     $this->assertFalse($o->accepts($Gif));
     $o->setHttpAccept($Xml);
     $this->assertFalse($o->accepts($Everything));
     $this->assertFalse($o->accepts($Application));
     $this->assertTrue($o->accepts($Xml));
     $this->assertFalse($o->accepts($Json));
     $this->assertFalse($o->accepts($Image));
     $this->assertFalse($o->accepts($Png));
     $this->assertFalse($o->accepts($Gif));
     $o->setHttpAccept($Everything);
     $this->assertTrue($o->accepts($Everything));
     $this->assertTrue($o->accepts($Application));
     $this->assertTrue($o->accepts($Xml));
     $this->assertTrue($o->accepts($Json));
     $this->assertTrue($o->accepts($Image));
     $this->assertTrue($o->accepts($Png));
     $this->assertTrue($o->accepts($Gif));
 }
Example #14
0
 public function testGetGetVarIncorrect()
 {
     $o = new PopulatedRequest();
     $this->assertEquals($o->getVar('asdf'), '');
 }
Example #15
0
 public function testGetHttpMethod()
 {
     $o = new PopulatedRequest();
     $o->setHttpMethod(HttpRequestTypes::HEAD);
     $this->assertEquals(HttpRequestTypes::HEAD, $o->getHttpMethod());
     $this->assertNotEquals(HttpRequestTypes::GET, $o->getHttpMethod());
     $this->assertNotEquals(HttpRequestTypes::POST, $o->getHttpMethod());
     $this->assertNotEquals(HttpRequestTypes::PUT, $o->getHttpMethod());
     $this->assertNotEquals(HttpRequestTypes::DELETE, $o->getHttpMethod());
     $o->setHttpMethod(HttpRequestTypes::GET);
     $this->assertNotEquals(HttpRequestTypes::HEAD, $o->getHttpMethod());
     $this->assertEquals(HttpRequestTypes::GET, $o->getHttpMethod());
     $this->assertNotEquals(HttpRequestTypes::POST, $o->getHttpMethod());
     $this->assertNotEquals(HttpRequestTypes::PUT, $o->getHttpMethod());
     $this->assertNotEquals(HttpRequestTypes::DELETE, $o->getHttpMethod());
     $o->setHttpMethod(HttpRequestTypes::POST);
     $this->assertNotEquals(HttpRequestTypes::HEAD, $o->getHttpMethod());
     $this->assertNotEquals(HttpRequestTypes::GET, $o->getHttpMethod());
     $this->assertEquals(HttpRequestTypes::POST, $o->getHttpMethod());
     $this->assertNotEquals(HttpRequestTypes::PUT, $o->getHttpMethod());
     $this->assertNotEquals(HttpRequestTypes::DELETE, $o->getHttpMethod());
     $o->setHttpMethod(HttpRequestTypes::PUT);
     $this->assertNotEquals(HttpRequestTypes::HEAD, $o->getHttpMethod());
     $this->assertNotEquals(HttpRequestTypes::GET, $o->getHttpMethod());
     $this->assertNotEquals(HttpRequestTypes::POST, $o->getHttpMethod());
     $this->assertEquals(HttpRequestTypes::PUT, $o->getHttpMethod());
     $this->assertNotEquals(HttpRequestTypes::DELETE, $o->getHttpMethod());
     $o->setHttpMethod(HttpRequestTypes::DELETE);
     $this->assertNotEquals(HttpRequestTypes::HEAD, $o->getHttpMethod());
     $this->assertNotEquals(HttpRequestTypes::GET, $o->getHttpMethod());
     $this->assertNotEquals(HttpRequestTypes::POST, $o->getHttpMethod());
     $this->assertNotEquals(HttpRequestTypes::PUT, $o->getHttpMethod());
     $this->assertEquals(HttpRequestTypes::DELETE, $o->getHttpMethod());
 }
Example #16
0
 public function testHasVar()
 {
     $o = new PopulatedRequest();
     // GET var
     $this->assertTrue($o->hasVar('cucu'));
     // 'cucu' => 'pasare','ana' => 'are', 'mere' => '', 'test' => 123
     $this->assertTrue($o->hasVar('ana'));
     $this->assertTrue($o->hasVar('test'));
     // POST var
     $this->assertTrue($o->hasVar('postone'));
     // 'postone' => 'are', 'ana' => ''
     $this->assertTrue($o->hasVar('ana'));
     // Cookie var
     $this->assertTrue($o->hasVar('user'));
     // 'user' => 'asddsasdad234'
     PopulatedRequest::startSession();
     $o->setSessionVar('ala', uniqid('ala:'));
     $o->setSessionVar('bala', '##');
     // Session var
     $this->assertTrue($o->hasVar('ala'));
     // 'ala' => uniqid('ala:'), 'bala' => '##'
     $this->assertTrue($o->hasVar('bala'));
 }
Example #17
0
 public function testGetPostVarCorrect()
 {
     $o = new PopulatedRequest();
     $this->assertEquals($_POST['postone'], $o->getVar('postone'));
 }