Skip to content

Commit 44a3889

Browse files
committed
Merge remote-tracking branch 'warxcell/patch-3' into release/3.x
2 parents bae176e + 7ec8921 commit 44a3889

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

src/DocBlock/Description.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,16 @@ public function __construct($bodyTemplate, array $tags = [])
6969
$this->bodyTemplate = $bodyTemplate;
7070
$this->tags = $tags;
7171
}
72+
73+
/**
74+
* Returns the tags for this DocBlock.
75+
*
76+
* @return Tag[]
77+
*/
78+
public function getTags()
79+
{
80+
return $this->tags;
81+
}
7282

7383
/**
7484
* Renders this description as a string where the provided formatter will format the tags in the expected string

tests/unit/DocBlock/DescriptionTest.php

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,58 @@ public function testDescriptionCanBeCastToString()
6464
$this->assertSame($expected, (string)$fixture);
6565
}
6666

67+
/**
68+
* @covers ::getTags
69+
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Generic
70+
* @uses \phpDocumentor\Reflection\DocBlock\Tags\BaseTag
71+
*/
72+
public function testDescriptionTagsGetter()
73+
{
74+
$body = '@JoinTable(name="table", joinColumns=%1$s, inverseJoinColumns=%2$s)';
75+
76+
$tag1 = new Generic('JoinColumn', new Description('(name="column_id", referencedColumnName="id")'));
77+
$tag2 = new Generic('JoinColumn', new Description('(name="column_id_2", referencedColumnName="id")'));
78+
79+
$tags = [
80+
$tag1,
81+
$tag2,
82+
];
83+
84+
$fixture = new Description($body, $tags);
85+
86+
$this->assertEquals(2, count($fixture->getTags()));
87+
88+
$actualTags = $fixture->getTags();
89+
$this->assertSame($tags, $actualTags);
90+
$this->assertSame($tag1, $actualTags[0]);
91+
$this->assertSame($tag2, $actualTags[1]);
92+
}
93+
94+
/**
95+
* @covers ::__construct
96+
* @covers ::render
97+
* @covers ::__toString
98+
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Generic
99+
* @uses \phpDocumentor\Reflection\DocBlock\Tags\BaseTag
100+
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
101+
*/
102+
public function testDescriptionMultipleTagsCanBeCastToString()
103+
{
104+
$body = '@JoinTable(name="table", joinColumns=%1$s, inverseJoinColumns=%2$s)';
105+
106+
$tag1 = new Generic('JoinColumn', new Description('(name="column_id", referencedColumnName="id")'));
107+
$tag2 = new Generic('JoinColumn', new Description('(name="column_id_2", referencedColumnName="id")'));
108+
109+
$tags = [
110+
$tag1,
111+
$tag2,
112+
];
113+
114+
$fixture = new Description($body, $tags);
115+
$expected = '@JoinTable(name="table", joinColumns={@JoinColumn (name="column_id", referencedColumnName="id")}, inverseJoinColumns={@JoinColumn (name="column_id_2", referencedColumnName="id")})';
116+
$this->assertSame($expected, (string)$fixture);
117+
}
118+
67119
/**
68120
* @covers ::__construct
69121
* @expectedException \InvalidArgumentException

0 commit comments

Comments
 (0)