Adds new test case for single doc type imports.

Corrects issue with installing/importing single or multiple doc types, which is not part of the usual complete package xml.
This commit is contained in:
Morten Christensen
2013-04-03 18:26:54 -02:00
parent b9d7f0c5a5
commit e207b1f1e1
6 changed files with 94 additions and 2 deletions

View File

@@ -85,6 +85,34 @@ namespace Umbraco.Tests.Services.Importing {
}
}
/// <summary>
/// Looks up a localized string similar to &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;
///&lt;DocumentType&gt;
/// &lt;Info&gt;
/// &lt;Name&gt;test&lt;/Name&gt;
/// &lt;Alias&gt;test&lt;/Alias&gt;
/// &lt;Icon&gt;folder.gif&lt;/Icon&gt;
/// &lt;Thumbnail&gt;folder.png&lt;/Thumbnail&gt;
/// &lt;Description&gt;
/// &lt;/Description&gt;
/// &lt;AllowAtRoot&gt;False&lt;/AllowAtRoot&gt;
/// &lt;AllowedTemplates&gt;
/// &lt;Template&gt;test&lt;/Template&gt;
/// &lt;/AllowedTemplates&gt;
/// &lt;DefaultTemplate&gt;test&lt;/DefaultTemplate&gt;
/// &lt;/Info&gt;
/// &lt;Structure&gt;
/// &lt;DocumentType&gt;test&lt;/DocumentType&gt;
/// &lt;/Structure&gt;
/// &lt;GenericProperties&gt;
/// &lt;GenericProperty&gt; [rest of string was truncated]&quot;;.
/// </summary>
internal static string SingleDocType {
get {
return ResourceManager.GetString("SingleDocType", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;
///&lt;umbPackage&gt;

View File

@@ -130,4 +130,7 @@
<data name="XsltSearch_Package" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>xsltsearch-package.xml;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="SingleDocType" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>singledoctype.xml;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
</root>

View File

@@ -206,5 +206,22 @@ namespace Umbraco.Tests.Services.Importing
Assert.That(templates.Any(), Is.True);
Assert.That(templates.Count(), Is.EqualTo(numberOfTemplates));
}
[Test]
public void PackagingService_Can_Import_Single_DocTypr()
{
// Arrange
string strXml = ImportResources.SingleDocType;
var docTypeElement = XElement.Parse(strXml);
var packagingService = ServiceContext.PackagingService;
// Act
var contentTypes = packagingService.ImportContentTypes(docTypeElement);
// Assert
Assert.That(contentTypes.Any(), Is.True);
Assert.That(contentTypes.Any(x => x.HasIdentity == false), Is.False);
Assert.That(contentTypes.Count(), Is.EqualTo(1));
}
}
}

View File

@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8" ?>
<DocumentType>
<Info>
<Name>test</Name>
<Alias>test</Alias>
<Icon>folder.gif</Icon>
<Thumbnail>folder.png</Thumbnail>
<Description>
</Description>
<AllowAtRoot>False</AllowAtRoot>
<AllowedTemplates>
<Template>test</Template>
</AllowedTemplates>
<DefaultTemplate>test</DefaultTemplate>
</Info>
<Structure>
<DocumentType>test</DocumentType>
</Structure>
<GenericProperties>
<GenericProperty>
<Name>test</Name>
<Alias>test</Alias>
<Type>b4471851-82b6-4c75-afa4-39fa9c6a75e9</Type>
<Definition>fbaf13a8-4036-41f2-93a3-974f678c312a</Definition>
<Tab>
</Tab>
<Mandatory>False</Mandatory>
<Validation>
</Validation>
<Description><![CDATA[]]></Description>
</GenericProperty>
</GenericProperties>
<Tabs />
</DocumentType>

View File

@@ -426,6 +426,7 @@
<Content Include="Migrations\SqlScripts\SqlCeTotal-480.sql" />
<Content Include="Migrations\SqlScripts\SqlServerTotal-480.sql" />
<Content Include="Services\Importing\InheritedDocTypes-Package.xml" />
<Content Include="Services\Importing\SingleDocType.xml" />
<Content Include="Services\Importing\StandardMvc-Package.xml">
<SubType>Designer</SubType>
</Content>

View File

@@ -421,7 +421,12 @@ namespace umbraco.cms.businesslogic.packager
#endregion
#region DocumentTypes
var docTypeElement = rootElement.Descendants("DocumentTypes").FirstOrDefault();
//Check whether the root element is a doc type rather then a complete package
var docTypeElement = rootElement.Name.LocalName.Equals("DocumentType") ||
rootElement.Name.LocalName.Equals("DocumentTypes")
? rootElement
: rootElement.Descendants("DocumentTypes").FirstOrDefault();
if (docTypeElement != null)
{
var contentTypes = packagingService.ImportContentTypes(docTypeElement, currentUser.Id);
@@ -692,7 +697,11 @@ namespace umbraco.cms.businesslogic.packager
#endregion
#region Install DocumentTypes
var docTypeElement = rootElement.Descendants("DocumentTypes").FirstOrDefault();
//Check whether the root element is a doc type rather then a complete package
var docTypeElement = rootElement.Name.LocalName.Equals("DocumentType") ||
rootElement.Name.LocalName.Equals("DocumentTypes")
? rootElement
: rootElement.Descendants("DocumentTypes").FirstOrDefault();
if (docTypeElement != null)
{
var contentTypes = packagingService.ImportContentTypes(docTypeElement, currentUser.Id);