~tcuthbert/wordpress/openstack-objectstorage

« back to all changes in this revision

Viewing changes to vendor/sebastian/comparator/tests/ResourceComparatorTest.php

  • Committer: Jacek Nykis
  • Date: 2015-02-11 15:35:31 UTC
  • Revision ID: jacek.nykis@canonical.com-20150211153531-hmy6zi0ov2qfkl0b
Initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
/*
 
3
 * This file is part of the Comparator package.
 
4
 *
 
5
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 
6
 *
 
7
 * For the full copyright and license information, please view the LICENSE
 
8
 * file that was distributed with this source code.
 
9
 */
 
10
 
 
11
namespace SebastianBergmann\Comparator;
 
12
 
 
13
/**
 
14
 * @coversDefaultClass SebastianBergmann\Comparator\ResourceComparator
 
15
 *
 
16
 * @package    Comparator
 
17
 * @author     Jeff Welch <whatthejeff@gmail.com>
 
18
 * @copyright  Sebastian Bergmann <sebastian@phpunit.de>
 
19
 * @license    http://www.opensource.org/licenses/BSD-3-Clause  The BSD 3-Clause License
 
20
 * @link       http://www.github.com/sebastianbergmann/comparator
 
21
 */
 
22
class ResourceComparatorTest extends \PHPUnit_Framework_TestCase
 
23
{
 
24
    private $comparator;
 
25
 
 
26
    protected function setUp()
 
27
    {
 
28
        $this->comparator = new ResourceComparator;
 
29
    }
 
30
 
 
31
    public function acceptsSucceedsProvider()
 
32
    {
 
33
        $tmpfile1 = tmpfile();
 
34
        $tmpfile2 = tmpfile();
 
35
 
 
36
        return array(
 
37
          array($tmpfile1, $tmpfile1),
 
38
          array($tmpfile2, $tmpfile2),
 
39
          array($tmpfile1, $tmpfile2)
 
40
        );
 
41
    }
 
42
 
 
43
    public function acceptsFailsProvider()
 
44
    {
 
45
        $tmpfile1 = tmpfile();
 
46
 
 
47
        return array(
 
48
          array($tmpfile1, null),
 
49
          array(null, $tmpfile1),
 
50
          array(null, null)
 
51
        );
 
52
    }
 
53
 
 
54
    public function assertEqualsSucceedsProvider()
 
55
    {
 
56
        $tmpfile1 = tmpfile();
 
57
        $tmpfile2 = tmpfile();
 
58
 
 
59
        return array(
 
60
          array($tmpfile1, $tmpfile1),
 
61
          array($tmpfile2, $tmpfile2)
 
62
        );
 
63
    }
 
64
 
 
65
    public function assertEqualsFailsProvider()
 
66
    {
 
67
        $tmpfile1 = tmpfile();
 
68
        $tmpfile2 = tmpfile();
 
69
 
 
70
        return array(
 
71
          array($tmpfile1, $tmpfile2),
 
72
          array($tmpfile2, $tmpfile1)
 
73
        );
 
74
    }
 
75
 
 
76
    /**
 
77
     * @covers       ::accepts
 
78
     * @dataProvider acceptsSucceedsProvider
 
79
     */
 
80
    public function testAcceptsSucceeds($expected, $actual)
 
81
    {
 
82
        $this->assertTrue(
 
83
          $this->comparator->accepts($expected, $actual)
 
84
        );
 
85
    }
 
86
 
 
87
    /**
 
88
     * @covers       ::accepts
 
89
     * @dataProvider acceptsFailsProvider
 
90
     */
 
91
    public function testAcceptsFails($expected, $actual)
 
92
    {
 
93
        $this->assertFalse(
 
94
          $this->comparator->accepts($expected, $actual)
 
95
        );
 
96
    }
 
97
 
 
98
    /**
 
99
     * @covers       ::assertEquals
 
100
     * @dataProvider assertEqualsSucceedsProvider
 
101
     */
 
102
    public function testAssertEqualsSucceeds($expected, $actual)
 
103
    {
 
104
        $exception = null;
 
105
 
 
106
        try {
 
107
            $this->comparator->assertEquals($expected, $actual);
 
108
        }
 
109
 
 
110
        catch (ComparisonFailure $exception) {
 
111
        }
 
112
 
 
113
        $this->assertNull($exception, 'Unexpected ComparisonFailure');
 
114
    }
 
115
 
 
116
    /**
 
117
     * @covers       ::assertEquals
 
118
     * @dataProvider assertEqualsFailsProvider
 
119
     */
 
120
    public function testAssertEqualsFails($expected, $actual)
 
121
    {
 
122
        $this->setExpectedException('SebastianBergmann\\Comparator\\ComparisonFailure');
 
123
        $this->comparator->assertEquals($expected, $actual);
 
124
    }
 
125
}