• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

misantron / dbunit / 4562384438

pending completion
4562384438

push

github

Aleksandr Ivanov
Fix build status badge display

635 of 1200 relevant lines covered (52.92%)

5.65 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

33.33
/src/Constraint/DataSetIsEqual.php
1
<?php
2

3
/*
4
 * This file is part of DbUnit.
5
 *
6
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11

12
namespace PHPUnit\DbUnit\Constraint;
13

14
use PHPUnit\DbUnit\DataSet\IDataSet;
15
use PHPUnit\DbUnit\Exception\InvalidArgumentException;
16
use PHPUnit\Framework\Constraint\Constraint;
17

18
/**
19
 * Asserts whether or not two dbunit datasets are equal.
20
 */
21
class DataSetIsEqual extends Constraint
22
{
23
    /**
24
     * @var IDataSet
25
     */
26
    protected $value;
27

28
    /**
29
     * @param IDataSet $value
30
     */
31
    public function __construct(IDataSet $value)
32
    {
33
        $this->value = $value;
22✔
34
    }
35

36
    /**
37
     * Returns a string representation of the constraint.
38
     *
39
     * @return string
40
     */
41
    public function toString(): string
42
    {
43
        return sprintf(
×
44
            'is equal to expected %s',
×
45
            (string) $this->value
×
46
        );
×
47
    }
48

49
    /**
50
     * Evaluates the constraint for parameter $other. Returns TRUE if the
51
     * constraint is met, FALSE otherwise.
52
     *
53
     * This method can be overridden to implement the evaluation algorithm.
54
     *
55
     * @param IDataSet $other value or object to evaluate
56
     *
57
     * @return bool
58
     */
59
    protected function matches($other): bool
60
    {
61
        if (!$other instanceof IDataSet) {
22✔
62
            throw new InvalidArgumentException('Only dataset instance can be matched');
×
63
        }
64

65
        return $this->value->matches($other);
22✔
66
    }
67

68
    /**
69
     * Returns the description of the failure
70
     *
71
     * The beginning of failure messages is "Failed asserting that" in most
72
     * cases. This method should return the second part of that sentence.
73
     *
74
     * @param mixed $other evaluated value or object
75
     *
76
     * @return string
77
     */
78
    protected function failureDescription($other): string
79
    {
80
        return $other . ' ' . $this->toString();
×
81
    }
82
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc