Skip to content

Commit

Permalink
Merge pull request #94 from atoum/sf3
Browse files Browse the repository at this point in the history
SF3 compatibility
  • Loading branch information
FlorianLB committed Feb 10, 2016
2 parents 069b0bb + c089ce2 commit 04b4fa3
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 20 deletions.
16 changes: 7 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,17 @@ php:
- 5.3
- 5.4
- 5.5
- 5.6
- 7.0

env:
global:
- secure: "AwZKGvI1XksV7d1IHzn86m4Hsgk+LOXU6vYTcvBkLbDR40DOBUz7pH1LAX0S\n7KLtKYVHTOwqBQH4QyJHcFDEQ/u/ODmTzPIE8uirMlL8OLbIFMpGVKhjsK6C\nSWX0HS+6w+cN3+MzXK0ie3Pg525PQ+thgq7fJwElNJCqk6SoEkM="

before_script:
- "[ ! -d ~/.composer ] && mkdir ~/.composer || true"
- "[ ! -z $GITHUB_TOKEN ] && echo \"{ \\\"config\\\": { \\\"github-oauth\\\": { \\\"github.com\\\": \\\"$GITHUB_TOKEN\\\" } } }\" > ~/.composer/config.json || true"
- wget http://getcomposer.org/composer.phar
- "[ ! -z $GITHUB_TOKEN ] && php composer.phar install --dev || php composer.phar install --dev --prefer-source"
matrix:
- COMPOSER_PREFER="--prefer-stable"
- COMPOSER_PREFER="--prefer-lowest"

script:
- bin/atoum
- composer update $COMPOSER_PREFER
- bin/atoum -ncc

notifications:
irc: "irc.freenode.org##atoum"
29 changes: 29 additions & 0 deletions DomCrawler/Crawler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php
/**
* Created by PhpStorm.
* User: julien.bianchi
* Date: 09/02/2016
* Time: 21:29
*/

namespace atoum\AtoumBundle\DomCrawler;

use Symfony\Component\DomCrawler;

class Crawler extends DomCrawler\Crawler
{
public function contains($object)
{
if ($this instanceof \SplObjectStorage) {
return parent::contains($object);
}

foreach ($this as $node) {
if ($node === $object) {
return true;
}
}

return false;
}
}
6 changes: 3 additions & 3 deletions DomCrawler/DOMNode.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace atoum\AtoumBundle\DomCrawler;

use Symfony\Component\DomCrawler\Crawler;
use Symfony\Component\DomCrawler;

class DOMNode
{
Expand All @@ -17,8 +17,8 @@ class DOMNode
*/
public function __construct($node)
{
if (($node instanceof Crawler || $node instanceof \DOMNode) === false) {
throw new \InvalidArgumentException('Node should be an instance of either \\DOMNode or \\Symfony\\Component\\DomCrawler\\Crawler');
if (($node instanceof DomCrawler\Crawler || $node instanceof \DOMNode) === false) {
throw new \InvalidArgumentException('Node should be an instance of either \\DOMNode or \\Symfony\\Component\\DomCrawler\\Crawler, got ' . get_class($node));
}

$this->node = $node;
Expand Down
Empty file removed atoum/AtoumBundle
Empty file.
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
],
"require": {
"php": ">=5.3.3",
"symfony/framework-bundle": "2.*",
"symfony/console": "2.*",
"symfony/finder": "2.*",
"symfony/dom-crawler": "2.*",
"symfony/css-selector": "2.*",
"atoum/atoum": ">=1.0,<3.0",
"symfony/framework-bundle": ">=2.3.0|^3.0",
"symfony/console": ">=2.3.0|^3.0",
"symfony/finder": ">=2.3.0|^3.0",
"symfony/dom-crawler": ">=2.3.0|^3.0",
"symfony/css-selector": ">=2.3.0|^3.0",
"atoum/atoum": ">=2.1.0,<3.0",
"fzaninotto/faker": "1.*"
},
"require-dev": {
Expand Down
5 changes: 3 additions & 2 deletions tests/units/DomCrawler/DOMNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require_once __DIR__ . '/../../bootstrap.php';

use mageekguy\atoum;
use atoum\AtoumBundle\DomCrawler\Crawler;
use atoum\AtoumBundle\DomCrawler\DOMNode as TestedClass;

class DOMNode extends atoum\test
Expand All @@ -17,7 +18,7 @@ public function test__construct()
new TestedClass($node);
})
->isInstanceOf('\\InvalidArgumentException')
->hasMessage('Node should be an instance of either \\DOMNode or \\Symfony\\Component\\DomCrawler\\Crawler')
->hasMessage('Node should be an instance of either \\DOMNode or \\Symfony\\Component\\DomCrawler\\Crawler, got ' . get_class($node))
->if($node = new \DOMElement(uniqid('_')))
->then
->object($object = new TestedClass($node))
Expand Down Expand Up @@ -73,7 +74,7 @@ public function testChildren()
->if($node = $document->createElement(uniqid('_')))
->and($child = $document->createElement(uniqid('_')))
->and($node->appendChild($child))
->and($crawler = new \Symfony\Component\DomCrawler\Crawler(array($node)))
->and($crawler = new Crawler(array($node)))
->and($object = new TestedClass($crawler))
->then
->object($children = $object->children())->isInstanceOf('\\Symfony\\Component\\DomCrawler\\Crawler')
Expand Down

0 comments on commit 04b4fa3

Please sign in to comment.