/** * Test maxDimensions * * @return void */ public function testMaxDimensions() { $data = []; $result = Hash::maxDimensions($data); $this->assertEquals(0, $result); $data = ['a', 'b']; $result = Hash::maxDimensions($data); $this->assertEquals(1, $result); $data = ['1' => '1.1', '2', '3' => ['3.1' => '3.1.1']]; $result = Hash::maxDimensions($data); $this->assertEquals($result, 2); $data = ['1' => ['1.1' => '1.1.1'], '2', '3' => ['3.1' => ['3.1.1' => '3.1.1.1']]]; $result = Hash::maxDimensions($data); $this->assertEquals($result, 3); $data = ['1' => ['1.1' => '1.1.1'], ['2' => ['2.1' => ['2.1.1' => '2.1.1.1']]], '3' => ['3.1' => ['3.1.1' => '3.1.1.1']]]; $result = Hash::maxDimensions($data); $this->assertEquals($result, 4); $data = ['1' => ['1.1' => '1.1.1', '1.2' => ['1.2.1' => ['1.2.1.1', ['1.2.2.1']]]], '2' => ['2.1' => '2.1.1']]; $result = Hash::maxDimensions($data); $this->assertEquals($result, 5); }
/** * Test maxDimensions * * @return void */ public function testMaxDimensions() { $data = array('1' => '1.1', '2', '3' => array('3.1' => '3.1.1')); $result = Hash::maxDimensions($data); $this->assertEquals($result, 2); $data = array('1' => array('1.1' => '1.1.1'), '2', '3' => array('3.1' => array('3.1.1' => '3.1.1.1'))); $result = Hash::maxDimensions($data); $this->assertEquals($result, 3); $data = array('1' => array('1.1' => '1.1.1'), array('2' => array('2.1' => array('2.1.1' => '2.1.1.1'))), '3' => array('3.1' => array('3.1.1' => '3.1.1.1'))); $result = Hash::maxDimensions($data); $this->assertEquals($result, 4); $data = array('1' => array('1.1' => '1.1.1'), array('2' => array('2.1' => array('2.1.1' => array('2.1.1.1')))), '3' => array('3.1' => array('3.1.1' => '3.1.1.1'))); $result = Hash::maxDimensions($data); $this->assertEquals($result, 5); $data = array('1' => array('1.1' => '1.1.1'), array('2' => array('2.1' => array('2.1.1' => array('2.1.1.1' => '2.1.1.1.1')))), '3' => array('3.1' => array('3.1.1' => '3.1.1.1'))); $result = Hash::maxDimensions($data); $this->assertEquals($result, 5); $data = array('1' => array('1.1' => '1.1.1'), array('2' => array('2.1' => array('2.1.1' => array('2.1.1.1' => '2.1.1.1.1')))), '3' => array('3.1' => array('3.1.1' => '3.1.1.1'))); $result = Hash::maxDimensions($data); $this->assertEquals($result, 5); }