/** * Convert a dom element to a textual representation. * Shows tag name, id and classes * * @param mixed $other * @return string */ public static function describeDOMElement($other) { if ($other instanceof DOMElement) { $tag = $other->tagName; $id = $other->getAttribute("id"); $id = $id ? '#' . $id : null; $classes = Converter::parseClasses($other->getAttribute("class")); $classes = $classes ? '.' . join('.', $classes) : null; return $tag . $id . $classes; } else { return '[unknown]'; } }
/** * @dataProvider dataParseClasses * @covers ::parseClasses */ public function testParseClasses($classes, $expected) { $this->assertEquals($expected, Converter::parseClasses($classes)); }