/** * Test that flip() will replace keys with their value, and the value with the key. Will remove empty values first. */ public function testFlip() { $data = array('true' => true, 'false' => false, 'null' => null, 'zero' => 0, 'stringZero' => '0', 'empty' => array(), 'array' => array('false' => false, 'null' => null, 'empty' => array())); $this->assertEquals(array(1 => 'true', 0 => 'stringZero', 'empty' => array(), 'array' => array('empty' => array())), Hash::flip($data)); $data = array('foo' => 'bar', 1 => 'one', 2 => 'two', true, false, null, 'key' => 'value', 'baz' => 'bar'); $this->assertEquals(array('bar' => 'baz', 'one' => '', 'two' => '', 1 => '', 'value' => 'key'), Hash::flip($data)); $this->assertEquals(array(1 => 'boolean', 123 => 'integer', 'foobar' => 'strings', 1988 => 'numeric', 'empty' => array(), 'one' => array(1 => 'depth', 'two' => array(2 => 'depth', 'three' => array(3 => 'depth', 1 => 'true', 0 => 'zero', 'four' => array('five' => array('six' => array('seven' => array('We can go deeper!' => 'key')))))))), Hash::flip($this->expanded)); }