public function testVisit()
{
$visitor = $this->getVisitor();
$generator = $this->getGenerator();
$generator->startDocument(null);
$contentTypeGroupRefList = new ContentTypeGroupRefList(new ContentType(array('id' => 42, 'fieldDefinitions' => array())), array(new ContentTypeGroup(array('id' => 1)), new ContentTypeGroup(array('id' => 2))));
$this->addRouteExpectation('ezpublish_rest_listContentTypesForGroup', array('contentTypeGroupId' => $contentTypeGroupRefList->contentType->id), "/content/types/{$contentTypeGroupRefList->contentType->id}/groups");
// first iteration
$this->addRouteExpectation('ezpublish_rest_loadContentTypeGroup', array('contentTypeGroupId' => $contentTypeGroupRefList->contentTypeGroups[0]->id), "/content/typegroups/{$contentTypeGroupRefList->contentTypeGroups[0]->id}");
$this->addRouteExpectation('ezpublish_rest_unlinkContentTypeFromGroup', array('contentTypeId' => $contentTypeGroupRefList->contentType->id, 'contentTypeGroupId' => $contentTypeGroupRefList->contentTypeGroups[0]->id), "/content/types/{$contentTypeGroupRefList->contentType->id}/groups/{$contentTypeGroupRefList->contentTypeGroups[0]->id}");
// second iteration
$this->addRouteExpectation('ezpublish_rest_loadContentTypeGroup', array('contentTypeGroupId' => $contentTypeGroupRefList->contentTypeGroups[1]->id), "/content/typegroups/{$contentTypeGroupRefList->contentTypeGroups[1]->id}");
$this->addRouteExpectation('ezpublish_rest_unlinkContentTypeFromGroup', array('contentTypeId' => $contentTypeGroupRefList->contentType->id, 'contentTypeGroupId' => $contentTypeGroupRefList->contentTypeGroups[1]->id), "/content/types/{$contentTypeGroupRefList->contentType->id}/groups/{$contentTypeGroupRefList->contentTypeGroups[1]->id}");
$visitor->visit($this->getVisitorMock(), $generator, $contentTypeGroupRefList);
$result = $generator->endDocument(null);
$this->assertNotNull($result);
$dom = new \DOMDocument();
$dom->loadXml($result);
return $dom;
}