public function testItUpdatesMetadataObjectsFromSource()
 {
     $sources = $this->stubSources(array('id_one', 'id_two', 'id_three', 'id_four', 'id_five', 'id_seven'));
     $metadata = $this->stubMetadataObjects(array('id_one' => array('handle_one', 'handle_two', 'handle_three'), 'id_two' => array('handle_two', 'handle_three', 'handle_five', 'handle_six'), 'id_four' => array('handle_four'), 'id_five' => array('handle_five'), 'id_six' => array('handle_six')), array(2, 1, 1, 2, 1));
     $newMetadata = $this->stubMetadataObjects(array('id_two' => array('handle_two'), 'id_three' => array('handle_three'), 'id_four' => array('handle_four', 'handle_five')), 1, false);
     $expectedMetadata = array('id_one' => $metadata['id_one'], 'id_two' => $newMetadata['id_two'], 'id_three' => $newMetadata['id_three'], 'id_four' => $newMetadata['id_four'], 'id_five' => $metadata['id_five']);
     $expectedMetadataHandles = array('handle_one' => array('id_one' => $expectedMetadata['id_one']), 'handle_two' => array('id_one' => $expectedMetadata['id_one'], 'id_two' => $expectedMetadata['id_two']), 'handle_three' => array('id_one' => $expectedMetadata['id_one'], 'id_three' => $expectedMetadata['id_three']), 'handle_four' => array('id_four' => $expectedMetadata['id_four']), 'handle_five' => array('id_four' => $expectedMetadata['id_four'], 'id_five' => $expectedMetadata['id_five']));
     $testException = new RuntimeException('something wrong is going to happen');
     $this->compiler->expects($this->exactly(6))->method('compile')->withConsecutive(array($sources['id_one'], $metadata['id_one']), array($sources['id_two'], $metadata['id_two']), array($sources['id_three'], null), array($sources['id_four'], $metadata['id_four']), array($sources['id_five'], $metadata['id_five']), array($sources['id_seven'], null))->willReturnOnConsecutiveCalls($metadata['id_one'], $newMetadata['id_two'], $newMetadata['id_three'], $newMetadata['id_four'], $metadata['id_five'], $this->throwException($testException));
     $errorProcessor = $this->createErrorProcessor($this->index);
     $errorProcessor->expects($this->once())->method('processException')->with($testException)->willReturnSelf();
     $this->index->setLayout($this->layout);
     $this->index->update($sources);
     $this->assertAttributeSame($expectedMetadata, 'metadata', $this->index);
     $this->assertAttributeSame($expectedMetadataHandles, 'metadataByHandle', $this->index);
 }