Skip to content

Commit 533dde2

Browse files
committed
AC-958: create unit test for Magento2\Annotation checks
1 parent 9eda380 commit 533dde2

4 files changed

+414
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,309 @@
1+
<?php
2+
3+
/**
4+
* Class for method structure for annotations test cases
5+
*/
6+
class MethodAnnotationFixture
7+
{
8+
/**
9+
*
10+
* @inheritdoc
11+
*/
12+
public function getProductListDefaultSortBy1()
13+
{
14+
}
15+
16+
/**
17+
*
18+
* @inheritdoc
19+
*/
20+
public function getProductListDefaultSortBy10($store = null)
21+
{
22+
return $store;
23+
}
24+
25+
/**
26+
* Block for short
27+
*
28+
* {@inheritdoc}
29+
*
30+
*/
31+
public function getProductListDefaultSortBy102()
32+
{
33+
}
34+
35+
/**
36+
* {@inheritdoc}
37+
*/
38+
public function getProductListDefaultBy()
39+
{
40+
return;
41+
}
42+
43+
/**
44+
*
45+
* {@inheritdoc}
46+
*
47+
*/
48+
public function getProductListDefaultSortBy13()
49+
{
50+
return;
51+
}
52+
53+
/**
54+
* ProductVisibilityCondition constructor
55+
* @param \Magento\Catalog\Model\Product\Visibility $productVisibility
56+
*/
57+
public function content(\Magento\Catalog\Model\Product\Visibility $productVisibility)
58+
{
59+
$this->productVisibility = $productVisibility;
60+
}
61+
62+
/**
63+
* block description
64+
*
65+
* {@inheritdoc}
66+
*
67+
* @param \Magento\Catalog\Model\ResourceModel\Product\Collection $collection
68+
* @return void
69+
*/
70+
public function construct(AbstractDb $collection)
71+
{
72+
/** @var */
73+
$collection->setVisibility($this->productVisibility->getVisibleInCatalogIds());
74+
}
75+
76+
/**
77+
* Move category
78+
*
79+
*
80+
* @param int $parentId new parent category id
81+
*
82+
* @return $this
83+
* @throws \Magento\Framework\Exception\LocalizedException|\Exception
84+
*/
85+
public function move($parentId)
86+
{
87+
/**
88+
* Validate new parent category id. (category model is used for backward
89+
* compatibility in event params)
90+
*/
91+
try {
92+
$this->categoryRepository->get($parentId, $this->getStoreId());
93+
}
94+
catch (NoSuchEntityException $e) {
95+
throw new \Magento\Framework\Exception\LocalizedException(
96+
__('Sorry, but we can\'t find the new parent category you selected.'),
97+
$e
98+
);
99+
}
100+
return true;
101+
}
102+
103+
/**
104+
* Block for short description
105+
*
106+
* This a long description {@inheritdoc} consists more lines as part of the long description
107+
* on multi line.
108+
*
109+
* @param int $store
110+
*
111+
*
112+
*/
113+
public function getProductListDefaultSortBy26032($store)
114+
{
115+
return $store;
116+
}
117+
118+
/**
119+
*
120+
*
121+
*
122+
*/
123+
public function getProductListDefaultSortBy2632()
124+
{
125+
}
126+
127+
/**
128+
* Block for short description
129+
*
130+
* This a long description {@inheritdoc} consists more lines as part of the long description
131+
* on multi line.
132+
*
133+
* @param int $store
134+
*
135+
*
136+
*
137+
*/
138+
public function getProductListDefaultSortBy2002($store)
139+
{
140+
return $store;
141+
}
142+
143+
/**
144+
*
145+
* block for short description
146+
*
147+
* @param int $store
148+
* @return int
149+
*/
150+
public function getProductListDefaultSortBy3002($store)
151+
{
152+
return $store;
153+
}
154+
155+
/**
156+
* Block for short description
157+
*
158+
* @see consists more lines as part of the long description
159+
* on multi line.
160+
*
161+
* @param string $store
162+
* @param string $foo
163+
*/
164+
public function getProductListDefaultSortBy12($store, $foo)
165+
{
166+
return $store === $foo;
167+
}
168+
169+
/**
170+
* Block for short description
171+
*
172+
* {@inheritdoc}
173+
*
174+
* @param string $store
175+
* @param string $foo
176+
*/
177+
public function getProductListDefaultSort2($store, $foo)
178+
{
179+
return $store === $foo;
180+
}
181+
182+
/**
183+
* Block for short description
184+
*
185+
* a long description {@inheritdoc} consists more lines as part of the long description
186+
* on multi line.
187+
*
188+
* @param string $store
189+
* @param string $foo
190+
*/
191+
public function getProductListDefault($store, $foo)
192+
{
193+
return $store === $foo;
194+
}
195+
196+
/**
197+
* Retrieve custom options
198+
*
199+
* @param ProductOptionInterface $productOption
200+
*
201+
* @return array
202+
*/
203+
protected function getCustomOptions(ProductOptionInterface $productOption)
204+
{
205+
if ($productOption
206+
&& $productOption->getExtensionAttributes()
207+
&& $productOption->getExtensionAttributes()->getCustomOptions()
208+
) {
209+
return $productOption->getExtensionAttributes()->getCustomOptions();
210+
}
211+
return [];
212+
}
213+
214+
/**
215+
* This is the summary for a DocBlock.
216+
*
217+
* This is the description for a DocBlock. This text may contain
218+
* multiple lines and even some _markdown_.
219+
* * Markdown style lists function too
220+
* * Just try this out once
221+
* The section after the description contains the tags; which provide
222+
* structured meta-data concerning the given element.
223+
*
224+
* @param int $example This is an example function/method parameter description.
225+
* @param string $example2 This is a second example.
226+
*
227+
*/
228+
public function getProductListDefaultSortBy2($example, $example2)
229+
{
230+
return $example === $example2;
231+
}
232+
233+
/**
234+
* Returns the content of the tokens from the specified start position in
235+
* the token stack for the specified length.
236+
*
237+
* @param int $start
238+
* @param int $length
239+
*
240+
* @return string The token contents.
241+
*/
242+
public function getProductListDefaultSortBy($start, $length)
243+
{
244+
return $start === $length;
245+
}
246+
247+
/**
248+
* Some text about this step/method returns the content of the tokens the token stack for the specified length
249+
*
250+
* @param string $name
251+
* @param string $folder
252+
*
253+
* @see this file
254+
* @When I create a file called :name in :folder
255+
*/
256+
public function getProductListDefaultSortBy222($name, $folder)
257+
{
258+
return $name === $folder;
259+
}
260+
261+
public function setExtensionAs(\Magento\Catalog\Api\Data\CategoryExtensionInterface $extensionAttributes)
262+
{
263+
return $this->_setExtensionAttributes($extensionAttributes);
264+
}
265+
266+
/**
267+
*
268+
* short description
269+
* @param \Magento\Catalog\Api\Data\CategoryExtensionInterface $extensionAttributes
270+
* @return mixed
271+
*/
272+
public function setEn(\Magento\Catalog\Api\Data\CategoryExtensionInterface $extensionAttributes)
273+
{
274+
return $this->_setExtensionAttributes($extensionAttributes);
275+
}
276+
277+
/**
278+
* @param \Magento\Catalog\Api\Data\CategoryExtensionInterface $extensionAttributes
279+
* @return mixed
280+
*/
281+
public function setExtenw(\Magento\Catalog\Api\Data\CategoryExtensionInterface $extensionAttributes)
282+
{
283+
return $this->_setExtensionAttributes($extensionAttributes);
284+
}
285+
286+
/**
287+
*
288+
* Short description
289+
* @param \Magento\Catalog\Api\Data\CategoryExtensionInterface $extensionAttributes
290+
* @return mixed
291+
*/
292+
public function setExff(\Magento\Catalog\Api\Data\CategoryExtensionInterface $extensionAttributes)
293+
{
294+
return $this->_setExtensionAttributes($extensionAttributes);
295+
}
296+
297+
/**
298+
* {@inheritdoc}
299+
*
300+
* @param int $start
301+
* @param int $length
302+
*
303+
* @return string The token contents.
304+
*/
305+
public function getProductSortBy($start, $length)
306+
{
307+
return $start === $length;
308+
}
309+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento2\Tests\Annotation;
7+
8+
use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest;
9+
10+
class MethodAnnotationStructureUnitTest extends AbstractSniffUnitTest
11+
{
12+
/**
13+
* @inheritdoc
14+
*/
15+
public function getErrorList()
16+
{
17+
return [
18+
10 => 1,
19+
18 => 1,
20+
30 => 1,
21+
36 => 1,
22+
45 => 2,
23+
47 => 1,
24+
55 => 1,
25+
63 => 1,
26+
80 => 1,
27+
112 => 1,
28+
118 => 1,
29+
137 => 1,
30+
145 => 2,
31+
185 => 1,
32+
227 => 1,
33+
235 => 1,
34+
268 => 2,
35+
269 => 1,
36+
277 => 1,
37+
278 => 1,
38+
288 => 1,
39+
289 => 1,
40+
298 => 1
41+
];
42+
}
43+
44+
/**
45+
* @inheritdoc
46+
*/
47+
public function getWarningList()
48+
{
49+
return [];
50+
}
51+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
/**
3+
* This is the summary for a DocBlock.
4+
*
5+
* This is the description for a DocBlock. This text may contain
6+
* multiple lines and even some _markdown_.
7+
* * Markdown style lists function too
8+
* * Just try this out once
9+
* The section after the description contains the tags; which provide
10+
* structured meta-data concerning the given element.
11+
*
12+
* @param int $example This is an example function/method parameter description.
13+
* @param string $example2 This is a second example.
14+
*
15+
*/
16+
public function getProductListDefaultSortBy2($example, $example2)
17+
{
18+
return $example === $example2;
19+
}
20+
21+
public function setExtensionAs(\Magento\Catalog\Api\Data\CategoryExtensionInterface $extensionAttributes)
22+
{
23+
return $this->_setExtensionAttributes($extensionAttributes);
24+
}

0 commit comments

Comments
 (0)