Exemplo n.º 1
0
 /**
  * {@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);
     }
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function apply(Crawler $template)
 {
     $elements = $template->filter($this->selector);
     foreach ($this->classes as $class => $action) {
         $action ? $elements->addClass($class) : $elements->removeClass($class);
     }
 }
Exemplo n.º 3
0
 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);
 }
Exemplo n.º 4
0
 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);
 }
Exemplo n.º 5
0
 /**
  * {@inheritdoc}
  */
 public function apply(Crawler $template)
 {
     $elements = $template->filter($this->selector);
     foreach ($this->attributes as $attribute => $value) {
         $elements->css($attribute, $value);
     }
 }
Exemplo n.º 6
0
 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);
 }
Exemplo n.º 7
0
 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);
 }
Exemplo n.º 8
0
 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);
 }
Exemplo n.º 9
0
 /**
  * {@inheritdoc}
  */
 public function apply(Crawler $template)
 {
     $template->filter($this->selector)->prepend($this->element);
 }
Exemplo n.º 10
0
 /**
  * {@inheritdoc}
  */
 public function apply(Crawler $template)
 {
     $template->filter($this->selector)->replaceWith($this->text);
 }
Exemplo n.º 11
0
 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);
 }
Exemplo n.º 12
0
 /**
  * {@inheritdoc}
  */
 public function apply(Crawler $template)
 {
     $template->filter($this->selector)->insertAfter($this->text);
 }
Exemplo n.º 13
0
 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);
 }
Exemplo n.º 14
0
 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);
 }
Exemplo n.º 15
0
 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);
 }
Exemplo n.º 16
0
 /**
  * {@inheritdoc}
  */
 public function apply(Crawler $template)
 {
     $template->filter($this->selector)->remove();
 }
Exemplo n.º 17
0
 /**
  * {@inheritdoc}
  */
 public function apply(Crawler $template)
 {
     $template->filter($this->selector)->toggleClass($this->class);
 }
Exemplo n.º 18
0
 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);
 }