コード例 #1
0
ファイル: Style.php プロジェクト: nurfiantara/ehri-ica-atom
/**
* Function to create a new FluentDOMStyleinstance and loads data into it if
* a valid $source is provided.
*
* @param mixed $source
* @param string $contentType optional, default value 'text/xml'
* @return object FluentDOMStyle
*/
function FluentDOMStyle($source = NULL, $contentType = 'text/xml')
{
    $result = new FluentDOMStyle();
    if (isset($source)) {
        return $result->load($source, $contentType);
    } else {
        return $result;
    }
}
コード例 #2
0
ファイル: CssTest.php プロジェクト: noels/FluentDOM
 /**
  * @covers FluentDOMCss::count
  */
 public function testCountExpectingTwo()
 {
     $fd = new FluentDOMStyle();
     $fd->load('<sample style="width: 21px; height: 21px;"/>');
     $fd = $fd->find('/*');
     $css = new FluentDOMCss($fd);
     $this->assertEquals(2, count($css));
 }
コード例 #3
0
 /**
  * Get FluentDOMStyle instance with loaded html document using a mock loader
  *
  * @return FluentDOMStyle
  */
 protected function getFluentDOMStyleFixture($string = NULL, $xpath = NULL)
 {
     $fd = new FluentDOMStyle();
     if (!empty($string)) {
         $dom = new DOMDocument();
         $dom->loadXML($string);
         $loader = $this->getMock('FluentDOMLoader');
         $loader->expects($this->once())->method('load')->with($this->equalTo(''))->will($this->returnValue($dom));
         $fd->setLoaders(array($loader));
         $fd->load('');
         if (!empty($xpath)) {
             $query = new DOMXPath($dom);
             $nodes = $query->evaluate($xpath);
             $fd = $fd->spawn();
             $fd->push($nodes);
         }
     }
     return $fd;
 }