CoreFiles by mySites.guru
MatchTest.php56 lines, 1,641 bytes, from Joomla_4.0.0-beta6-Beta-Full_Package.zip
Raw History Compare with 4.0.0-beta5
md5
8267920785b103eba468ed71328fec85
sha1
59bc59b2bd354bc2e1b9788582daebbbefa4b9db
sha256
99f3ab28dbb56b589fb83d1ea649de340a85362348595aa003ac5cc19e2e3522
<?php

namespace Negotiation\Tests;

use Negotiation\Match;

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

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

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

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

The same content is in 13 releases, Joomla 4.0.0-alpha7 to 4.0.0-beta7. See them all, or every version of this file.