コード例 #1
0
ファイル: AlterAttributes.php プロジェクト: hason/Twigleaf
 /**
  * {@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
ファイル: AlterClasses.php プロジェクト: hason/Twigleaf
 /**
  * {@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
ファイル: AlterCssAttributes.php プロジェクト: hason/Twigleaf
 /**
  * {@inheritdoc}
  */
 public function apply(Crawler $template)
 {
     $elements = $template->filter($this->selector);
     foreach ($this->attributes as $attribute => $value) {
         $elements->css($attribute, $value);
     }
 }
コード例 #6
0
ファイル: AlterClassesSpec.php プロジェクト: hason/Twigleaf
 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
ファイル: PrependSpec.php プロジェクト: hason/Twigleaf
 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
ファイル: UnwrapSpec.php プロジェクト: hason/Twigleaf
 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
ファイル: Prepend.php プロジェクト: hason/Twigleaf
 /**
  * {@inheritdoc}
  */
 public function apply(Crawler $template)
 {
     $template->filter($this->selector)->prepend($this->element);
 }
コード例 #10
0
ファイル: Replace.php プロジェクト: hason/Twigleaf
 /**
  * {@inheritdoc}
  */
 public function apply(Crawler $template)
 {
     $template->filter($this->selector)->replaceWith($this->text);
 }
コード例 #11
0
ファイル: WrapSpec.php プロジェクト: hason/Twigleaf
 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
ファイル: InsertAfter.php プロジェクト: hason/Twigleaf
 /**
  * {@inheritdoc}
  */
 public function apply(Crawler $template)
 {
     $template->filter($this->selector)->insertAfter($this->text);
 }
コード例 #13
0
ファイル: ReplaceSpec.php プロジェクト: hason/Twigleaf
 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
ファイル: RemoveSpec.php プロジェクト: hason/Twigleaf
 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
ファイル: ToggleClassSpec.php プロジェクト: hason/Twigleaf
 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
ファイル: Remove.php プロジェクト: hason/Twigleaf
 /**
  * {@inheritdoc}
  */
 public function apply(Crawler $template)
 {
     $template->filter($this->selector)->remove();
 }
コード例 #17
0
ファイル: ToggleClass.php プロジェクト: hason/Twigleaf
 /**
  * {@inheritdoc}
  */
 public function apply(Crawler $template)
 {
     $template->filter($this->selector)->toggleClass($this->class);
 }
コード例 #18
0
ファイル: InsertBeforeSpec.php プロジェクト: hason/Twigleaf
 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);
 }