Update to drupal-org-drupal 8.0.0-rc2. For more information, see https://www.drupal.org/node/2598668
This commit is contained in:
parent
f32e58e4b1
commit
8e18df8c36
3062 changed files with 15044 additions and 172506 deletions
|
@ -1,163 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the Comparator package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass SebastianBergmann\Comparator\ArrayComparator
|
||||
*
|
||||
*/
|
||||
class ArrayComparatorTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $comparator;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->comparator = new ArrayComparator;
|
||||
$this->comparator->setFactory(new Factory);
|
||||
}
|
||||
|
||||
public function acceptsFailsProvider()
|
||||
{
|
||||
return array(
|
||||
array(array(), null),
|
||||
array(null, array()),
|
||||
array(null, null)
|
||||
);
|
||||
}
|
||||
|
||||
public function assertEqualsSucceedsProvider()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
array('a' => 1, 'b' => 2),
|
||||
array('b' => 2, 'a' => 1)
|
||||
),
|
||||
array(
|
||||
array(1),
|
||||
array('1')
|
||||
),
|
||||
array(
|
||||
array(3, 2, 1),
|
||||
array(2, 3, 1),
|
||||
0,
|
||||
true
|
||||
),
|
||||
array(
|
||||
array(2.3),
|
||||
array(2.5),
|
||||
0.5
|
||||
),
|
||||
array(
|
||||
array(array(2.3)),
|
||||
array(array(2.5)),
|
||||
0.5
|
||||
),
|
||||
array(
|
||||
array(new Struct(2.3)),
|
||||
array(new Struct(2.5)),
|
||||
0.5
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function assertEqualsFailsProvider()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
array(),
|
||||
array(0 => 1)
|
||||
),
|
||||
array(
|
||||
array(0 => 1),
|
||||
array()
|
||||
),
|
||||
array(
|
||||
array(0 => null),
|
||||
array()
|
||||
),
|
||||
array(
|
||||
array(0 => 1, 1 => 2),
|
||||
array(0 => 1, 1 => 3)
|
||||
),
|
||||
array(
|
||||
array('a', 'b' => array(1, 2)),
|
||||
array('a', 'b' => array(2, 1))
|
||||
),
|
||||
array(
|
||||
array(2.3),
|
||||
array(4.2),
|
||||
0.5
|
||||
),
|
||||
array(
|
||||
array(array(2.3)),
|
||||
array(array(4.2)),
|
||||
0.5
|
||||
),
|
||||
array(
|
||||
array(new Struct(2.3)),
|
||||
array(new Struct(4.2)),
|
||||
0.5
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::accepts
|
||||
*/
|
||||
public function testAcceptsSucceeds()
|
||||
{
|
||||
$this->assertTrue(
|
||||
$this->comparator->accepts(array(), array())
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::accepts
|
||||
* @dataProvider acceptsFailsProvider
|
||||
*/
|
||||
public function testAcceptsFails($expected, $actual)
|
||||
{
|
||||
$this->assertFalse(
|
||||
$this->comparator->accepts($expected, $actual)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::assertEquals
|
||||
* @dataProvider assertEqualsSucceedsProvider
|
||||
*/
|
||||
public function testAssertEqualsSucceeds($expected, $actual, $delta = 0.0, $canonicalize = false)
|
||||
{
|
||||
$exception = null;
|
||||
|
||||
try {
|
||||
$this->comparator->assertEquals($expected, $actual, $delta, $canonicalize);
|
||||
}
|
||||
|
||||
catch (ComparisonFailure $exception) {
|
||||
}
|
||||
|
||||
$this->assertNull($exception, 'Unexpected ComparisonFailure');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::assertEquals
|
||||
* @dataProvider assertEqualsFailsProvider
|
||||
*/
|
||||
public function testAssertEqualsFails($expected, $actual,$delta = 0.0, $canonicalize = false)
|
||||
{
|
||||
$this->setExpectedException(
|
||||
'SebastianBergmann\\Comparator\\ComparisonFailure',
|
||||
'Failed asserting that two arrays are equal'
|
||||
);
|
||||
$this->comparator->assertEquals($expected, $actual, $delta, $canonicalize);
|
||||
}
|
||||
}
|
|
@ -1,162 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the Comparator package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
use DOMNode;
|
||||
use DOMDocument;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass SebastianBergmann\Comparator\DOMNodeComparator
|
||||
*
|
||||
*/
|
||||
class DOMNodeComparatorTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $comparator;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->comparator = new DOMNodeComparator;
|
||||
}
|
||||
|
||||
public function acceptsSucceedsProvider()
|
||||
{
|
||||
$document = new DOMDocument;
|
||||
$node = new DOMNode;
|
||||
|
||||
return array(
|
||||
array($document, $document),
|
||||
array($node, $node),
|
||||
array($document, $node),
|
||||
array($node, $document)
|
||||
);
|
||||
}
|
||||
|
||||
public function acceptsFailsProvider()
|
||||
{
|
||||
$document = new DOMDocument;
|
||||
|
||||
return array(
|
||||
array($document, null),
|
||||
array(null, $document),
|
||||
array(null, null)
|
||||
);
|
||||
}
|
||||
|
||||
public function assertEqualsSucceedsProvider()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
$this->createDOMDocument('<root></root>'),
|
||||
$this->createDOMDocument('<root/>')
|
||||
),
|
||||
array(
|
||||
$this->createDOMDocument('<root attr="bar"></root>'),
|
||||
$this->createDOMDocument('<root attr="bar"/>')
|
||||
),
|
||||
array(
|
||||
$this->createDOMDocument('<root><foo attr="bar"></foo></root>'),
|
||||
$this->createDOMDocument('<root><foo attr="bar"/></root>')
|
||||
),
|
||||
array(
|
||||
$this->createDOMDocument("<root>\n <child/>\n</root>"),
|
||||
$this->createDOMDocument('<root><child/></root>')
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function assertEqualsFailsProvider()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
$this->createDOMDocument('<root></root>'),
|
||||
$this->createDOMDocument('<bar/>')
|
||||
),
|
||||
array(
|
||||
$this->createDOMDocument('<foo attr1="bar"/>'),
|
||||
$this->createDOMDocument('<foo attr1="foobar"/>')
|
||||
),
|
||||
array(
|
||||
$this->createDOMDocument('<foo> bar </foo>'),
|
||||
$this->createDOMDocument('<foo />')
|
||||
),
|
||||
array(
|
||||
$this->createDOMDocument('<foo xmlns="urn:myns:bar"/>'),
|
||||
$this->createDOMDocument('<foo xmlns="urn:notmyns:bar"/>')
|
||||
),
|
||||
array(
|
||||
$this->createDOMDocument('<foo> bar </foo>'),
|
||||
$this->createDOMDocument('<foo> bir </foo>')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private function createDOMDocument($content)
|
||||
{
|
||||
$document = new DOMDocument;
|
||||
$document->preserveWhiteSpace = false;
|
||||
$document->loadXML($content);
|
||||
|
||||
return $document;
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::accepts
|
||||
* @dataProvider acceptsSucceedsProvider
|
||||
*/
|
||||
public function testAcceptsSucceeds($expected, $actual)
|
||||
{
|
||||
$this->assertTrue(
|
||||
$this->comparator->accepts($expected, $actual)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::accepts
|
||||
* @dataProvider acceptsFailsProvider
|
||||
*/
|
||||
public function testAcceptsFails($expected, $actual)
|
||||
{
|
||||
$this->assertFalse(
|
||||
$this->comparator->accepts($expected, $actual)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::assertEquals
|
||||
* @dataProvider assertEqualsSucceedsProvider
|
||||
*/
|
||||
public function testAssertEqualsSucceeds($expected, $actual)
|
||||
{
|
||||
$exception = null;
|
||||
|
||||
try {
|
||||
$this->comparator->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
catch (ComparisonFailure $exception) {
|
||||
}
|
||||
|
||||
$this->assertNull($exception, 'Unexpected ComparisonFailure');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::assertEquals
|
||||
* @dataProvider assertEqualsFailsProvider
|
||||
*/
|
||||
public function testAssertEqualsFails($expected, $actual)
|
||||
{
|
||||
$this->setExpectedException(
|
||||
'SebastianBergmann\\Comparator\\ComparisonFailure',
|
||||
'Failed asserting that two DOM'
|
||||
);
|
||||
$this->comparator->assertEquals($expected, $actual);
|
||||
}
|
||||
}
|
|
@ -1,216 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the Comparator package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
use DateTime;
|
||||
use DateTimeImmutable;
|
||||
use DateTimeZone;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass SebastianBergmann\Comparator\DateTimeComparator
|
||||
*
|
||||
*/
|
||||
class DateTimeComparatorTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $comparator;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->comparator = new DateTimeComparator;
|
||||
}
|
||||
|
||||
public function acceptsFailsProvider()
|
||||
{
|
||||
$datetime = new DateTime;
|
||||
|
||||
return array(
|
||||
array($datetime, null),
|
||||
array(null, $datetime),
|
||||
array(null, null)
|
||||
);
|
||||
}
|
||||
|
||||
public function assertEqualsSucceedsProvider()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
new DateTime('2013-03-29 04:13:35', new DateTimeZone('America/New_York')),
|
||||
new DateTime('2013-03-29 04:13:35', new DateTimeZone('America/New_York'))
|
||||
),
|
||||
array(
|
||||
new DateTime('2013-03-29 04:13:35', new DateTimeZone('America/New_York')),
|
||||
new DateTime('2013-03-29 04:13:25', new DateTimeZone('America/New_York')),
|
||||
10
|
||||
),
|
||||
array(
|
||||
new DateTime('2013-03-29 04:13:35', new DateTimeZone('America/New_York')),
|
||||
new DateTime('2013-03-29 04:14:40', new DateTimeZone('America/New_York')),
|
||||
65
|
||||
),
|
||||
array(
|
||||
new DateTime('2013-03-29', new DateTimeZone('America/New_York')),
|
||||
new DateTime('2013-03-29', new DateTimeZone('America/New_York'))
|
||||
),
|
||||
array(
|
||||
new DateTime('2013-03-29 04:13:35', new DateTimeZone('America/New_York')),
|
||||
new DateTime('2013-03-29 03:13:35', new DateTimeZone('America/Chicago'))
|
||||
),
|
||||
array(
|
||||
new DateTime('2013-03-29 04:13:35', new DateTimeZone('America/New_York')),
|
||||
new DateTime('2013-03-29 03:13:49', new DateTimeZone('America/Chicago')),
|
||||
15
|
||||
),
|
||||
array(
|
||||
new DateTime('2013-03-30', new DateTimeZone('America/New_York')),
|
||||
new DateTime('2013-03-29 23:00:00', new DateTimeZone('America/Chicago'))
|
||||
),
|
||||
array(
|
||||
new DateTime('2013-03-30', new DateTimeZone('America/New_York')),
|
||||
new DateTime('2013-03-29 23:01:30', new DateTimeZone('America/Chicago')),
|
||||
100
|
||||
),
|
||||
array(
|
||||
new DateTime('@1364616000'),
|
||||
new DateTime('2013-03-29 23:00:00', new DateTimeZone('America/Chicago'))
|
||||
),
|
||||
array(
|
||||
new DateTime('2013-03-29T05:13:35-0500'),
|
||||
new DateTime('2013-03-29T04:13:35-0600')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function assertEqualsFailsProvider()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
new DateTime('2013-03-29 04:13:35', new DateTimeZone('America/New_York')),
|
||||
new DateTime('2013-03-29 03:13:35', new DateTimeZone('America/New_York'))
|
||||
),
|
||||
array(
|
||||
new DateTime('2013-03-29 04:13:35', new DateTimeZone('America/New_York')),
|
||||
new DateTime('2013-03-29 03:13:35', new DateTimeZone('America/New_York')),
|
||||
3500
|
||||
),
|
||||
array(
|
||||
new DateTime('2013-03-29 04:13:35', new DateTimeZone('America/New_York')),
|
||||
new DateTime('2013-03-29 05:13:35', new DateTimeZone('America/New_York')),
|
||||
3500
|
||||
),
|
||||
array(
|
||||
new DateTime('2013-03-29', new DateTimeZone('America/New_York')),
|
||||
new DateTime('2013-03-30', new DateTimeZone('America/New_York'))
|
||||
),
|
||||
array(
|
||||
new DateTime('2013-03-29', new DateTimeZone('America/New_York')),
|
||||
new DateTime('2013-03-30', new DateTimeZone('America/New_York')),
|
||||
43200
|
||||
),
|
||||
array(
|
||||
new DateTime('2013-03-29 04:13:35', new DateTimeZone('America/New_York')),
|
||||
new DateTime('2013-03-29 04:13:35', new DateTimeZone('America/Chicago')),
|
||||
),
|
||||
array(
|
||||
new DateTime('2013-03-29 04:13:35', new DateTimeZone('America/New_York')),
|
||||
new DateTime('2013-03-29 04:13:35', new DateTimeZone('America/Chicago')),
|
||||
3500
|
||||
),
|
||||
array(
|
||||
new DateTime('2013-03-30', new DateTimeZone('America/New_York')),
|
||||
new DateTime('2013-03-30', new DateTimeZone('America/Chicago'))
|
||||
),
|
||||
array(
|
||||
new DateTime('2013-03-29T05:13:35-0600'),
|
||||
new DateTime('2013-03-29T04:13:35-0600')
|
||||
),
|
||||
array(
|
||||
new DateTime('2013-03-29T05:13:35-0600'),
|
||||
new DateTime('2013-03-29T05:13:35-0500')
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::accepts
|
||||
*/
|
||||
public function testAcceptsSucceeds()
|
||||
{
|
||||
$this->assertTrue(
|
||||
$this->comparator->accepts(
|
||||
new DateTime,
|
||||
new DateTime
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::accepts
|
||||
* @dataProvider acceptsFailsProvider
|
||||
*/
|
||||
public function testAcceptsFails($expected, $actual)
|
||||
{
|
||||
$this->assertFalse(
|
||||
$this->comparator->accepts($expected, $actual)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::assertEquals
|
||||
* @dataProvider assertEqualsSucceedsProvider
|
||||
*/
|
||||
public function testAssertEqualsSucceeds($expected, $actual, $delta = 0.0)
|
||||
{
|
||||
$exception = null;
|
||||
|
||||
try {
|
||||
$this->comparator->assertEquals($expected, $actual, $delta);
|
||||
}
|
||||
|
||||
catch (ComparisonFailure $exception) {
|
||||
}
|
||||
|
||||
$this->assertNull($exception, 'Unexpected ComparisonFailure');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::assertEquals
|
||||
* @dataProvider assertEqualsFailsProvider
|
||||
*/
|
||||
public function testAssertEqualsFails($expected, $actual, $delta = 0.0)
|
||||
{
|
||||
$this->setExpectedException(
|
||||
'SebastianBergmann\\Comparator\\ComparisonFailure',
|
||||
'Failed asserting that two DateTime objects are equal.'
|
||||
);
|
||||
$this->comparator->assertEquals($expected, $actual, $delta);
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires PHP 5.5
|
||||
* @covers ::accepts
|
||||
*/
|
||||
public function testAcceptsDateTimeInterface()
|
||||
{
|
||||
$this->assertTrue($this->comparator->accepts(new DateTime, new DateTimeImmutable));
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires PHP 5.5
|
||||
* @covers ::assertEquals
|
||||
*/
|
||||
public function testSupportsDateTimeInterface()
|
||||
{
|
||||
$this->comparator->assertEquals(
|
||||
new DateTime('2013-03-29 04:13:35', new DateTimeZone('America/New_York')),
|
||||
new DateTimeImmutable('2013-03-29 04:13:35', new DateTimeZone('America/New_York'))
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,134 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the Comparator package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass SebastianBergmann\Comparator\DoubleComparator
|
||||
*
|
||||
*/
|
||||
class DoubleComparatorTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $comparator;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->comparator = new DoubleComparator;
|
||||
}
|
||||
|
||||
public function acceptsSucceedsProvider()
|
||||
{
|
||||
return array(
|
||||
array(0, 5.0),
|
||||
array(5.0, 0),
|
||||
array('5', 4.5),
|
||||
array(1.2e3, 7E-10),
|
||||
array(3, acos(8)),
|
||||
array(acos(8), 3),
|
||||
array(acos(8), acos(8))
|
||||
);
|
||||
}
|
||||
|
||||
public function acceptsFailsProvider()
|
||||
{
|
||||
return array(
|
||||
array(5, 5),
|
||||
array('4.5', 5),
|
||||
array(0x539, 02471),
|
||||
array(5.0, false),
|
||||
array(null, 5.0)
|
||||
);
|
||||
}
|
||||
|
||||
public function assertEqualsSucceedsProvider()
|
||||
{
|
||||
return array(
|
||||
array(2.3, 2.3),
|
||||
array('2.3', 2.3),
|
||||
array(5.0, 5),
|
||||
array(5, 5.0),
|
||||
array(5.0, '5'),
|
||||
array(1.2e3, 1200),
|
||||
array(2.3, 2.5, 0.5),
|
||||
array(3, 3.05, 0.05),
|
||||
array(1.2e3, 1201, 1),
|
||||
array((string)(1/3), 1 - 2/3),
|
||||
array(1/3, (string)(1 - 2/3))
|
||||
);
|
||||
}
|
||||
|
||||
public function assertEqualsFailsProvider()
|
||||
{
|
||||
return array(
|
||||
array(2.3, 4.2),
|
||||
array('2.3', 4.2),
|
||||
array(5.0, '4'),
|
||||
array(5.0, 6),
|
||||
array(1.2e3, 1201),
|
||||
array(2.3, 2.5, 0.2),
|
||||
array(3, 3.05, 0.04),
|
||||
array(3, acos(8)),
|
||||
array(acos(8), 3),
|
||||
array(acos(8), acos(8))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::accepts
|
||||
* @dataProvider acceptsSucceedsProvider
|
||||
*/
|
||||
public function testAcceptsSucceeds($expected, $actual)
|
||||
{
|
||||
$this->assertTrue(
|
||||
$this->comparator->accepts($expected, $actual)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::accepts
|
||||
* @dataProvider acceptsFailsProvider
|
||||
*/
|
||||
public function testAcceptsFails($expected, $actual)
|
||||
{
|
||||
$this->assertFalse(
|
||||
$this->comparator->accepts($expected, $actual)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::assertEquals
|
||||
* @dataProvider assertEqualsSucceedsProvider
|
||||
*/
|
||||
public function testAssertEqualsSucceeds($expected, $actual, $delta = 0.0)
|
||||
{
|
||||
$exception = null;
|
||||
|
||||
try {
|
||||
$this->comparator->assertEquals($expected, $actual, $delta);
|
||||
}
|
||||
|
||||
catch (ComparisonFailure $exception) {
|
||||
}
|
||||
|
||||
$this->assertNull($exception, 'Unexpected ComparisonFailure');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::assertEquals
|
||||
* @dataProvider assertEqualsFailsProvider
|
||||
*/
|
||||
public function testAssertEqualsFails($expected, $actual, $delta = 0.0)
|
||||
{
|
||||
$this->setExpectedException(
|
||||
'SebastianBergmann\\Comparator\\ComparisonFailure', 'matches expected'
|
||||
);
|
||||
$this->comparator->assertEquals($expected, $actual, $delta);
|
||||
}
|
||||
}
|
|
@ -1,136 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the Comparator package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
use \Exception;
|
||||
use \RuntimeException;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass SebastianBergmann\Comparator\ExceptionComparator
|
||||
*
|
||||
*/
|
||||
class ExceptionComparatorTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $comparator;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->comparator = new ExceptionComparator;
|
||||
$this->comparator->setFactory(new Factory);
|
||||
}
|
||||
|
||||
public function acceptsSucceedsProvider()
|
||||
{
|
||||
return array(
|
||||
array(new Exception, new Exception),
|
||||
array(new RuntimeException, new RuntimeException),
|
||||
array(new Exception, new RuntimeException)
|
||||
);
|
||||
}
|
||||
|
||||
public function acceptsFailsProvider()
|
||||
{
|
||||
return array(
|
||||
array(new Exception, null),
|
||||
array(null, new Exception),
|
||||
array(null, null)
|
||||
);
|
||||
}
|
||||
|
||||
public function assertEqualsSucceedsProvider()
|
||||
{
|
||||
$exception1 = new Exception;
|
||||
$exception2 = new Exception;
|
||||
|
||||
$exception3 = new RunTimeException('Error', 100);
|
||||
$exception4 = new RunTimeException('Error', 100);
|
||||
|
||||
return array(
|
||||
array($exception1, $exception1),
|
||||
array($exception1, $exception2),
|
||||
array($exception3, $exception3),
|
||||
array($exception3, $exception4)
|
||||
);
|
||||
}
|
||||
|
||||
public function assertEqualsFailsProvider()
|
||||
{
|
||||
$typeMessage = 'not instance of expected class';
|
||||
$equalMessage = 'Failed asserting that two objects are equal.';
|
||||
|
||||
$exception1 = new Exception('Error', 100);
|
||||
$exception2 = new Exception('Error', 101);
|
||||
$exception3 = new Exception('Errors', 101);
|
||||
|
||||
$exception4 = new RunTimeException('Error', 100);
|
||||
$exception5 = new RunTimeException('Error', 101);
|
||||
|
||||
return array(
|
||||
array($exception1, $exception2, $equalMessage),
|
||||
array($exception1, $exception3, $equalMessage),
|
||||
array($exception1, $exception4, $typeMessage),
|
||||
array($exception2, $exception3, $equalMessage),
|
||||
array($exception4, $exception5, $equalMessage)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::accepts
|
||||
* @dataProvider acceptsSucceedsProvider
|
||||
*/
|
||||
public function testAcceptsSucceeds($expected, $actual)
|
||||
{
|
||||
$this->assertTrue(
|
||||
$this->comparator->accepts($expected, $actual)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::accepts
|
||||
* @dataProvider acceptsFailsProvider
|
||||
*/
|
||||
public function testAcceptsFails($expected, $actual)
|
||||
{
|
||||
$this->assertFalse(
|
||||
$this->comparator->accepts($expected, $actual)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::assertEquals
|
||||
* @dataProvider assertEqualsSucceedsProvider
|
||||
*/
|
||||
public function testAssertEqualsSucceeds($expected, $actual)
|
||||
{
|
||||
$exception = null;
|
||||
|
||||
try {
|
||||
$this->comparator->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
catch (ComparisonFailure $exception) {
|
||||
}
|
||||
|
||||
$this->assertNull($exception, 'Unexpected ComparisonFailure');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::assertEquals
|
||||
* @dataProvider assertEqualsFailsProvider
|
||||
*/
|
||||
public function testAssertEqualsFails($expected, $actual, $message)
|
||||
{
|
||||
$this->setExpectedException(
|
||||
'SebastianBergmann\\Comparator\\ComparisonFailure', $message
|
||||
);
|
||||
$this->comparator->assertEquals($expected, $actual);
|
||||
}
|
||||
}
|
115
vendor/sebastian/comparator/tests/FactoryTest.php
vendored
115
vendor/sebastian/comparator/tests/FactoryTest.php
vendored
|
@ -1,115 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the Comparator package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass SebastianBergmann\Comparator\Factory
|
||||
*
|
||||
*/
|
||||
class FactoryTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function instanceProvider()
|
||||
{
|
||||
$tmpfile = tmpfile();
|
||||
|
||||
return array(
|
||||
array(NULL, NULL, 'SebastianBergmann\\Comparator\\ScalarComparator'),
|
||||
array(NULL, TRUE, 'SebastianBergmann\\Comparator\\ScalarComparator'),
|
||||
array(TRUE, NULL, 'SebastianBergmann\\Comparator\\ScalarComparator'),
|
||||
array(TRUE, TRUE, 'SebastianBergmann\\Comparator\\ScalarComparator'),
|
||||
array(FALSE, FALSE, 'SebastianBergmann\\Comparator\\ScalarComparator'),
|
||||
array(TRUE, FALSE, 'SebastianBergmann\\Comparator\\ScalarComparator'),
|
||||
array(FALSE, TRUE, 'SebastianBergmann\\Comparator\\ScalarComparator'),
|
||||
array('', '', 'SebastianBergmann\\Comparator\\ScalarComparator'),
|
||||
array('0', '0', 'SebastianBergmann\\Comparator\\ScalarComparator'),
|
||||
array('0', 0, 'SebastianBergmann\\Comparator\\NumericComparator'),
|
||||
array(0, '0', 'SebastianBergmann\\Comparator\\NumericComparator'),
|
||||
array(0, 0, 'SebastianBergmann\\Comparator\\NumericComparator'),
|
||||
array(1.0, 0, 'SebastianBergmann\\Comparator\\DoubleComparator'),
|
||||
array(0, 1.0, 'SebastianBergmann\\Comparator\\DoubleComparator'),
|
||||
array(1.0, 1.0, 'SebastianBergmann\\Comparator\\DoubleComparator'),
|
||||
array(array(1), array(1), 'SebastianBergmann\\Comparator\\ArrayComparator'),
|
||||
array($tmpfile, $tmpfile, 'SebastianBergmann\\Comparator\\ResourceComparator'),
|
||||
array(new \stdClass, new \stdClass, 'SebastianBergmann\\Comparator\\ObjectComparator'),
|
||||
array(new \DateTime, new \DateTime, 'SebastianBergmann\\Comparator\\DateTimeComparator'),
|
||||
array(new \SplObjectStorage, new \SplObjectStorage, 'SebastianBergmann\\Comparator\\SplObjectStorageComparator'),
|
||||
array(new \Exception, new \Exception, 'SebastianBergmann\\Comparator\\ExceptionComparator'),
|
||||
array(new \DOMDocument, new \DOMDocument, 'SebastianBergmann\\Comparator\\DOMNodeComparator'),
|
||||
// mixed types
|
||||
array($tmpfile, array(1), 'SebastianBergmann\\Comparator\\TypeComparator'),
|
||||
array(array(1), $tmpfile, 'SebastianBergmann\\Comparator\\TypeComparator'),
|
||||
array($tmpfile, '1', 'SebastianBergmann\\Comparator\\TypeComparator'),
|
||||
array('1', $tmpfile, 'SebastianBergmann\\Comparator\\TypeComparator'),
|
||||
array($tmpfile, new \stdClass, 'SebastianBergmann\\Comparator\\TypeComparator'),
|
||||
array(new \stdClass, $tmpfile, 'SebastianBergmann\\Comparator\\TypeComparator'),
|
||||
array(new \stdClass, array(1), 'SebastianBergmann\\Comparator\\TypeComparator'),
|
||||
array(array(1), new \stdClass, 'SebastianBergmann\\Comparator\\TypeComparator'),
|
||||
array(new \stdClass, '1', 'SebastianBergmann\\Comparator\\TypeComparator'),
|
||||
array('1', new \stdClass, 'SebastianBergmann\\Comparator\\TypeComparator'),
|
||||
array(new ClassWithToString, '1', 'SebastianBergmann\\Comparator\\ScalarComparator'),
|
||||
array('1', new ClassWithToString, 'SebastianBergmann\\Comparator\\ScalarComparator'),
|
||||
array(1.0, new \stdClass, 'SebastianBergmann\\Comparator\\TypeComparator'),
|
||||
array(new \stdClass, 1.0, 'SebastianBergmann\\Comparator\\TypeComparator'),
|
||||
array(1.0, array(1), 'SebastianBergmann\\Comparator\\TypeComparator'),
|
||||
array(array(1), 1.0, 'SebastianBergmann\\Comparator\\TypeComparator'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider instanceProvider
|
||||
* @covers ::getComparatorFor
|
||||
* @covers ::__construct
|
||||
*/
|
||||
public function testGetComparatorFor($a, $b, $expected)
|
||||
{
|
||||
$factory = new Factory;
|
||||
$actual = $factory->getComparatorFor($a, $b);
|
||||
$this->assertInstanceOf($expected, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::register
|
||||
*/
|
||||
public function testRegister()
|
||||
{
|
||||
$comparator = new TestClassComparator;
|
||||
|
||||
$factory = new Factory;
|
||||
$factory->register($comparator);
|
||||
|
||||
$a = new TestClass;
|
||||
$b = new TestClass;
|
||||
$expected = 'SebastianBergmann\\Comparator\\TestClassComparator';
|
||||
$actual = $factory->getComparatorFor($a, $b);
|
||||
|
||||
$factory->unregister($comparator);
|
||||
$this->assertInstanceOf($expected, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::unregister
|
||||
*/
|
||||
public function testUnregister()
|
||||
{
|
||||
$comparator = new TestClassComparator;
|
||||
|
||||
$factory = new Factory;
|
||||
$factory->register($comparator);
|
||||
$factory->unregister($comparator);
|
||||
|
||||
$a = new TestClass;
|
||||
$b = new TestClass;
|
||||
$expected = 'SebastianBergmann\\Comparator\\ObjectComparator';
|
||||
$actual = $factory->getComparatorFor($a, $b);
|
||||
|
||||
$this->assertInstanceOf($expected, $actual);
|
||||
}
|
||||
}
|
|
@ -1,166 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the Comparator package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass SebastianBergmann\Comparator\MockObjectComparator
|
||||
*
|
||||
*/
|
||||
class MockObjectComparatorTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $comparator;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->comparator = new MockObjectComparator;
|
||||
$this->comparator->setFactory(new Factory);
|
||||
}
|
||||
|
||||
public function acceptsSucceedsProvider()
|
||||
{
|
||||
$testmock = $this->getMock('SebastianBergmann\\Comparator\\TestClass');
|
||||
$stdmock = $this->getMock('stdClass');
|
||||
|
||||
return array(
|
||||
array($testmock, $testmock),
|
||||
array($stdmock, $stdmock),
|
||||
array($stdmock, $testmock)
|
||||
);
|
||||
}
|
||||
|
||||
public function acceptsFailsProvider()
|
||||
{
|
||||
$stdmock = $this->getMock('stdClass');
|
||||
|
||||
return array(
|
||||
array($stdmock, null),
|
||||
array(null, $stdmock),
|
||||
array(null, null)
|
||||
);
|
||||
}
|
||||
|
||||
public function assertEqualsSucceedsProvider()
|
||||
{
|
||||
// cyclic dependencies
|
||||
$book1 = $this->getMock('SebastianBergmann\\Comparator\\Book', null);
|
||||
$book1->author = $this->getMock('SebastianBergmann\\Comparator\\Author', null, array('Terry Pratchett'));
|
||||
$book1->author->books[] = $book1;
|
||||
$book2 = $this->getMock('SebastianBergmann\\Comparator\\Book', null);
|
||||
$book2->author = $this->getMock('SebastianBergmann\\Comparator\\Author', null, array('Terry Pratchett'));
|
||||
$book2->author->books[] = $book2;
|
||||
|
||||
$object1 = $this->getMock('SebastianBergmann\\Comparator\\SampleClass', null, array(4, 8, 15));
|
||||
$object2 = $this->getMock('SebastianBergmann\\Comparator\\SampleClass', null, array(4, 8, 15));
|
||||
|
||||
return array(
|
||||
array($object1, $object1),
|
||||
array($object1, $object2),
|
||||
array($book1, $book1),
|
||||
array($book1, $book2),
|
||||
array(
|
||||
$this->getMock('SebastianBergmann\\Comparator\\Struct', null, array(2.3)),
|
||||
$this->getMock('SebastianBergmann\\Comparator\\Struct', null, array(2.5)),
|
||||
0.5
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function assertEqualsFailsProvider()
|
||||
{
|
||||
$typeMessage = 'is not instance of expected class';
|
||||
$equalMessage = 'Failed asserting that two objects are equal.';
|
||||
|
||||
// cyclic dependencies
|
||||
$book1 = $this->getMock('SebastianBergmann\\Comparator\\Book', null);
|
||||
$book1->author = $this->getMock('SebastianBergmann\\Comparator\\Author', null, array('Terry Pratchett'));
|
||||
$book1->author->books[] = $book1;
|
||||
$book2 = $this->getMock('SebastianBergmann\\Comparator\\Book', null);
|
||||
$book2->author = $this->getMock('SebastianBergmann\\Comparator\\Author', null, array('Terry Pratch'));
|
||||
$book2->author->books[] = $book2;
|
||||
|
||||
$book3 = $this->getMock('SebastianBergmann\\Comparator\\Book', null);
|
||||
$book3->author = 'Terry Pratchett';
|
||||
$book4 = $this->getMock('stdClass');
|
||||
$book4->author = 'Terry Pratchett';
|
||||
|
||||
$object1 = $this->getMock('SebastianBergmann\\Comparator\\SampleClass', null, array(4, 8, 15));
|
||||
$object2 = $this->getMock('SebastianBergmann\\Comparator\\SampleClass', null, array(16, 23, 42));
|
||||
|
||||
return array(
|
||||
array(
|
||||
$this->getMock('SebastianBergmann\\Comparator\\SampleClass', null, array(4, 8, 15)),
|
||||
$this->getMock('SebastianBergmann\\Comparator\\SampleClass', null, array(16, 23, 42)),
|
||||
$equalMessage
|
||||
),
|
||||
array($object1, $object2, $equalMessage),
|
||||
array($book1, $book2, $equalMessage),
|
||||
array($book3, $book4, $typeMessage),
|
||||
array(
|
||||
$this->getMock('SebastianBergmann\\Comparator\\Struct', null, array(2.3)),
|
||||
$this->getMock('SebastianBergmann\\Comparator\\Struct', null, array(4.2)),
|
||||
$equalMessage,
|
||||
0.5
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::accepts
|
||||
* @dataProvider acceptsSucceedsProvider
|
||||
*/
|
||||
public function testAcceptsSucceeds($expected, $actual)
|
||||
{
|
||||
$this->assertTrue(
|
||||
$this->comparator->accepts($expected, $actual)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::accepts
|
||||
* @dataProvider acceptsFailsProvider
|
||||
*/
|
||||
public function testAcceptsFails($expected, $actual)
|
||||
{
|
||||
$this->assertFalse(
|
||||
$this->comparator->accepts($expected, $actual)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::assertEquals
|
||||
* @dataProvider assertEqualsSucceedsProvider
|
||||
*/
|
||||
public function testAssertEqualsSucceeds($expected, $actual, $delta = 0.0)
|
||||
{
|
||||
$exception = null;
|
||||
|
||||
try {
|
||||
$this->comparator->assertEquals($expected, $actual, $delta);
|
||||
}
|
||||
|
||||
catch (ComparisonFailure $exception) {
|
||||
}
|
||||
|
||||
$this->assertNull($exception, 'Unexpected ComparisonFailure');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::assertEquals
|
||||
* @dataProvider assertEqualsFailsProvider
|
||||
*/
|
||||
public function testAssertEqualsFails($expected, $actual, $message, $delta = 0.0)
|
||||
{
|
||||
$this->setExpectedException(
|
||||
'SebastianBergmann\\Comparator\\ComparisonFailure', $message
|
||||
);
|
||||
$this->comparator->assertEquals($expected, $actual, $delta);
|
||||
}
|
||||
}
|
|
@ -1,122 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the Comparator package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass SebastianBergmann\Comparator\NumericComparator
|
||||
*
|
||||
*/
|
||||
class NumericComparatorTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $comparator;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->comparator = new NumericComparator;
|
||||
}
|
||||
|
||||
public function acceptsSucceedsProvider()
|
||||
{
|
||||
return array(
|
||||
array(5, 10),
|
||||
array(8, '0'),
|
||||
array('10', 0),
|
||||
array(0x74c3b00c, 42),
|
||||
array(0755, 0777)
|
||||
);
|
||||
}
|
||||
|
||||
public function acceptsFailsProvider()
|
||||
{
|
||||
return array(
|
||||
array('5', '10'),
|
||||
array(8, 5.0),
|
||||
array(5.0, 8),
|
||||
array(10, null),
|
||||
array(false, 12)
|
||||
);
|
||||
}
|
||||
|
||||
public function assertEqualsSucceedsProvider()
|
||||
{
|
||||
return array(
|
||||
array(1337, 1337),
|
||||
array('1337', 1337),
|
||||
array(0x539, 1337),
|
||||
array(02471, 1337),
|
||||
array(1337, 1338, 1),
|
||||
array('1337', 1340, 5),
|
||||
);
|
||||
}
|
||||
|
||||
public function assertEqualsFailsProvider()
|
||||
{
|
||||
return array(
|
||||
array(1337, 1338),
|
||||
array('1338', 1337),
|
||||
array(0x539, 1338),
|
||||
array(1337, 1339, 1),
|
||||
array('1337', 1340, 2),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::accepts
|
||||
* @dataProvider acceptsSucceedsProvider
|
||||
*/
|
||||
public function testAcceptsSucceeds($expected, $actual)
|
||||
{
|
||||
$this->assertTrue(
|
||||
$this->comparator->accepts($expected, $actual)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::accepts
|
||||
* @dataProvider acceptsFailsProvider
|
||||
*/
|
||||
public function testAcceptsFails($expected, $actual)
|
||||
{
|
||||
$this->assertFalse(
|
||||
$this->comparator->accepts($expected, $actual)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::assertEquals
|
||||
* @dataProvider assertEqualsSucceedsProvider
|
||||
*/
|
||||
public function testAssertEqualsSucceeds($expected, $actual, $delta = 0.0)
|
||||
{
|
||||
$exception = null;
|
||||
|
||||
try {
|
||||
$this->comparator->assertEquals($expected, $actual, $delta);
|
||||
}
|
||||
|
||||
catch (ComparisonFailure $exception) {
|
||||
}
|
||||
|
||||
$this->assertNull($exception, 'Unexpected ComparisonFailure');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::assertEquals
|
||||
* @dataProvider assertEqualsFailsProvider
|
||||
*/
|
||||
public function testAssertEqualsFails($expected, $actual, $delta = 0.0)
|
||||
{
|
||||
$this->setExpectedException(
|
||||
'SebastianBergmann\\Comparator\\ComparisonFailure', 'matches expected'
|
||||
);
|
||||
$this->comparator->assertEquals($expected, $actual, $delta);
|
||||
}
|
||||
}
|
|
@ -1,150 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the Comparator package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass SebastianBergmann\Comparator\ObjectComparator
|
||||
*
|
||||
*/
|
||||
class ObjectComparatorTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $comparator;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->comparator = new ObjectComparator;
|
||||
$this->comparator->setFactory(new Factory);
|
||||
}
|
||||
|
||||
public function acceptsSucceedsProvider()
|
||||
{
|
||||
return array(
|
||||
array(new TestClass, new TestClass),
|
||||
array(new stdClass, new stdClass),
|
||||
array(new stdClass, new TestClass)
|
||||
);
|
||||
}
|
||||
|
||||
public function acceptsFailsProvider()
|
||||
{
|
||||
return array(
|
||||
array(new stdClass, null),
|
||||
array(null, new stdClass),
|
||||
array(null, null)
|
||||
);
|
||||
}
|
||||
|
||||
public function assertEqualsSucceedsProvider()
|
||||
{
|
||||
// cyclic dependencies
|
||||
$book1 = new Book;
|
||||
$book1->author = new Author('Terry Pratchett');
|
||||
$book1->author->books[] = $book1;
|
||||
$book2 = new Book;
|
||||
$book2->author = new Author('Terry Pratchett');
|
||||
$book2->author->books[] = $book2;
|
||||
|
||||
$object1 = new SampleClass(4, 8, 15);
|
||||
$object2 = new SampleClass(4, 8, 15);
|
||||
|
||||
return array(
|
||||
array($object1, $object1),
|
||||
array($object1, $object2),
|
||||
array($book1, $book1),
|
||||
array($book1, $book2),
|
||||
array(new Struct(2.3), new Struct(2.5), 0.5)
|
||||
);
|
||||
}
|
||||
|
||||
public function assertEqualsFailsProvider()
|
||||
{
|
||||
$typeMessage = 'is not instance of expected class';
|
||||
$equalMessage = 'Failed asserting that two objects are equal.';
|
||||
|
||||
// cyclic dependencies
|
||||
$book1 = new Book;
|
||||
$book1->author = new Author('Terry Pratchett');
|
||||
$book1->author->books[] = $book1;
|
||||
$book2 = new Book;
|
||||
$book2->author = new Author('Terry Pratch');
|
||||
$book2->author->books[] = $book2;
|
||||
|
||||
$book3 = new Book;
|
||||
$book3->author = 'Terry Pratchett';
|
||||
$book4 = new stdClass;
|
||||
$book4->author = 'Terry Pratchett';
|
||||
|
||||
$object1 = new SampleClass( 4, 8, 15);
|
||||
$object2 = new SampleClass(16, 23, 42);
|
||||
|
||||
return array(
|
||||
array(new SampleClass(4, 8, 15), new SampleClass(16, 23, 42), $equalMessage),
|
||||
array($object1, $object2, $equalMessage),
|
||||
array($book1, $book2, $equalMessage),
|
||||
array($book3, $book4, $typeMessage),
|
||||
array(new Struct(2.3), new Struct(4.2), $equalMessage, 0.5)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::accepts
|
||||
* @dataProvider acceptsSucceedsProvider
|
||||
*/
|
||||
public function testAcceptsSucceeds($expected, $actual)
|
||||
{
|
||||
$this->assertTrue(
|
||||
$this->comparator->accepts($expected, $actual)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::accepts
|
||||
* @dataProvider acceptsFailsProvider
|
||||
*/
|
||||
public function testAcceptsFails($expected, $actual)
|
||||
{
|
||||
$this->assertFalse(
|
||||
$this->comparator->accepts($expected, $actual)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::assertEquals
|
||||
* @dataProvider assertEqualsSucceedsProvider
|
||||
*/
|
||||
public function testAssertEqualsSucceeds($expected, $actual, $delta = 0.0)
|
||||
{
|
||||
$exception = null;
|
||||
|
||||
try {
|
||||
$this->comparator->assertEquals($expected, $actual, $delta);
|
||||
}
|
||||
|
||||
catch (ComparisonFailure $exception) {
|
||||
}
|
||||
|
||||
$this->assertNull($exception, 'Unexpected ComparisonFailure');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::assertEquals
|
||||
* @dataProvider assertEqualsFailsProvider
|
||||
*/
|
||||
public function testAssertEqualsFails($expected, $actual, $message, $delta = 0.0)
|
||||
{
|
||||
$this->setExpectedException(
|
||||
'SebastianBergmann\\Comparator\\ComparisonFailure', $message
|
||||
);
|
||||
$this->comparator->assertEquals($expected, $actual, $delta);
|
||||
}
|
||||
}
|
|
@ -1,120 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the Comparator package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass SebastianBergmann\Comparator\ResourceComparator
|
||||
*
|
||||
*/
|
||||
class ResourceComparatorTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $comparator;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->comparator = new ResourceComparator;
|
||||
}
|
||||
|
||||
public function acceptsSucceedsProvider()
|
||||
{
|
||||
$tmpfile1 = tmpfile();
|
||||
$tmpfile2 = tmpfile();
|
||||
|
||||
return array(
|
||||
array($tmpfile1, $tmpfile1),
|
||||
array($tmpfile2, $tmpfile2),
|
||||
array($tmpfile1, $tmpfile2)
|
||||
);
|
||||
}
|
||||
|
||||
public function acceptsFailsProvider()
|
||||
{
|
||||
$tmpfile1 = tmpfile();
|
||||
|
||||
return array(
|
||||
array($tmpfile1, null),
|
||||
array(null, $tmpfile1),
|
||||
array(null, null)
|
||||
);
|
||||
}
|
||||
|
||||
public function assertEqualsSucceedsProvider()
|
||||
{
|
||||
$tmpfile1 = tmpfile();
|
||||
$tmpfile2 = tmpfile();
|
||||
|
||||
return array(
|
||||
array($tmpfile1, $tmpfile1),
|
||||
array($tmpfile2, $tmpfile2)
|
||||
);
|
||||
}
|
||||
|
||||
public function assertEqualsFailsProvider()
|
||||
{
|
||||
$tmpfile1 = tmpfile();
|
||||
$tmpfile2 = tmpfile();
|
||||
|
||||
return array(
|
||||
array($tmpfile1, $tmpfile2),
|
||||
array($tmpfile2, $tmpfile1)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::accepts
|
||||
* @dataProvider acceptsSucceedsProvider
|
||||
*/
|
||||
public function testAcceptsSucceeds($expected, $actual)
|
||||
{
|
||||
$this->assertTrue(
|
||||
$this->comparator->accepts($expected, $actual)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::accepts
|
||||
* @dataProvider acceptsFailsProvider
|
||||
*/
|
||||
public function testAcceptsFails($expected, $actual)
|
||||
{
|
||||
$this->assertFalse(
|
||||
$this->comparator->accepts($expected, $actual)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::assertEquals
|
||||
* @dataProvider assertEqualsSucceedsProvider
|
||||
*/
|
||||
public function testAssertEqualsSucceeds($expected, $actual)
|
||||
{
|
||||
$exception = null;
|
||||
|
||||
try {
|
||||
$this->comparator->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
catch (ComparisonFailure $exception) {
|
||||
}
|
||||
|
||||
$this->assertNull($exception, 'Unexpected ComparisonFailure');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::assertEquals
|
||||
* @dataProvider assertEqualsFailsProvider
|
||||
*/
|
||||
public function testAssertEqualsFails($expected, $actual)
|
||||
{
|
||||
$this->setExpectedException('SebastianBergmann\\Comparator\\ComparisonFailure');
|
||||
$this->comparator->assertEquals($expected, $actual);
|
||||
}
|
||||
}
|
|
@ -1,158 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the Comparator package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass SebastianBergmann\Comparator\ScalarComparator
|
||||
*
|
||||
*/
|
||||
class ScalarComparatorTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $comparator;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->comparator = new ScalarComparator;
|
||||
}
|
||||
|
||||
public function acceptsSucceedsProvider()
|
||||
{
|
||||
return array(
|
||||
array("string", "string"),
|
||||
array(new ClassWithToString, "string"),
|
||||
array("string", new ClassWithToString),
|
||||
array("string", null),
|
||||
array(false, "string"),
|
||||
array(false, true),
|
||||
array(null, false),
|
||||
array(null, null),
|
||||
array("10", 10),
|
||||
array("", false),
|
||||
array("1", true),
|
||||
array(1, true),
|
||||
array(0, false),
|
||||
array(0.1, "0.1")
|
||||
);
|
||||
}
|
||||
|
||||
public function acceptsFailsProvider()
|
||||
{
|
||||
return array(
|
||||
array(array(), array()),
|
||||
array("string", array()),
|
||||
array(new ClassWithToString, new ClassWithToString),
|
||||
array(false, new ClassWithToString),
|
||||
array(tmpfile(), tmpfile())
|
||||
);
|
||||
}
|
||||
|
||||
public function assertEqualsSucceedsProvider()
|
||||
{
|
||||
return array(
|
||||
array("string", "string"),
|
||||
array(new ClassWithToString, new ClassWithToString),
|
||||
array("string representation", new ClassWithToString),
|
||||
array(new ClassWithToString, "string representation"),
|
||||
array("string", "STRING", true),
|
||||
array("STRING", "string", true),
|
||||
array("String Representation", new ClassWithToString, true),
|
||||
array(new ClassWithToString, "String Representation", true),
|
||||
array("10", 10),
|
||||
array("", false),
|
||||
array("1", true),
|
||||
array(1, true),
|
||||
array(0, false),
|
||||
array(0.1, "0.1"),
|
||||
array(false, null),
|
||||
array(false, false),
|
||||
array(true, true),
|
||||
array(null, null)
|
||||
);
|
||||
}
|
||||
|
||||
public function assertEqualsFailsProvider()
|
||||
{
|
||||
$stringException = 'Failed asserting that two strings are equal.';
|
||||
$otherException = 'matches expected';
|
||||
|
||||
return array(
|
||||
array("string", "other string", $stringException),
|
||||
array("string", "STRING", $stringException),
|
||||
array("STRING", "string", $stringException),
|
||||
array("string", "other string", $stringException),
|
||||
// https://github.com/sebastianbergmann/phpunit/issues/1023
|
||||
array('9E6666666','9E7777777', $stringException),
|
||||
array(new ClassWithToString, "does not match", $otherException),
|
||||
array("does not match", new ClassWithToString, $otherException),
|
||||
array(0, 'Foobar', $otherException),
|
||||
array('Foobar', 0, $otherException),
|
||||
array("10", 25, $otherException),
|
||||
array("1", false, $otherException),
|
||||
array("", true, $otherException),
|
||||
array(false, true, $otherException),
|
||||
array(true, false, $otherException),
|
||||
array(null, true, $otherException),
|
||||
array(0, true, $otherException)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::accepts
|
||||
* @dataProvider acceptsSucceedsProvider
|
||||
*/
|
||||
public function testAcceptsSucceeds($expected, $actual)
|
||||
{
|
||||
$this->assertTrue(
|
||||
$this->comparator->accepts($expected, $actual)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::accepts
|
||||
* @dataProvider acceptsFailsProvider
|
||||
*/
|
||||
public function testAcceptsFails($expected, $actual)
|
||||
{
|
||||
$this->assertFalse(
|
||||
$this->comparator->accepts($expected, $actual)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::assertEquals
|
||||
* @dataProvider assertEqualsSucceedsProvider
|
||||
*/
|
||||
public function testAssertEqualsSucceeds($expected, $actual, $ignoreCase = false)
|
||||
{
|
||||
$exception = null;
|
||||
|
||||
try {
|
||||
$this->comparator->assertEquals($expected, $actual, 0.0, false, $ignoreCase);
|
||||
}
|
||||
|
||||
catch (ComparisonFailure $exception) {
|
||||
}
|
||||
|
||||
$this->assertNull($exception, 'Unexpected ComparisonFailure');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::assertEquals
|
||||
* @dataProvider assertEqualsFailsProvider
|
||||
*/
|
||||
public function testAssertEqualsFails($expected, $actual, $message)
|
||||
{
|
||||
$this->setExpectedException(
|
||||
'SebastianBergmann\\Comparator\\ComparisonFailure', $message
|
||||
);
|
||||
$this->comparator->assertEquals($expected, $actual);
|
||||
}
|
||||
}
|
|
@ -1,137 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the Comparator package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
use SplObjectStorage;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass SebastianBergmann\Comparator\SplObjectStorageComparator
|
||||
*
|
||||
*/
|
||||
class SplObjectStorageComparatorTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $comparator;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->comparator = new SplObjectStorageComparator;
|
||||
}
|
||||
|
||||
public function acceptsFailsProvider()
|
||||
{
|
||||
return array(
|
||||
array(new SplObjectStorage, new stdClass),
|
||||
array(new stdClass, new SplObjectStorage),
|
||||
array(new stdClass, new stdClass)
|
||||
);
|
||||
}
|
||||
|
||||
public function assertEqualsSucceedsProvider()
|
||||
{
|
||||
$object1 = new stdClass();
|
||||
$object2 = new stdClass();
|
||||
|
||||
$storage1 = new SplObjectStorage();
|
||||
$storage2 = new SplObjectStorage();
|
||||
|
||||
$storage3 = new SplObjectStorage();
|
||||
$storage3->attach($object1);
|
||||
$storage3->attach($object2);
|
||||
|
||||
$storage4 = new SplObjectStorage();
|
||||
$storage4->attach($object2);
|
||||
$storage4->attach($object1);
|
||||
|
||||
return array(
|
||||
array($storage1, $storage1),
|
||||
array($storage1, $storage2),
|
||||
array($storage3, $storage3),
|
||||
array($storage3, $storage4)
|
||||
);
|
||||
}
|
||||
|
||||
public function assertEqualsFailsProvider()
|
||||
{
|
||||
$object1 = new stdClass;
|
||||
$object2 = new stdClass;
|
||||
|
||||
$storage1 = new SplObjectStorage;
|
||||
|
||||
$storage2 = new SplObjectStorage;
|
||||
$storage2->attach($object1);
|
||||
|
||||
$storage3 = new SplObjectStorage;
|
||||
$storage3->attach($object2);
|
||||
$storage3->attach($object1);
|
||||
|
||||
return array(
|
||||
array($storage1, $storage2),
|
||||
array($storage1, $storage3),
|
||||
array($storage2, $storage3),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::accepts
|
||||
*/
|
||||
public function testAcceptsSucceeds()
|
||||
{
|
||||
$this->assertTrue(
|
||||
$this->comparator->accepts(
|
||||
new SplObjectStorage,
|
||||
new SplObjectStorage
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::accepts
|
||||
* @dataProvider acceptsFailsProvider
|
||||
*/
|
||||
public function testAcceptsFails($expected, $actual)
|
||||
{
|
||||
$this->assertFalse(
|
||||
$this->comparator->accepts($expected, $actual)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::assertEquals
|
||||
* @dataProvider assertEqualsSucceedsProvider
|
||||
*/
|
||||
public function testAssertEqualsSucceeds($expected, $actual)
|
||||
{
|
||||
$exception = null;
|
||||
|
||||
try {
|
||||
$this->comparator->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
catch (ComparisonFailure $exception) {
|
||||
}
|
||||
|
||||
$this->assertNull($exception, 'Unexpected ComparisonFailure');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::assertEquals
|
||||
* @dataProvider assertEqualsFailsProvider
|
||||
*/
|
||||
public function testAssertEqualsFails($expected, $actual)
|
||||
{
|
||||
$this->setExpectedException(
|
||||
'SebastianBergmann\\Comparator\\ComparisonFailure',
|
||||
'Failed asserting that two objects are equal.'
|
||||
);
|
||||
$this->comparator->assertEquals($expected, $actual);
|
||||
}
|
||||
}
|
|
@ -1,104 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the Comparator package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass SebastianBergmann\Comparator\TypeComparator
|
||||
*
|
||||
*/
|
||||
class TypeComparatorTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $comparator;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->comparator = new TypeComparator;
|
||||
}
|
||||
|
||||
public function acceptsSucceedsProvider()
|
||||
{
|
||||
return array(
|
||||
array(true, 1),
|
||||
array(false, array(1)),
|
||||
array(null, new stdClass),
|
||||
array(1.0, 5),
|
||||
array("", "")
|
||||
);
|
||||
}
|
||||
|
||||
public function assertEqualsSucceedsProvider()
|
||||
{
|
||||
return array(
|
||||
array(true, true),
|
||||
array(true, false),
|
||||
array(false, false),
|
||||
array(null, null),
|
||||
array(new stdClass, new stdClass),
|
||||
array(0, 0),
|
||||
array(1.0, 2.0),
|
||||
array("hello", "world"),
|
||||
array("", ""),
|
||||
array(array(), array(1,2,3))
|
||||
);
|
||||
}
|
||||
|
||||
public function assertEqualsFailsProvider()
|
||||
{
|
||||
return array(
|
||||
array(true, null),
|
||||
array(null, false),
|
||||
array(1.0, 0),
|
||||
array(new stdClass, array()),
|
||||
array("1", 1)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::accepts
|
||||
* @dataProvider acceptsSucceedsProvider
|
||||
*/
|
||||
public function testAcceptsSucceeds($expected, $actual)
|
||||
{
|
||||
$this->assertTrue(
|
||||
$this->comparator->accepts($expected, $actual)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::assertEquals
|
||||
* @dataProvider assertEqualsSucceedsProvider
|
||||
*/
|
||||
public function testAssertEqualsSucceeds($expected, $actual)
|
||||
{
|
||||
$exception = null;
|
||||
|
||||
try {
|
||||
$this->comparator->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
catch (ComparisonFailure $exception) {
|
||||
}
|
||||
|
||||
$this->assertNull($exception, 'Unexpected ComparisonFailure');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::assertEquals
|
||||
* @dataProvider assertEqualsFailsProvider
|
||||
*/
|
||||
public function testAssertEqualsFails($expected, $actual)
|
||||
{
|
||||
$this->setExpectedException('SebastianBergmann\\Comparator\\ComparisonFailure', 'does not match expected type');
|
||||
$this->comparator->assertEquals($expected, $actual);
|
||||
}
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the Comparator package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
/**
|
||||
* An author.
|
||||
*
|
||||
*/
|
||||
class Author
|
||||
{
|
||||
// the order of properties is important for testing the cycle!
|
||||
public $books = array();
|
||||
|
||||
private $name = '';
|
||||
|
||||
public function __construct($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the Comparator package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
/**
|
||||
* A book.
|
||||
*
|
||||
*/
|
||||
class Book
|
||||
{
|
||||
// the order of properties is important for testing the cycle!
|
||||
public $author = null;
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the Comparator package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
class ClassWithToString
|
||||
{
|
||||
public function __toString()
|
||||
{
|
||||
return 'string representation';
|
||||
}
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the Comparator package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
/**
|
||||
* A sample class.
|
||||
*
|
||||
*/
|
||||
class SampleClass
|
||||
{
|
||||
public $a;
|
||||
protected $b;
|
||||
protected $c;
|
||||
|
||||
public function __construct($a, $b, $c)
|
||||
{
|
||||
$this->a = $a;
|
||||
$this->b = $b;
|
||||
$this->c = $c;
|
||||
}
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the Comparator package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
/**
|
||||
* A struct.
|
||||
*
|
||||
*/
|
||||
class Struct
|
||||
{
|
||||
public $var;
|
||||
|
||||
public function __construct($var)
|
||||
{
|
||||
$this->var = $var;
|
||||
}
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the Comparator package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
class TestClass {
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the Comparator package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Comparator;
|
||||
|
||||
class TestClassComparator extends ObjectComparator {
|
||||
}
|
38
vendor/sebastian/comparator/tests/autoload.php
vendored
38
vendor/sebastian/comparator/tests/autoload.php
vendored
|
@ -1,38 +0,0 @@
|
|||
<?php
|
||||
// @codingStandardsIgnoreFile
|
||||
// @codeCoverageIgnoreStart
|
||||
// this is an autogenerated file - do not edit
|
||||
spl_autoload_register(
|
||||
function($class) {
|
||||
static $classes = null;
|
||||
if ($classes === null) {
|
||||
$classes = array(
|
||||
'sebastianbergmann\\comparator\\arraycomparatortest' => '/ArrayComparatorTest.php',
|
||||
'sebastianbergmann\\comparator\\author' => '/_files/Author.php',
|
||||
'sebastianbergmann\\comparator\\book' => '/_files/Book.php',
|
||||
'sebastianbergmann\\comparator\\classwithtostring' => '/_files/ClassWithToString.php',
|
||||
'sebastianbergmann\\comparator\\datetimecomparatortest' => '/DateTimeComparatorTest.php',
|
||||
'sebastianbergmann\\comparator\\domnodecomparatortest' => '/DOMNodeComparatorTest.php',
|
||||
'sebastianbergmann\\comparator\\doublecomparatortest' => '/DoubleComparatorTest.php',
|
||||
'sebastianbergmann\\comparator\\exceptioncomparatortest' => '/ExceptionComparatorTest.php',
|
||||
'sebastianbergmann\\comparator\\factorytest' => '/FactoryTest.php',
|
||||
'sebastianbergmann\\comparator\\mockobjectcomparatortest' => '/MockObjectComparatorTest.php',
|
||||
'sebastianbergmann\\comparator\\numericcomparatortest' => '/NumericComparatorTest.php',
|
||||
'sebastianbergmann\\comparator\\objectcomparatortest' => '/ObjectComparatorTest.php',
|
||||
'sebastianbergmann\\comparator\\resourcecomparatortest' => '/ResourceComparatorTest.php',
|
||||
'sebastianbergmann\\comparator\\sampleclass' => '/_files/SampleClass.php',
|
||||
'sebastianbergmann\\comparator\\scalarcomparatortest' => '/ScalarComparatorTest.php',
|
||||
'sebastianbergmann\\comparator\\splobjectstoragecomparatortest' => '/SplObjectStorageComparatorTest.php',
|
||||
'sebastianbergmann\\comparator\\struct' => '/_files/Struct.php',
|
||||
'sebastianbergmann\\comparator\\testclass' => '/_files/TestClass.php',
|
||||
'sebastianbergmann\\comparator\\testclasscomparator' => '/_files/TestClassComparator.php',
|
||||
'sebastianbergmann\\comparator\\typecomparatortest' => '/TypeComparatorTest.php'
|
||||
);
|
||||
}
|
||||
$cn = strtolower($class);
|
||||
if (isset($classes[$cn])) {
|
||||
require __DIR__ . $classes[$cn];
|
||||
}
|
||||
}
|
||||
);
|
||||
// @codeCoverageIgnoreEnd
|
|
@ -1,7 +0,0 @@
|
|||
<?php
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
require __DIR__ . '/autoload.php';
|
||||
|
||||
ini_set('precision', 14);
|
||||
ini_set('serialize_precision', 14);
|
||||
|
BIN
vendor/sebastian/diff/tests/DifferTest.php
vendored
BIN
vendor/sebastian/diff/tests/DifferTest.php
vendored
Binary file not shown.
|
@ -1,175 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the Diff package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Diff\LCS;
|
||||
|
||||
use PHPUnit_Framework_TestCase;
|
||||
|
||||
/**
|
||||
* Some of these tests are volontary stressfull, in order to give some approximative benchmark hints.
|
||||
*/
|
||||
class TimeEfficientImplementationTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $implementation;
|
||||
private $memory_limit;
|
||||
private $stress_sizes = array(1, 2, 3, 100, 500, 1000, 2000);
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->memory_limit = ini_get('memory_limit');
|
||||
ini_set('memory_limit', '256M');
|
||||
|
||||
$this->implementation = new TimeEfficientImplementation;
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
ini_set('memory_limit', $this->memory_limit);
|
||||
}
|
||||
|
||||
public function testBothEmpty()
|
||||
{
|
||||
$from = array();
|
||||
$to = array();
|
||||
$common = $this->implementation->calculate($from, $to);
|
||||
|
||||
$this->assertEquals(array(), $common);
|
||||
}
|
||||
|
||||
public function testIsStrictComparison()
|
||||
{
|
||||
$from = array(
|
||||
false, 0, 0.0, '', null, array(),
|
||||
true, 1, 1.0, 'foo', array('foo', 'bar'), array('foo' => 'bar')
|
||||
);
|
||||
$to = $from;
|
||||
$common = $this->implementation->calculate($from, $to);
|
||||
|
||||
$this->assertEquals($from, $common);
|
||||
|
||||
$to = array(
|
||||
false, false, false, false, false, false,
|
||||
true, true, true, true, true, true
|
||||
);
|
||||
$expected = array(
|
||||
false,
|
||||
true,
|
||||
);
|
||||
$common = $this->implementation->calculate($from, $to);
|
||||
|
||||
$this->assertEquals($expected, $common);
|
||||
}
|
||||
|
||||
public function testEqualSequences()
|
||||
{
|
||||
foreach ($this->stress_sizes as $size) {
|
||||
$range = range(1, $size);
|
||||
$from = $range;
|
||||
$to = $range;
|
||||
$common = $this->implementation->calculate($from, $to);
|
||||
|
||||
$this->assertEquals($range, $common);
|
||||
}
|
||||
}
|
||||
|
||||
public function testDistinctSequences()
|
||||
{
|
||||
$from = array('A');
|
||||
$to = array('B');
|
||||
$common = $this->implementation->calculate($from, $to);
|
||||
$this->assertEquals(array(), $common);
|
||||
|
||||
$from = array('A', 'B', 'C');
|
||||
$to = array('D', 'E', 'F');
|
||||
$common = $this->implementation->calculate($from, $to);
|
||||
$this->assertEquals(array(), $common);
|
||||
|
||||
foreach ($this->stress_sizes as $size) {
|
||||
$from = range(1, $size);
|
||||
$to = range($size + 1, $size * 2);
|
||||
$common = $this->implementation->calculate($from, $to);
|
||||
$this->assertEquals(array(), $common);
|
||||
}
|
||||
}
|
||||
|
||||
public function testCommonSubsequence()
|
||||
{
|
||||
$from = array('A', 'C', 'E', 'F', 'G' );
|
||||
$to = array('A', 'B', 'D', 'E', 'H');
|
||||
$expected = array('A', 'E' );
|
||||
$common = $this->implementation->calculate($from, $to);
|
||||
$this->assertEquals($expected, $common);
|
||||
|
||||
$from = array('A', 'C', 'E', 'F', 'G' );
|
||||
$to = array( 'B', 'C', 'D', 'E', 'F', 'H');
|
||||
$expected = array('C', 'E', 'F' );
|
||||
$common = $this->implementation->calculate($from, $to);
|
||||
$this->assertEquals($expected, $common);
|
||||
|
||||
foreach ($this->stress_sizes as $size) {
|
||||
$from = $size < 2 ? array(1) : range(1, $size + 1, 2);
|
||||
$to = $size < 3 ? array(1) : range(1, $size + 1, 3);
|
||||
$expected = $size < 6 ? array(1) : range(1, $size + 1, 6);
|
||||
$common = $this->implementation->calculate($from, $to);
|
||||
|
||||
$this->assertEquals($expected, $common);
|
||||
}
|
||||
}
|
||||
|
||||
public function testSingleElementSubsequenceAtStart()
|
||||
{
|
||||
foreach ($this->stress_sizes as $size) {
|
||||
$from = range(1, $size);
|
||||
$to = array_slice($from, 0, 1);
|
||||
$common = $this->implementation->calculate($from, $to);
|
||||
|
||||
$this->assertEquals($to, $common);
|
||||
}
|
||||
}
|
||||
|
||||
public function testSingleElementSubsequenceAtMiddle()
|
||||
{
|
||||
foreach ($this->stress_sizes as $size) {
|
||||
$from = range(1, $size);
|
||||
$to = array_slice($from, (int) $size / 2, 1);
|
||||
$common = $this->implementation->calculate($from, $to);
|
||||
|
||||
$this->assertEquals($to, $common);
|
||||
}
|
||||
}
|
||||
|
||||
public function testSingleElementSubsequenceAtEnd()
|
||||
{
|
||||
foreach ($this->stress_sizes as $size) {
|
||||
$from = range(1, $size);
|
||||
$to = array_slice($from, $size - 1, 1);
|
||||
$common = $this->implementation->calculate($from, $to);
|
||||
|
||||
$this->assertEquals($to, $common);
|
||||
}
|
||||
}
|
||||
|
||||
public function testReversedSequences()
|
||||
{
|
||||
$from = array('A', 'B');
|
||||
$to = array('B', 'A');
|
||||
$expected = array('A');
|
||||
$common = $this->implementation->calculate($from, $to);
|
||||
$this->assertEquals($expected, $common);
|
||||
|
||||
foreach ($this->stress_sizes as $size) {
|
||||
$from = range(1, $size);
|
||||
$to = array_reverse($from);
|
||||
$common = $this->implementation->calculate($from, $to);
|
||||
|
||||
$this->assertEquals(array(1), $common);
|
||||
}
|
||||
}
|
||||
}
|
62
vendor/sebastian/diff/tests/ParserTest.php
vendored
62
vendor/sebastian/diff/tests/ParserTest.php
vendored
|
@ -1,62 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the Diff package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Diff;
|
||||
|
||||
use PHPUnit_Framework_TestCase;
|
||||
|
||||
class ParserTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @var Parser
|
||||
*/
|
||||
private $parser;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->parser = new Parser;
|
||||
}
|
||||
|
||||
public function testParse()
|
||||
{
|
||||
$content = file_get_contents(__DIR__ . '/fixtures/patch.txt');
|
||||
|
||||
$diffs = $this->parser->parse($content);
|
||||
|
||||
$this->assertCount(1, $diffs);
|
||||
|
||||
$chunks = $diffs[0]->getChunks();
|
||||
$this->assertCount(1, $chunks);
|
||||
|
||||
$this->assertEquals(20, $chunks[0]->getStart());
|
||||
|
||||
$this->assertCount(5, $chunks[0]->getLines());
|
||||
}
|
||||
|
||||
public function testParseWithMultipleChunks()
|
||||
{
|
||||
$content = file_get_contents(__DIR__ . '/fixtures/patch2.txt');
|
||||
|
||||
$diffs = $this->parser->parse($content);
|
||||
|
||||
$this->assertCount(1, $diffs);
|
||||
|
||||
$chunks = $diffs[0]->getChunks();
|
||||
$this->assertCount(3, $chunks);
|
||||
|
||||
$this->assertEquals(20, $chunks[0]->getStart());
|
||||
$this->assertEquals(320, $chunks[1]->getStart());
|
||||
$this->assertEquals(600, $chunks[2]->getStart());
|
||||
|
||||
$this->assertCount(5, $chunks[0]->getLines());
|
||||
$this->assertCount(5, $chunks[1]->getLines());
|
||||
$this->assertCount(5, $chunks[2]->getLines());
|
||||
}
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
diff --git a/Foo.php b/Foo.php
|
||||
index abcdefg..abcdefh 100644
|
||||
--- a/Foo.php
|
||||
+++ b/Foo.php
|
||||
@@ -20,4 +20,5 @@ class Foo
|
||||
const ONE = 1;
|
||||
const TWO = 2;
|
||||
+ const THREE = 3;
|
||||
const FOUR = 4;
|
21
vendor/sebastian/diff/tests/fixtures/patch2.txt
vendored
21
vendor/sebastian/diff/tests/fixtures/patch2.txt
vendored
|
@ -1,21 +0,0 @@
|
|||
diff --git a/Foo.php b/Foo.php
|
||||
index abcdefg..abcdefh 100644
|
||||
--- a/Foo.php
|
||||
+++ b/Foo.php
|
||||
@@ -20,4 +20,5 @@ class Foo
|
||||
const ONE = 1;
|
||||
const TWO = 2;
|
||||
+ const THREE = 3;
|
||||
const FOUR = 4;
|
||||
|
||||
@@ -320,4 +320,5 @@ class Foo
|
||||
const A = 'A';
|
||||
const B = 'B';
|
||||
+ const C = 'C';
|
||||
const D = 'D';
|
||||
|
||||
@@ -600,4 +600,5 @@ class Foo
|
||||
public function doSomething() {
|
||||
|
||||
+ return 'foo';
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the Environment package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Environment;
|
||||
|
||||
use PHPUnit_Framework_TestCase;
|
||||
|
||||
class ConsoleTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @var \SebastianBergmann\Environment\Console
|
||||
*/
|
||||
private $console;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->console = new Console;
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \SebastianBergmann\Environment\Console::isInteractive
|
||||
*/
|
||||
public function testCanDetectIfStdoutIsInteractiveByDefault()
|
||||
{
|
||||
$this->assertInternalType('boolean', $this->console->isInteractive());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \SebastianBergmann\Environment\Console::isInteractive
|
||||
*/
|
||||
public function testCanDetectIfFileDescriptorIsInteractive()
|
||||
{
|
||||
$this->assertInternalType('boolean', $this->console->isInteractive(STDOUT));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \SebastianBergmann\Environment\Console::hasColorSupport
|
||||
* @uses \SebastianBergmann\Environment\Console::isInteractive
|
||||
*/
|
||||
public function testCanDetectColorSupport()
|
||||
{
|
||||
$this->assertInternalType('boolean', $this->console->hasColorSupport());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \SebastianBergmann\Environment\Console::getNumberOfColumns
|
||||
* @uses \SebastianBergmann\Environment\Console::isInteractive
|
||||
*/
|
||||
public function testCanDetectNumberOfColumns()
|
||||
{
|
||||
$this->assertInternalType('integer', $this->console->getNumberOfColumns());
|
||||
}
|
||||
}
|
112
vendor/sebastian/environment/tests/RuntimeTest.php
vendored
112
vendor/sebastian/environment/tests/RuntimeTest.php
vendored
|
@ -1,112 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the Environment package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Environment;
|
||||
|
||||
use PHPUnit_Framework_TestCase;
|
||||
|
||||
class RuntimeTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @var \SebastianBergmann\Environment\Runtime
|
||||
*/
|
||||
private $env;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->env = new Runtime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \SebastianBergmann\Environment\Runtime::canCollectCodeCoverage
|
||||
* @uses \SebastianBergmann\Environment\Runtime::hasXdebug
|
||||
* @uses \SebastianBergmann\Environment\Runtime::isHHVM
|
||||
* @uses \SebastianBergmann\Environment\Runtime::isPHP
|
||||
*/
|
||||
public function testAbilityToCollectCodeCoverageCanBeAssessed()
|
||||
{
|
||||
$this->assertInternalType('boolean', $this->env->canCollectCodeCoverage());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \SebastianBergmann\Environment\Runtime::getBinary
|
||||
* @uses \SebastianBergmann\Environment\Runtime::isHHVM
|
||||
*/
|
||||
public function testBinaryCanBeRetrieved()
|
||||
{
|
||||
$this->assertInternalType('string', $this->env->getBinary());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \SebastianBergmann\Environment\Runtime::isHHVM
|
||||
*/
|
||||
public function testCanBeDetected()
|
||||
{
|
||||
$this->assertInternalType('boolean', $this->env->isHHVM());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \SebastianBergmann\Environment\Runtime::isPHP
|
||||
* @uses \SebastianBergmann\Environment\Runtime::isHHVM
|
||||
*/
|
||||
public function testCanBeDetected2()
|
||||
{
|
||||
$this->assertInternalType('boolean', $this->env->isPHP());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \SebastianBergmann\Environment\Runtime::hasXdebug
|
||||
* @uses \SebastianBergmann\Environment\Runtime::isHHVM
|
||||
* @uses \SebastianBergmann\Environment\Runtime::isPHP
|
||||
*/
|
||||
public function testXdebugCanBeDetected()
|
||||
{
|
||||
$this->assertInternalType('boolean', $this->env->hasXdebug());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \SebastianBergmann\Environment\Runtime::getNameWithVersion
|
||||
* @uses \SebastianBergmann\Environment\Runtime::getName
|
||||
* @uses \SebastianBergmann\Environment\Runtime::getVersion
|
||||
* @uses \SebastianBergmann\Environment\Runtime::isHHVM
|
||||
* @uses \SebastianBergmann\Environment\Runtime::isPHP
|
||||
*/
|
||||
public function testNameAndVersionCanBeRetrieved()
|
||||
{
|
||||
$this->assertInternalType('string', $this->env->getNameWithVersion());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \SebastianBergmann\Environment\Runtime::getName
|
||||
* @uses \SebastianBergmann\Environment\Runtime::isHHVM
|
||||
*/
|
||||
public function testNameCanBeRetrieved()
|
||||
{
|
||||
$this->assertInternalType('string', $this->env->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \SebastianBergmann\Environment\Runtime::getVersion
|
||||
* @uses \SebastianBergmann\Environment\Runtime::isHHVM
|
||||
*/
|
||||
public function testVersionCanBeRetrieved()
|
||||
{
|
||||
$this->assertInternalType('string', $this->env->getVersion());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \SebastianBergmann\Environment\Runtime::getVendorUrl
|
||||
* @uses \SebastianBergmann\Environment\Runtime::isHHVM
|
||||
*/
|
||||
public function testVendorUrlCanBeRetrieved()
|
||||
{
|
||||
$this->assertInternalType('string', $this->env->getVendorUrl());
|
||||
}
|
||||
}
|
333
vendor/sebastian/exporter/tests/ExporterTest.php
vendored
333
vendor/sebastian/exporter/tests/ExporterTest.php
vendored
|
@ -1,333 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the Exporter package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Exporter;
|
||||
|
||||
/**
|
||||
* @covers SebastianBergmann\Exporter\Exporter
|
||||
*/
|
||||
class ExporterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @var Exporter
|
||||
*/
|
||||
private $exporter;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->exporter = new Exporter;
|
||||
}
|
||||
|
||||
public function exportProvider()
|
||||
{
|
||||
$obj2 = new \stdClass;
|
||||
$obj2->foo = 'bar';
|
||||
|
||||
$obj3 = (object)array(1,2,"Test\r\n",4,5,6,7,8);
|
||||
|
||||
$obj = new \stdClass;
|
||||
//@codingStandardsIgnoreStart
|
||||
$obj->null = null;
|
||||
//@codingStandardsIgnoreEnd
|
||||
$obj->boolean = true;
|
||||
$obj->integer = 1;
|
||||
$obj->double = 1.2;
|
||||
$obj->string = '1';
|
||||
$obj->text = "this\nis\na\nvery\nvery\nvery\nvery\nvery\nvery\rlong\n\rtext";
|
||||
$obj->object = $obj2;
|
||||
$obj->objectagain = $obj2;
|
||||
$obj->array = array('foo' => 'bar');
|
||||
$obj->self = $obj;
|
||||
|
||||
$storage = new \SplObjectStorage;
|
||||
$storage->attach($obj2);
|
||||
$storage->foo = $obj2;
|
||||
|
||||
return array(
|
||||
array(null, 'null'),
|
||||
array(true, 'true'),
|
||||
array(false, 'false'),
|
||||
array(1, '1'),
|
||||
array(1.0, '1.0'),
|
||||
array(1.2, '1.2'),
|
||||
array(fopen('php://memory', 'r'), 'resource(%d) of type (stream)'),
|
||||
array('1', "'1'"),
|
||||
array(array(array(1,2,3), array(3,4,5)),
|
||||
<<<EOF
|
||||
Array &0 (
|
||||
0 => Array &1 (
|
||||
0 => 1
|
||||
1 => 2
|
||||
2 => 3
|
||||
)
|
||||
1 => Array &2 (
|
||||
0 => 3
|
||||
1 => 4
|
||||
2 => 5
|
||||
)
|
||||
)
|
||||
EOF
|
||||
),
|
||||
// \n\r and \r is converted to \n
|
||||
array("this\nis\na\nvery\nvery\nvery\nvery\nvery\nvery\rlong\n\rtext",
|
||||
<<<EOF
|
||||
'this
|
||||
is
|
||||
a
|
||||
very
|
||||
very
|
||||
very
|
||||
very
|
||||
very
|
||||
very
|
||||
long
|
||||
text'
|
||||
EOF
|
||||
),
|
||||
array(new \stdClass, 'stdClass Object &%x ()'),
|
||||
array($obj,
|
||||
<<<EOF
|
||||
stdClass Object &%x (
|
||||
'null' => null
|
||||
'boolean' => true
|
||||
'integer' => 1
|
||||
'double' => 1.2
|
||||
'string' => '1'
|
||||
'text' => 'this
|
||||
is
|
||||
a
|
||||
very
|
||||
very
|
||||
very
|
||||
very
|
||||
very
|
||||
very
|
||||
long
|
||||
text'
|
||||
'object' => stdClass Object &%x (
|
||||
'foo' => 'bar'
|
||||
)
|
||||
'objectagain' => stdClass Object &%x
|
||||
'array' => Array &%d (
|
||||
'foo' => 'bar'
|
||||
)
|
||||
'self' => stdClass Object &%x
|
||||
)
|
||||
EOF
|
||||
),
|
||||
array(array(), 'Array &%d ()'),
|
||||
array($storage,
|
||||
<<<EOF
|
||||
SplObjectStorage Object &%x (
|
||||
'foo' => stdClass Object &%x (
|
||||
'foo' => 'bar'
|
||||
)
|
||||
'%x' => Array &0 (
|
||||
'obj' => stdClass Object &%x
|
||||
'inf' => null
|
||||
)
|
||||
)
|
||||
EOF
|
||||
),
|
||||
array($obj3,
|
||||
<<<EOF
|
||||
stdClass Object &%x (
|
||||
0 => 1
|
||||
1 => 2
|
||||
2 => 'Test\n'
|
||||
3 => 4
|
||||
4 => 5
|
||||
5 => 6
|
||||
6 => 7
|
||||
7 => 8
|
||||
)
|
||||
EOF
|
||||
),
|
||||
array(
|
||||
chr(0) . chr(1) . chr(2) . chr(3) . chr(4) . chr(5),
|
||||
'Binary String: 0x000102030405'
|
||||
),
|
||||
array(
|
||||
implode('', array_map('chr', range(0x0e, 0x1f))),
|
||||
'Binary String: 0x0e0f101112131415161718191a1b1c1d1e1f'
|
||||
),
|
||||
array(
|
||||
chr(0x00) . chr(0x09),
|
||||
'Binary String: 0x0009'
|
||||
),
|
||||
array(
|
||||
'',
|
||||
"''"
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider exportProvider
|
||||
*/
|
||||
public function testExport($value, $expected)
|
||||
{
|
||||
$this->assertStringMatchesFormat(
|
||||
$expected,
|
||||
$this->trimNewline($this->exporter->export($value))
|
||||
);
|
||||
}
|
||||
|
||||
public function testExport2()
|
||||
{
|
||||
if (PHP_VERSION === '5.3.3') {
|
||||
$this->markTestSkipped('Skipped due to "Nesting level too deep - recursive dependency?" fatal error');
|
||||
}
|
||||
|
||||
$obj = new \stdClass;
|
||||
$obj->foo = 'bar';
|
||||
|
||||
$array = array(
|
||||
0 => 0,
|
||||
'null' => null,
|
||||
'boolean' => true,
|
||||
'integer' => 1,
|
||||
'double' => 1.2,
|
||||
'string' => '1',
|
||||
'text' => "this\nis\na\nvery\nvery\nvery\nvery\nvery\nvery\rlong\n\rtext",
|
||||
'object' => $obj,
|
||||
'objectagain' => $obj,
|
||||
'array' => array('foo' => 'bar'),
|
||||
);
|
||||
|
||||
$array['self'] = &$array;
|
||||
|
||||
$expected = <<<EOF
|
||||
Array &%d (
|
||||
0 => 0
|
||||
'null' => null
|
||||
'boolean' => true
|
||||
'integer' => 1
|
||||
'double' => 1.2
|
||||
'string' => '1'
|
||||
'text' => 'this
|
||||
is
|
||||
a
|
||||
very
|
||||
very
|
||||
very
|
||||
very
|
||||
very
|
||||
very
|
||||
long
|
||||
text'
|
||||
'object' => stdClass Object &%x (
|
||||
'foo' => 'bar'
|
||||
)
|
||||
'objectagain' => stdClass Object &%x
|
||||
'array' => Array &%d (
|
||||
'foo' => 'bar'
|
||||
)
|
||||
'self' => Array &%d (
|
||||
0 => 0
|
||||
'null' => null
|
||||
'boolean' => true
|
||||
'integer' => 1
|
||||
'double' => 1.2
|
||||
'string' => '1'
|
||||
'text' => 'this
|
||||
is
|
||||
a
|
||||
very
|
||||
very
|
||||
very
|
||||
very
|
||||
very
|
||||
very
|
||||
long
|
||||
text'
|
||||
'object' => stdClass Object &%x
|
||||
'objectagain' => stdClass Object &%x
|
||||
'array' => Array &%d (
|
||||
'foo' => 'bar'
|
||||
)
|
||||
'self' => Array &%d
|
||||
)
|
||||
)
|
||||
EOF;
|
||||
|
||||
$this->assertStringMatchesFormat(
|
||||
$expected,
|
||||
$this->trimNewline($this->exporter->export($array))
|
||||
);
|
||||
}
|
||||
|
||||
public function shortenedExportProvider()
|
||||
{
|
||||
$obj = new \stdClass;
|
||||
$obj->foo = 'bar';
|
||||
|
||||
$array = array(
|
||||
'foo' => 'bar',
|
||||
);
|
||||
|
||||
return array(
|
||||
array(null, 'null'),
|
||||
array(true, 'true'),
|
||||
array(1, '1'),
|
||||
array(1.0, '1.0'),
|
||||
array(1.2, '1.2'),
|
||||
array('1', "'1'"),
|
||||
// \n\r and \r is converted to \n
|
||||
array("this\nis\na\nvery\nvery\nvery\nvery\nvery\nvery\rlong\n\rtext", "'this\\nis\\na\\nvery\\nvery\\nvery\\nvery...g\\ntext'"),
|
||||
array(new \stdClass, 'stdClass Object ()'),
|
||||
array($obj, 'stdClass Object (...)'),
|
||||
array(array(), 'Array ()'),
|
||||
array($array, 'Array (...)'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider shortenedExportProvider
|
||||
*/
|
||||
public function testShortenedExport($value, $expected)
|
||||
{
|
||||
$this->assertSame(
|
||||
$expected,
|
||||
$this->trimNewline($this->exporter->shortenedExport($value))
|
||||
);
|
||||
}
|
||||
|
||||
public function provideNonBinaryMultibyteStrings()
|
||||
{
|
||||
return array(
|
||||
array(implode('', array_map('chr', range(0x09, 0x0d))), 5),
|
||||
array(implode('', array_map('chr', range(0x20, 0x7f))), 96),
|
||||
array(implode('', array_map('chr', range(0x80, 0xff))), 128),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @dataProvider provideNonBinaryMultibyteStrings
|
||||
*/
|
||||
public function testNonBinaryStringExport($value, $expectedLength)
|
||||
{
|
||||
$this->assertRegExp(
|
||||
"~'.{{$expectedLength}}'\$~s",
|
||||
$this->exporter->export($value)
|
||||
);
|
||||
}
|
||||
|
||||
public function testNonObjectCanBeReturnedAsArray()
|
||||
{
|
||||
$this->assertEquals(array(true), $this->exporter->toArray(true));
|
||||
}
|
||||
|
||||
private function trimNewline($string)
|
||||
{
|
||||
return preg_replace('/[ ]*\n/', "\n", $string);
|
||||
}
|
||||
}
|
|
@ -1,149 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* GlobalState
|
||||
*
|
||||
* Copyright (c) 2001-2014, Sebastian Bergmann <sebastian@phpunit.de>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Sebastian Bergmann nor the names of his
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @author Sebastian Bergmann <sebastian@phpunit.de>
|
||||
* @copyright 2001-2014 Sebastian Bergmann <sebastian@phpunit.de>
|
||||
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
|
||||
* @link http://www.github.com/sebastianbergmann/global-state
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\GlobalState;
|
||||
|
||||
use PHPUnit_Framework_TestCase;
|
||||
|
||||
/**
|
||||
* @author Sebastian Bergmann <sebastian@phpunit.de>
|
||||
* @copyright 2001-2014 Sebastian Bergmann <sebastian@phpunit.de>
|
||||
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
|
||||
* @link http://www.github.com/sebastianbergmann/global-state
|
||||
*/
|
||||
class BlacklistTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @var \SebastianBergmann\GlobalState\Blacklist
|
||||
*/
|
||||
private $blacklist;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->blacklist = new Blacklist;
|
||||
}
|
||||
|
||||
public function testGlobalVariableThatIsNotBlacklistedIsNotTreatedAsBlacklisted()
|
||||
{
|
||||
$this->assertFalse($this->blacklist->isGlobalVariableBlacklisted('variable'));
|
||||
}
|
||||
|
||||
public function testGlobalVariableCanBeBlacklisted()
|
||||
{
|
||||
$this->blacklist->addGlobalVariable('variable');
|
||||
|
||||
$this->assertTrue($this->blacklist->isGlobalVariableBlacklisted('variable'));
|
||||
}
|
||||
|
||||
public function testStaticAttributeThatIsNotBlacklistedIsNotTreatedAsBlacklisted()
|
||||
{
|
||||
$this->assertFalse(
|
||||
$this->blacklist->isStaticAttributeBlacklisted(
|
||||
'SebastianBergmann\GlobalState\TestFixture\BlacklistedClass',
|
||||
'attribute'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testClassCanBeBlacklisted()
|
||||
{
|
||||
$this->blacklist->addClass('SebastianBergmann\GlobalState\TestFixture\BlacklistedClass');
|
||||
|
||||
$this->assertTrue(
|
||||
$this->blacklist->isStaticAttributeBlacklisted(
|
||||
'SebastianBergmann\GlobalState\TestFixture\BlacklistedClass',
|
||||
'attribute'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testSubclassesCanBeBlacklisted()
|
||||
{
|
||||
$this->blacklist->addSubclassesOf('SebastianBergmann\GlobalState\TestFixture\BlacklistedClass');
|
||||
|
||||
$this->assertTrue(
|
||||
$this->blacklist->isStaticAttributeBlacklisted(
|
||||
'SebastianBergmann\GlobalState\TestFixture\BlacklistedChildClass',
|
||||
'attribute'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testImplementorsCanBeBlacklisted()
|
||||
{
|
||||
$this->blacklist->addImplementorsOf('SebastianBergmann\GlobalState\TestFixture\BlacklistedInterface');
|
||||
|
||||
$this->assertTrue(
|
||||
$this->blacklist->isStaticAttributeBlacklisted(
|
||||
'SebastianBergmann\GlobalState\TestFixture\BlacklistedImplementor',
|
||||
'attribute'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testClassNamePrefixesCanBeBlacklisted()
|
||||
{
|
||||
$this->blacklist->addClassNamePrefix('SebastianBergmann\GlobalState');
|
||||
|
||||
$this->assertTrue(
|
||||
$this->blacklist->isStaticAttributeBlacklisted(
|
||||
'SebastianBergmann\GlobalState\TestFixture\BlacklistedClass',
|
||||
'attribute'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testStaticAttributeCanBeBlacklisted()
|
||||
{
|
||||
$this->blacklist->addStaticAttribute(
|
||||
'SebastianBergmann\GlobalState\TestFixture\BlacklistedClass',
|
||||
'attribute'
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$this->blacklist->isStaticAttributeBlacklisted(
|
||||
'SebastianBergmann\GlobalState\TestFixture\BlacklistedClass',
|
||||
'attribute'
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* GlobalState
|
||||
*
|
||||
* Copyright (c) 2001-2014, Sebastian Bergmann <sebastian@phpunit.de>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Sebastian Bergmann nor the names of his
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @author Sebastian Bergmann <sebastian@phpunit.de>
|
||||
* @copyright 2001-2014 Sebastian Bergmann <sebastian@phpunit.de>
|
||||
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
|
||||
* @link http://www.github.com/sebastianbergmann/global-state
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\GlobalState\TestFixture;
|
||||
|
||||
/**
|
||||
* @author Sebastian Bergmann <sebastian@phpunit.de>
|
||||
* @copyright 2001-2014 Sebastian Bergmann <sebastian@phpunit.de>
|
||||
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
|
||||
* @link http://www.github.com/sebastianbergmann/global-state
|
||||
*/
|
||||
class BlacklistedChildClass extends BlacklistedClass
|
||||
{
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* GlobalState
|
||||
*
|
||||
* Copyright (c) 2001-2014, Sebastian Bergmann <sebastian@phpunit.de>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Sebastian Bergmann nor the names of his
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @author Sebastian Bergmann <sebastian@phpunit.de>
|
||||
* @copyright 2001-2014 Sebastian Bergmann <sebastian@phpunit.de>
|
||||
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
|
||||
* @link http://www.github.com/sebastianbergmann/global-state
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\GlobalState\TestFixture;
|
||||
|
||||
/**
|
||||
* @author Sebastian Bergmann <sebastian@phpunit.de>
|
||||
* @copyright 2001-2014 Sebastian Bergmann <sebastian@phpunit.de>
|
||||
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
|
||||
* @link http://www.github.com/sebastianbergmann/global-state
|
||||
*/
|
||||
class BlacklistedClass
|
||||
{
|
||||
private static $attribute;
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* GlobalState
|
||||
*
|
||||
* Copyright (c) 2001-2014, Sebastian Bergmann <sebastian@phpunit.de>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Sebastian Bergmann nor the names of his
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @author Sebastian Bergmann <sebastian@phpunit.de>
|
||||
* @copyright 2001-2014 Sebastian Bergmann <sebastian@phpunit.de>
|
||||
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
|
||||
* @link http://www.github.com/sebastianbergmann/global-state
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\GlobalState\TestFixture;
|
||||
|
||||
/**
|
||||
* @author Sebastian Bergmann <sebastian@phpunit.de>
|
||||
* @copyright 2001-2014 Sebastian Bergmann <sebastian@phpunit.de>
|
||||
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
|
||||
* @link http://www.github.com/sebastianbergmann/global-state
|
||||
*/
|
||||
class BlacklistedImplementor implements BlacklistedInterface
|
||||
{
|
||||
private static $attribute;
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* GlobalState
|
||||
*
|
||||
* Copyright (c) 2001-2014, Sebastian Bergmann <sebastian@phpunit.de>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Sebastian Bergmann nor the names of his
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @author Sebastian Bergmann <sebastian@phpunit.de>
|
||||
* @copyright 2001-2014 Sebastian Bergmann <sebastian@phpunit.de>
|
||||
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
|
||||
* @link http://www.github.com/sebastianbergmann/global-state
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\GlobalState\TestFixture;
|
||||
|
||||
/**
|
||||
* @author Sebastian Bergmann <sebastian@phpunit.de>
|
||||
* @copyright 2001-2014 Sebastian Bergmann <sebastian@phpunit.de>
|
||||
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
|
||||
* @link http://www.github.com/sebastianbergmann/global-state
|
||||
*/
|
||||
interface BlacklistedInterface
|
||||
{
|
||||
}
|
|
@ -1,144 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of the Recursion Context package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\RecursionContext;
|
||||
|
||||
use PHPUnit_Framework_TestCase;
|
||||
|
||||
/**
|
||||
* @covers SebastianBergmann\RecursionContext\Context
|
||||
*/
|
||||
class ContextTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @var \SebastianBergmann\RecursionContext\Context
|
||||
*/
|
||||
private $context;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->context = new Context();
|
||||
}
|
||||
|
||||
public function failsProvider()
|
||||
{
|
||||
return array(
|
||||
array(true),
|
||||
array(false),
|
||||
array(null),
|
||||
array('string'),
|
||||
array(1),
|
||||
array(1.5),
|
||||
array(fopen('php://memory', 'r'))
|
||||
);
|
||||
}
|
||||
|
||||
public function valuesProvider()
|
||||
{
|
||||
$obj2 = new \stdClass();
|
||||
$obj2->foo = 'bar';
|
||||
|
||||
$obj3 = (object) array(1,2,"Test\r\n",4,5,6,7,8);
|
||||
|
||||
$obj = new \stdClass();
|
||||
//@codingStandardsIgnoreStart
|
||||
$obj->null = null;
|
||||
//@codingStandardsIgnoreEnd
|
||||
$obj->boolean = true;
|
||||
$obj->integer = 1;
|
||||
$obj->double = 1.2;
|
||||
$obj->string = '1';
|
||||
$obj->text = "this\nis\na\nvery\nvery\nvery\nvery\nvery\nvery\rlong\n\rtext";
|
||||
$obj->object = $obj2;
|
||||
$obj->objectagain = $obj2;
|
||||
$obj->array = array('foo' => 'bar');
|
||||
$obj->array2 = array(1,2,3,4,5,6);
|
||||
$obj->array3 = array($obj, $obj2, $obj3);
|
||||
$obj->self = $obj;
|
||||
|
||||
$storage = new \SplObjectStorage();
|
||||
$storage->attach($obj2);
|
||||
$storage->foo = $obj2;
|
||||
|
||||
return array(
|
||||
array($obj, spl_object_hash($obj)),
|
||||
array($obj2, spl_object_hash($obj2)),
|
||||
array($obj3, spl_object_hash($obj3)),
|
||||
array($storage, spl_object_hash($storage)),
|
||||
array($obj->array, 0),
|
||||
array($obj->array2, 0),
|
||||
array($obj->array3, 0)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers SebastianBergmann\RecursionContext\Context::add
|
||||
* @uses SebastianBergmann\RecursionContext\InvalidArgumentException
|
||||
* @dataProvider failsProvider
|
||||
*/
|
||||
public function testAddFails($value)
|
||||
{
|
||||
$this->setExpectedException(
|
||||
'SebastianBergmann\\RecursionContext\\Exception',
|
||||
'Only arrays and objects are supported'
|
||||
);
|
||||
$this->context->add($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers SebastianBergmann\RecursionContext\Context::contains
|
||||
* @uses SebastianBergmann\RecursionContext\InvalidArgumentException
|
||||
* @dataProvider failsProvider
|
||||
*/
|
||||
public function testContainsFails($value)
|
||||
{
|
||||
$this->setExpectedException(
|
||||
'SebastianBergmann\\RecursionContext\\Exception',
|
||||
'Only arrays and objects are supported'
|
||||
);
|
||||
$this->context->contains($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers SebastianBergmann\RecursionContext\Context::add
|
||||
* @dataProvider valuesProvider
|
||||
*/
|
||||
public function testAdd($value, $key)
|
||||
{
|
||||
$this->assertEquals($key, $this->context->add($value));
|
||||
|
||||
// Test we get the same key on subsequent adds
|
||||
$this->assertEquals($key, $this->context->add($value));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers SebastianBergmann\RecursionContext\Context::contains
|
||||
* @uses SebastianBergmann\RecursionContext\Context::add
|
||||
* @depends testAdd
|
||||
* @dataProvider valuesProvider
|
||||
*/
|
||||
public function testContainsFound($value, $key)
|
||||
{
|
||||
$this->context->add($value);
|
||||
$this->assertEquals($key, $this->context->contains($value));
|
||||
|
||||
// Test we get the same key on subsequent calls
|
||||
$this->assertEquals($key, $this->context->contains($value));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers SebastianBergmann\RecursionContext\Context::contains
|
||||
* @dataProvider valuesProvider
|
||||
*/
|
||||
public function testContainsNotFound($value)
|
||||
{
|
||||
$this->assertFalse($this->context->contains($value));
|
||||
}
|
||||
}
|
Reference in a new issue