Completed
Push — master ( fee712...2d57a6 )
by André
133:34 queued 112:15
created

RelationTest::testRelation()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 53

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 53
rs 9.0254
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
/**
4
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
5
 * @license For full copyright and license information view LICENSE file distributed with this source code.
6
 */
7
namespace eZ\Bundle\EzPublishRestBundle\Tests\Functional;
8
9
use eZ\Bundle\EzPublishRestBundle\Tests\Functional\TestCase as RESTFunctionalTestCase;
10
11
class RelationTest extends RESTFunctionalTestCase
12
{
13
    public function testRelation()
14
    {
15
        $xml = <<< XML
16
<?xml version="1.0" encoding="UTF-8"?>
17
<ContentCreate>
18
  <ContentType href="/api/ezp/v2/content/types/2" />
19
  <mainLanguageCode>eng-GB</mainLanguageCode>
20
  <LocationCreate>
21
    <ParentLocation href="/api/ezp/v2/content/locations/1/2" />
22
    <priority>0</priority>
23
    <hidden>false</hidden>
24
    <sortField>PATH</sortField>
25
    <sortOrder>ASC</sortOrder>
26
  </LocationCreate>
27
  <Section href="/api/ezp/v2/content/sections/1" />
28
  <alwaysAvailable>true</alwaysAvailable>
29
  <User href="/api/ezp/v2/user/users/14" />
30
  <modificationDate>2012-09-30T12:30:00</modificationDate>
31
  <fields>
32
    <field>
33
      <fieldDefinitionIdentifier>title</fieldDefinitionIdentifier>
34
      <languageCode>eng-GB</languageCode>
35
      <fieldValue>testRelation</fieldValue>
36
    </field>
37
    <field>
38
      <fieldDefinitionIdentifier>intro</fieldDefinitionIdentifier>
39
      <languageCode>eng-GB</languageCode>
40
      <fieldValue>
41
        <value key="xml">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
42
&lt;section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ezxhtml="http://ez.no/xmlns/ezpublish/docbook/xhtml" xmlns:ezcustom="http://ez.no/xmlns/ezpublish/docbook/custom" version="5.0-variant ezpublish-1.0"&gt;
43
&lt;title ezxhtml:level="2"&gt;This is a title.&lt;/title&gt;
44
&lt;para&gt;&lt;link xlink:href="ezcontent://1" xml:id="id1" xlink:title="Content title" ezxhtml:class="linkClass5"&gt;Content name&lt;/link&gt;&lt;/para&gt;
45
&lt;ezembed xlink:href="ezcontent://1" view="line" xml:id="embed-id-2" ezxhtml:class="embedClass2" ezxhtml:align="right"/&gt;
46
&lt;/section&gt;</value>
47
      </fieldValue>
48
    </field>
49
    <field>
50
      <fieldDefinitionIdentifier>image</fieldDefinitionIdentifier>
51
      <languageCode>eng-GB</languageCode>
52
      <fieldValue>
53
        <value key="destinationContentId">1</value>
54
      </fieldValue>
55
    </field>
56
  </fields>
57
</ContentCreate>
58
XML;
59
        $testContent = $this->createContent($xml);
60
        $relations = $testContent['CurrentVersion']['Version']['Relations']['Relation'];
61
62
        self::assertEquals('LINK', $relations[0]['RelationType']);
63
        self::assertEquals('EMBED', $relations[1]['RelationType']);
64
        self::assertEquals('ATTRIBUTE', $relations[2]['RelationType']);
65
    }
66
}
67