Пример #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);
     }
 }
Пример #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);
     }
 }
Пример #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);
 }
Пример #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);
 }
Пример #5
0
 /**
  * {@inheritdoc}
  */
 public function apply(Crawler $template)
 {
     $elements = $template->filter($this->selector);
     foreach ($this->attributes as $attribute => $value) {
         $elements->css($attribute, $value);
     }
 }
Пример #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);
 }
Пример #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);
 }
Пример #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);
 }
Пример #9
0
 /**
  * {@inheritdoc}
  */
 public function apply(Crawler $template)
 {
     $template->filter($this->selector)->prepend($this->element);
 }
Пример #10
0
 /**
  * {@inheritdoc}
  */
 public function apply(Crawler $template)
 {
     $template->filter($this->selector)->replaceWith($this->text);
 }
Пример #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);
 }
Пример #12
0
 /**
  * {@inheritdoc}
  */
 public function apply(Crawler $template)
 {
     $template->filter($this->selector)->insertAfter($this->text);
 }
Пример #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);
 }
Пример #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);
 }
Пример #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);
 }
Пример #16
0
 /**
  * {@inheritdoc}
  */
 public function apply(Crawler $template)
 {
     $template->filter($this->selector)->remove();
 }
Пример #17
0
 /**
  * {@inheritdoc}
  */
 public function apply(Crawler $template)
 {
     $template->filter($this->selector)->toggleClass($this->class);
 }
Пример #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);
 }