CoreFiles by mySites.guru
MatchTest.php56 lines, 1,779 bytes, from Joomla_4.0.0-rc6-Release_Candidate-Full_Package.zip
Raw History Compare with 4.0.0-rc5
md5
508761050fc033954722bfe0d1f2fec8
sha1
271e7dae2ec1ec41d98ee4d6f724a66d5c953286
sha256
b6b3cd17a1f9f54835d2deb687f894385ce5e6b7982a8a05b34a5d5da9d5ee31
<?php

namespace Negotiation\Tests;

use Negotiation\AcceptMatch;

class MatchTest extends TestCase
{
    /**
     * @dataProvider dataProviderForTestCompare
     */
    public function testCompare($match1, $match2, $expected)
    {
        $this->assertEquals($expected, AcceptMatch::compare($match1, $match2));
    }

    public static function dataProviderForTestCompare()
    {
        return array(
            array(new AcceptMatch(1.0, 110, 1), new AcceptMatch(1.0, 111, 1),    0),
            array(new AcceptMatch(0.1, 10,  1), new AcceptMatch(0.1,  10, 2),   -1),
            array(new AcceptMatch(0.5, 110, 5), new AcceptMatch(0.5,  11, 4),    1),
            array(new AcceptMatch(0.4, 110, 1), new AcceptMatch(0.6, 111, 3),    1),
            array(new AcceptMatch(0.6, 110, 1), new AcceptMatch(0.4, 111, 3),   -1),
        );
    }

    /**
     * @dataProvider dataProviderForTestReduce
     */
    public function testReduce($carry, $match, $expected)
    {
        $this->assertEquals($expected, AcceptMatch::reduce($carry, $match));
    }

    public static function dataProviderForTestReduce()
    {
        return array(
            array(
                array(1 => new AcceptMatch(1.0, 10, 1)),
                new AcceptMatch(0.5, 111, 1),
                array(1 => new AcceptMatch(0.5, 111, 1)),
            ),
            array(
                array(1 => new AcceptMatch(1.0, 110, 1)),
                new AcceptMatch(0.5, 11, 1),
                array(1 => new AcceptMatch(1.0, 110, 1)),
            ),
            array(
                array(0 => new AcceptMatch(1.0, 10, 1)),
                new AcceptMatch(0.5, 111, 1),
                array(0 => new AcceptMatch(1.0, 10, 1), 1 => new AcceptMatch(0.5, 111, 1)),
            ),
        );
    }
}

The same content is in 6 releases, Joomla 4.0.0-rc1 to 4.0.0-rc6. See them all, or every version of this file.