As I use more and more mock objects when testing I often have to fake the results of some findAll calls. That means I have to create array structures as shown in the following example:

$expectedPosts = array(array('Post' => array('id' => 3, 'title' => 'a title', 'content' => 'some content')),
			               array('Post' => array('id' => 4, 'title' => 'another title', 'content' => 'some other content')));

The core class Set provides an alternative way to create arrays using a dot notation. The example from above can be rewritten as:

$expectedPosts = array();
$expectedPosts = Set::insert($expectedPosts, '0.Post.id', 3);
$expectedPosts = Set::insert($expectedPosts, '0.Post.title', 'a title');
$expectedPosts = Set::insert($expectedPosts, '0.Post.content', 'some content');
$expectedPosts = Set::insert($expectedPosts, '1.Post.id', 4);
$expectedPosts = Set::insert($expectedPosts, '1.Post.title', 'another title');
$expectedPosts = Set::insert($expectedPosts, '1.Post.content', 'some other content');

You can also mix those two approaches:

$expectedPosts = array();
$expectedPosts = Set::insert($expectedPosts, '0.Post', array('id' => 3, 'title' => 'a title', 'content' => 'some content'));
$expectedPosts = Set::insert($expectedPosts, '1.Post', array('id' => 4, 'title' => 'another title', 'content' => 'some other content'));

It is quite handy, especially if you have to create more complex array structures.