4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\CssSelector\Tests\Node;
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\CssSelector\Node\Specificity;
17 class SpecificityTest extends TestCase
19 /** @dataProvider getValueTestData */
20 public function testValue(Specificity $specificity, $value)
22 $this->assertEquals($value, $specificity->getValue());
25 /** @dataProvider getValueTestData */
26 public function testPlusValue(Specificity $specificity, $value)
28 $this->assertEquals($value + 123, $specificity->plus(new Specificity(1, 2, 3))->getValue());
31 public function getValueTestData()
34 array(new Specificity(0, 0, 0), 0),
35 array(new Specificity(0, 0, 2), 2),
36 array(new Specificity(0, 3, 0), 30),
37 array(new Specificity(4, 0, 0), 400),
38 array(new Specificity(4, 3, 2), 432),
42 /** @dataProvider getCompareTestData */
43 public function testCompareTo(Specificity $a, Specificity $b, $result)
45 $this->assertEquals($result, $a->compareTo($b));
48 public function getCompareTestData()
51 array(new Specificity(0, 0, 0), new Specificity(0, 0, 0), 0),
52 array(new Specificity(0, 0, 1), new Specificity(0, 0, 1), 0),
53 array(new Specificity(0, 0, 2), new Specificity(0, 0, 1), 1),
54 array(new Specificity(0, 0, 2), new Specificity(0, 0, 3), -1),
55 array(new Specificity(0, 4, 0), new Specificity(0, 4, 0), 0),
56 array(new Specificity(0, 6, 0), new Specificity(0, 5, 11), 1),
57 array(new Specificity(0, 7, 0), new Specificity(0, 8, 0), -1),
58 array(new Specificity(9, 0, 0), new Specificity(9, 0, 0), 0),
59 array(new Specificity(11, 0, 0), new Specificity(10, 11, 0), 1),
60 array(new Specificity(12, 11, 0), new Specificity(13, 0, 0), -1),