1<?php
2
3/*
4 * This file is part of Twig.
5 *
6 * (c) Fabien Potencier
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11require_once __DIR__.'/../../../../lib/Twig/Extensions/Extension/Array.php';
12
13class Twig_Tests_Extension_ArrayTest extends \PHPUnit\Framework\TestCase
14{
15    /**
16     * @dataProvider getShuffleFilterTestData
17     */
18    public function testShuffleFilter($data, $expectedElements)
19    {
20        foreach ($expectedElements as $element) {
21            $this->assertTrue(in_array($element, twig_shuffle_filter($data), true)); // assertContains() would not consider the type
22        }
23    }
24
25    public function testShuffleFilterOnEmptyArray()
26    {
27        $this->assertEquals(array(), twig_shuffle_filter(array()));
28    }
29
30    public function getShuffleFilterTestData()
31    {
32        return array(
33            array(
34                array(1, 2, 3),
35                array(1, 2, 3),
36            ),
37            array(
38                array('a' => 'apple', 'b' => 'orange', 'c' => 'citrus'),
39                array('apple', 'orange', 'citrus'),
40            ),
41            array(
42                new ArrayObject(array('apple', 'orange', 'citrus')),
43                array('apple', 'orange', 'citrus'),
44            ),
45        );
46    }
47}
48