public function testShuffleAssoc() { $this->assertEquals('string', Arrays::shuffleAssoc('string')); $expected = ['x' => 'x', 'y' => 'y', 'z' => 'z']; $shuffled = Arrays::shuffleAssoc($expected); $this->assertFalse((bool) array_diff_assoc($expected, $shuffled)); $this->assertFalse((bool) array_diff_assoc($shuffled, $expected)); srand(40); $expected = ['z' => 'z', 'y' => 'y', 'x' => 'x']; $shuffled = Arrays::shuffleAssoc($expected); $this->assertEquals(json_encode($expected), json_encode($shuffled)); }
/** * Shuffles an array maintaining key association * * @param array $array * * @return array * * @deprecated */ function shuffle_assoc($array) { return \Packaged\Helpers\Arrays::shuffleAssoc($array); }
/** * @return $this */ private function _sortByRand() { $this->words = Arrays::shuffleAssoc($this->words); return $this; }