/** * 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; } }
/** * @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)); }
/** * 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; }