/** * {@inheritdoc} */ public function apply(Crawler $template) { $elements = $template->filter($this->selector); foreach ($this->attributes as $attribute => $value) { false === $value ? $elements->removeAttribute($attribute) : $elements->setAttribute($attribute, $value); } }
/** * {@inheritdoc} */ public function apply(Crawler $template) { $elements = $template->filter($this->selector); foreach ($this->classes as $class => $action) { $action ? $elements->addClass($class) : $elements->removeClass($class); } }
function it_removes_attributes_if_they_are_set_to_false(Crawler $template, Crawler $elements) { $this->beConstructedWith('p.comment', array('foo' => false)); $template->filter('p.comment')->shouldBeCalled()->willReturn($elements); $elements->removeAttribute('foo')->shouldBeCalled(); $this->apply($template); }
function it_modifies_css_attributes(Crawler $template, Crawler $elements) { $template->filter('p.comment')->shouldBeCalled()->willReturn($elements); $elements->css('margin-top', '10px')->shouldBeCalled(); $elements->css('color', '#1abb9c')->shouldBeCalled(); $this->apply($template); }
/** * {@inheritdoc} */ public function apply(Crawler $template) { $elements = $template->filter($this->selector); foreach ($this->attributes as $attribute => $value) { $elements->css($attribute, $value); } }
function it_removes_class_if_set_to_false(Crawler $template, Crawler $elements) { $this->beConstructedWith('h1', array('promoted' => false)); $template->filter('h1')->shouldBeCalled()->willReturn($elements); $elements->removeClass('promoted')->shouldBeCalled(); $this->apply($template); }
function it_prepends_content_to_matched_elements(Crawler $template, Crawler $elements) { $template->filter('p.comment')->shouldBeCalled()->willReturn($elements); $elements->prepend('<a href="#">Foo</a>')->shouldBeCalled(); $this->apply($template); }
function it_unwraps_matched_element_from_another_element(Crawler $template, Crawler $elements) { $template->filter('p.comment')->shouldBeCalled()->willReturn($elements); $elements->unwrap()->shouldBeCalled(); $this->apply($template); }
/** * {@inheritdoc} */ public function apply(Crawler $template) { $template->filter($this->selector)->prepend($this->element); }
/** * {@inheritdoc} */ public function apply(Crawler $template) { $template->filter($this->selector)->replaceWith($this->text); }
function it_wraps_matched_element_with_another_element(Crawler $template, Crawler $elements) { $template->filter('p.comment')->shouldBeCalled()->willReturn($elements); $elements->wrap('<a href="#">')->shouldBeCalled(); $this->apply($template); }
/** * {@inheritdoc} */ public function apply(Crawler $template) { $template->filter($this->selector)->insertAfter($this->text); }
function it_replaces_elements_with_content(Crawler $template, Crawler $elements) { $template->filter('h1')->shouldBeCalled()->willReturn($elements); $elements->replaceWith('<h1>Hello!</h1>')->shouldBeCalled(); $this->apply($template); }
function it_removes_elements_matching_selector_when_applied(Crawler $template, Crawler $elements) { $template->filter('div#comments')->shouldBeCalled()->willReturn($elements); $elements->remove()->shouldBeCalled(); $this->apply($template); }
function it_toggles_given_class_on_matched_set_of_elements(Crawler $template, Crawler $elements) { $template->filter('p.comment')->shouldBeCalled()->willReturn($elements); $elements->toggleClass('highlighted')->shouldBeCalled(); $this->apply($template); }
/** * {@inheritdoc} */ public function apply(Crawler $template) { $template->filter($this->selector)->remove(); }
/** * {@inheritdoc} */ public function apply(Crawler $template) { $template->filter($this->selector)->toggleClass($this->class); }
function it_inserts_content_before_matched_elements(Crawler $template, Crawler $elements) { $template->filter('p.comment')->shouldBeCalled()->willReturn($elements); $elements->insertBefore('<a href="#">Foo</a>')->shouldBeCalled(); $this->apply($template); }