public function testFlattenTwoLevels()
{
$data = array(array('Post' => array('id' => '1', 'author_id' => '1', 'title' => 'First Post'), 'Author' => array('id' => '1', 'user' => 'nate', 'password' => 'foo')), array('Post' => array('id' => '2', 'author_id' => '3', 'title' => 'Second Post', 'body' => 'Second Post Body'), 'Author' => array('id' => '3', 'user' => 'joel', 'password' => null)));
$expected = array('0.Post.id' => '1', '0.Post.author_id' => '1', '0.Post.title' => 'First Post', '0.Author.id' => '1', '0.Author.user' => 'nate', '0.Author.password' => 'foo', '1.Post.id' => '2', '1.Post.author_id' => '3', '1.Post.title' => 'Second Post', '1.Post.body' => 'Second Post Body', '1.Author.id' => '3', '1.Author.user' => 'joel', '1.Author.password' => null);
$result = Set::flatten($data);
$this->assertEqual($expected, $result);
$result = Set::expand($result);
$this->assertEqual($data, $result);
$result = Set::flatten($data[0], array('separator' => '/'));
$expected = array('Post/id' => '1', 'Post/author_id' => '1', 'Post/title' => 'First Post', 'Author/id' => '1', 'Author/user' => 'nate', 'Author/password' => 'foo');
$this->assertEqual($expected, $result);
$result = Set::expand($expected, array('separator' => '/'));
$this->assertEqual($data[0], $result);
}