getAttribute() public method

Access to the element's attributes.
public getAttribute ( string $name, string $default = null ) : string | null
$name string The attribute name
$default string The value returned if the attribute does not exist
return string | null The value of the attribute or null if attribute does not exist
Exemplo n.º 1
0
 public function testGetAttribute()
 {
     $domElement = $this->createDomElement('input');
     $element = new Element($domElement);
     $this->assertEquals("default", $element->getAttribute("value", "default"));
     $domElement->setAttribute("value", "test");
     $element = new Element($domElement);
     $this->assertEquals("test", $element->getAttribute("value"));
 }
Exemplo n.º 2
0
 public function testGetAttribute()
 {
     $domElement = $this->createDomElement('input');
     $element = new Element($domElement);
     $this->assertEquals(null, $element->getAttribute('value'));
     $this->assertEquals('default', $element->getAttribute('value', 'default'));
     $domElement->setAttribute('value', 'test');
     $element = new Element($domElement);
     $this->assertEquals('test', $element->getAttribute('value'));
 }