Changeset 200

Show
Ignore:
Timestamp:
02/02/07 16:08:36 (2 years ago)
Author:
mikey
Message:

added tests for functionality introduced with net.stubbles.xml.stubXMLXIncludeStreamWrapper

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/php/net/stubbles/xml/xsl/stubXSLProcessor.php

    r199 r200  
    161161         
    162162        unset($this->parameters[$nameSpace][$paramName]); 
     163        if (count($this->parameters[$nameSpace]) == 0) { 
     164            unset($this->parameters[$nameSpace]); 
     165        } 
    163166        return true; 
    164167    } 
     
    205208     * @return  array 
    206209     */ 
    207     public function getParameterNameSpaces() 
     210    public function getParameterNamespaces() 
    208211    { 
    209212        return array_keys($this->parameters); 
  • trunk/src/test/php/net/stubbles/xml/xsl/stubXSLProcessorTestCase.php

    r180 r200  
    6464        TeststubXSLProcessor::$mockXSLTProcessor = $this->mockXSLTProcessor; 
    6565        $this->xslProcessor = new TeststubXSLProcessor(); 
    66         $this->document = new DOMDocument(); 
     66        $this->document     = new DOMDocument(); 
    6767        $this->xslProcessor->setXMLDocument($this->document); 
     68    } 
     69     
     70    /** 
     71     * test importing a stylesheet 
     72     */ 
     73    public function testImportXSLStylesheet() 
     74    { 
     75        $stylesheet = new DOMDocument(); 
     76        $this->xslProcessor->importXSLStylesheet($stylesheet); 
     77        $this->assertEqual($this->xslProcessor->getStylesheets(), array($stylesheet)); 
    6878    } 
    6979     
     
    8696        $this->assertTrue($this->xslProcessor->hasParameter('foo', 'bar')); 
    8797        $this->assertTrue($this->xslProcessor->hasParameter('foo', 'foo')); 
     98        $this->assertEqual($this->xslProcessor->getParameters('foo'), array('bar' => 'baz', 'foo' => 'bar')); 
     99        $this->assertEqual($this->xslProcessor->getParameters('bar'), array()); 
     100        $this->assertEqual($this->xslProcessor->getParameterNamespaces(), array('foo')); 
    88101         
    89         $this->mockXSLTProcessor->expect('removeParameter', array('foo', 'bar')); 
     102        $this->mockXSLTProcessor->expectAt(0, 'removeParameter', array('foo', 'bar')); 
     103        $this->mockXSLTProcessor->expectAt(1, 'removeParameter', array('foo', 'bar')); 
     104        $this->mockXSLTProcessor->expectAt(2, 'removeParameter', array('foo', 'foo')); 
    90105        $this->mockXSLTProcessor->setReturnValueAt(0, 'removeParameter', false); 
    91106        $this->mockXSLTProcessor->setReturnValueAt(1, 'removeParameter', true); 
     107        $this->mockXSLTProcessor->setReturnValueAt(2, 'removeParameter', true); 
    92108        $this->assertFalse($this->xslProcessor->removeParameter('foo', 'bar')); 
    93109        $this->assertTrue($this->xslProcessor->hasParameter('foo', 'bar')); 
     
    95111        $this->assertFalse($this->xslProcessor->hasParameter('foo', 'bar')); 
    96112        $this->assertTrue($this->xslProcessor->removeParameter('foo', 'baz')); 
     113        $this->assertTrue($this->xslProcessor->removeParameter('foo', 'foo')); 
     114        $this->assertEqual($this->xslProcessor->getParameters('foo'), array()); 
     115        $this->assertEqual($this->xslProcessor->getParameterNamespaces(), array()); 
    97116    } 
    98117     
     
    114133        $this->assertTrue($this->xslProcessor->hasParameter('baz', 'foo')); 
    115134        $this->assertFalse($this->xslProcessor->hasParameter('baz', 'bar')); 
     135        $this->assertEqual($this->xslProcessor->getParameters('baz'), array('baz' => 'baz', 'foo' => 'bar')); 
     136        $this->assertEqual($this->xslProcessor->getParameters('bar'), array()); 
     137        $this->assertEqual($this->xslProcessor->getParameterNamespaces(), array('baz')); 
    116138         
    117         $this->mockXSLTProcessor->expect('removeParameter', array('baz', 'foo')); 
    118139        $this->mockXSLTProcessor->setReturnValueAt(0, 'removeParameter', false); 
    119140        $this->mockXSLTProcessor->setReturnValueAt(1, 'removeParameter', true); 
     141        $this->mockXSLTProcessor->setReturnValueAt(2, 'removeParameter', true); 
    120142        $this->assertEqual($this->xslProcessor->removeParameters('baz', array('foo')), array('foo' => false)); 
    121143        $this->assertTrue($this->xslProcessor->hasParameter('baz', 'foo')); 
     
    123145        $this->assertFalse($this->xslProcessor->hasParameter('baz', 'bar')); 
    124146        $this->assertEqual($this->xslProcessor->removeParameters('baz', array('bar')), array('bar' => true)); 
     147        $this->xslProcessor->removeParameter('baz', 'foo'); 
     148        $this->xslProcessor->removeParameter('baz', 'baz'); 
     149        $this->assertEqual($this->xslProcessor->getParameters('baz'), array()); 
     150        $this->assertEqual($this->xslProcessor->getParameterNamespaces(), array()); 
    125151    } 
    126152