zoe             Thu Apr 30 20:07:43 2009 UTC

  Added files:                 
    /phpruntests/src/testcase/sections/configurationsections    
                                                                
rtDeflatePostSection.php 
    /phpruntests/tests/testcase/sections/configurationsections  
                                                                
rtDeflatePostSectionTest.php 

  Modified files:              
    /phpruntests/src    rtClassMap.php 
  Log:
  deflate post section
  
http://cvs.php.net/viewvc.cgi/phpruntests/src/rtClassMap.php?r1=1.4&r2=1.5&diff_format=u
Index: phpruntests/src/rtClassMap.php
diff -u phpruntests/src/rtClassMap.php:1.4 phpruntests/src/rtClassMap.php:1.5
--- phpruntests/src/rtClassMap.php:1.4  Thu Apr 30 08:12:32 2009
+++ phpruntests/src/rtClassMap.php      Thu Apr 30 20:07:43 2009
@@ -56,6 +56,7 @@
     'rtTestPreCondition'                       => 
'testcase/rtTestPreCondition.php',
     'rtTestResults'                            => 'testcase/rtTestResults.php',
     'rtArgsSection'                            => 
'testcase/sections/configurationsections/rtArgsSection.php',
+    'rtDeflatePostSection'                     => 
'testcase/sections/configurationsections/rtDeflatePostSection.php',
     'rtEnvSection'                             => 
'testcase/sections/configurationsections/rtEnvSection.php',
     'rtGetSection'                             => 
'testcase/sections/configurationsections/rtGetSection.php',
     'rtGzipPostSection'                        => 
'testcase/sections/configurationsections/rtGzipPostSection.php',

http://cvs.php.net/viewvc.cgi/phpruntests/src/testcase/sections/configurationsections/rtDeflatePostSection.php?view=markup&rev=1.1
Index: 
phpruntests/src/testcase/sections/configurationsections/rtDeflatePostSection.php
+++ 
phpruntests/src/testcase/sections/configurationsections/rtDeflatePostSection.php
<?php
/**
 * rtPostSection
 * Sets environment variables for DEFLATE_POST section
 *
 *
 * @category  Testing
 * @package   RUNTESTS
 * @author    Zoe Slattery <z...@php.net>
 * @author    Stefan Priebsch <sprieb...@php.net>
 * @copyright 2009 The PHP Group
 * @license   http://www.php.net/license/3_01.txt PHP License 3.01
 * @link      http://qa.php.net/
 */
class rtDeflatePostSection extends rtConfigurationSection
{
    private $postVariables = array();
    private $postFileName;

    protected function init()
    { 
        $postString = implode('\n', $this->sectionContents);
        $compressedPostString = gzcompress($postString);
        
        $this->postVariables['CONTENT_TYPE'] = 
'application/x-www-form-urlencoded';
        $this->postVariables['CONTENT_LENGTH'] = strlen($compressedPostString);
        $this->postVariables['REQUEST_METHOD'] = 'POST';

        $this->postFileName = tempnam(sys_get_temp_dir(), 'post');
        
        file_put_contents($this->postFileName, $compressedPostString);
    }

    /**
     * Additional POST environment variables required by the test
     *
     * @return array
     */
    public function getPostVariables()
    {
        return $this->postVariables;
    }

    public function getPostFileName()
    {
        return $this->postFileName;
    }
}
?>
http://cvs.php.net/viewvc.cgi/phpruntests/tests/testcase/sections/configurationsections/rtDeflatePostSectionTest.php?view=markup&rev=1.1
Index: 
phpruntests/tests/testcase/sections/configurationsections/rtDeflatePostSectionTest.php
+++ 
phpruntests/tests/testcase/sections/configurationsections/rtDeflatePostSectionTest.php
<?php
require_once 'PHPUnit/Framework.php';
require_once dirname(__FILE__) . '../../../../../src/rtAutoload.php';

class rtDeflatePostSectionTest extends PHPUnit_Framework_TestCase
{
    public function testCreateInstance() 
    {
        $postSection = new rtDeflatePostSection('GZIP_POST', 
array('hello=World&goodbye=MrChips'));  
        
        $envVars = $postSection->getPostVariables();
        $this->assertEquals('POST', $envVars['REQUEST_METHOD']);
        
$this->assertEquals('application/x-www-form-urlencoded',$envVars['CONTENT_TYPE']);
        $this->assertEquals(strlen(gzcompress('hello=World&goodbye=MrChips')), 
$envVars['CONTENT_LENGTH']);
        
        $fileName = $postSection->getPostFileName();
        $string = file_get_contents($fileName);
        
        $expectedString = gzcompress('hello=World&goodbye=MrChips');
        
        $this->assertEquals($expectedString, $string);
    }
}
?>


-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to