Skip to content

Commit 481e1c1

Browse files
committed
AC-15048::[CE] PHPUnit 12: Upgrade Search & Navigation related test cases
1 parent 588eac3 commit 481e1c1

File tree

141 files changed

+3617
-1658
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

141 files changed

+3617
-1658
lines changed
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
<?php
2+
/**
3+
* Copyright 2024 Adobe
4+
* All Rights Reserved.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\AdvancedSearch\Test\Unit\Helper;
9+
10+
use Magento\AdvancedSearch\Model\Client\ClientInterface;
11+
12+
/**
13+
* Test helper for ClientInterface
14+
* Provides ping() and testConnection() methods that don't exist on the interface
15+
*/
16+
class ClientInterfaceTestHelper implements ClientInterface
17+
{
18+
/**
19+
* @var bool
20+
*/
21+
private $pingResult = true;
22+
23+
/**
24+
* @var bool
25+
*/
26+
private $testConnectionResult = true;
27+
28+
/**
29+
* @var array
30+
*/
31+
private $queryResults = [];
32+
33+
/**
34+
* @var int
35+
*/
36+
private $queryResultIndex = 0;
37+
38+
/**
39+
* Skip constructor
40+
*/
41+
public function __construct()
42+
{
43+
// Skip parent constructor to avoid dependency injection issues
44+
}
45+
46+
/**
47+
* Ping method for testing
48+
*
49+
* @return bool
50+
*/
51+
public function ping(): bool
52+
{
53+
return $this->pingResult;
54+
}
55+
56+
/**
57+
* Set ping result
58+
*
59+
* @param bool $result
60+
* @return $this
61+
*/
62+
public function setPingResult(bool $result): self
63+
{
64+
$this->pingResult = $result;
65+
return $this;
66+
}
67+
68+
/**
69+
* Test connection method for testing
70+
*
71+
* @return bool
72+
*/
73+
public function testConnection(): bool
74+
{
75+
return $this->testConnectionResult;
76+
}
77+
78+
/**
79+
* Set test connection result
80+
*
81+
* @param bool $result
82+
* @return $this
83+
*/
84+
public function setTestConnectionResult(bool $result): self
85+
{
86+
$this->testConnectionResult = $result;
87+
return $this;
88+
}
89+
90+
/**
91+
* Query method (from interface)
92+
*
93+
* @param array $query
94+
* @return array
95+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
96+
*/
97+
public function query($query): array
98+
{
99+
if (empty($this->queryResults)) {
100+
return [];
101+
}
102+
103+
$result = $this->queryResults[$this->queryResultIndex] ?? [];
104+
$this->queryResultIndex++;
105+
106+
return $result;
107+
}
108+
109+
/**
110+
* Set query results
111+
*
112+
* @param array $results
113+
* @return $this
114+
*/
115+
public function setQueryResults(array $results): self
116+
{
117+
$this->queryResults = $results;
118+
$this->queryResultIndex = 0;
119+
return $this;
120+
}
121+
122+
/**
123+
* Bulk query method (from interface)
124+
*
125+
* @param array $query
126+
* @return array
127+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
128+
*/
129+
public function bulkQuery($query): array
130+
{
131+
return [];
132+
}
133+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
/**
3+
* Copyright 2018 Adobe
4+
* All Rights Reserved.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Backend\Test\Unit\Helper;
9+
10+
use Magento\Backend\Model\Session;
11+
12+
/**
13+
* Test helper for Session class
14+
*/
15+
class SessionTestHelper extends Session
16+
{
17+
/**
18+
* @var array
19+
*/
20+
private $pageData;
21+
22+
/**
23+
* Constructor
24+
*/
25+
public function __construct()
26+
{
27+
// Skip parent constructor to avoid dependency injection issues
28+
}
29+
30+
/**
31+
* Set page data
32+
*
33+
* @param array $data
34+
* @return $this
35+
*/
36+
public function setPageData($data)
37+
{
38+
$this->pageData = $data;
39+
return $this;
40+
}
41+
42+
/**
43+
* Get page data
44+
*
45+
* @return array|null
46+
*/
47+
public function getPageData()
48+
{
49+
return $this->pageData;
50+
}
51+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
/**
3+
* Copyright 2018 Adobe
4+
* All Rights Reserved.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Catalog\Test\Unit\Helper;
9+
10+
use Magento\Catalog\Model\Layer\Filter\AbstractFilter;
11+
12+
/**
13+
* Test helper for AbstractFilter class
14+
*/
15+
class AbstractFilterTestHelper extends AbstractFilter
16+
{
17+
/**
18+
* @var mixed
19+
*/
20+
private $attributeModel;
21+
22+
/**
23+
* Skip parent constructor
24+
*/
25+
public function __construct()
26+
{
27+
}
28+
29+
/**
30+
* Get attribute model
31+
*
32+
* @return mixed
33+
*/
34+
public function getAttributeModel()
35+
{
36+
return $this->attributeModel;
37+
}
38+
39+
/**
40+
* Set attribute model
41+
*
42+
* @param mixed $attr
43+
* @return void
44+
*/
45+
public function setAttributeModel($attr)
46+
{
47+
$this->attributeModel = $attr;
48+
}
49+
50+
/**
51+
* Has attribute model
52+
*
53+
* @return bool
54+
*/
55+
public function hasAttributeModel()
56+
{
57+
return $this->attributeModel !== null;
58+
}
59+
}
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
<?php
2+
/**
3+
* Copyright 2018 Adobe
4+
* All Rights Reserved.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Catalog\Test\Unit\Helper;
9+
10+
use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
11+
use Magento\Swatches\Model\Swatch;
12+
13+
/**
14+
* Test helper for Attribute class
15+
*/
16+
class AttributeTestHelper extends Attribute
17+
{
18+
/**
19+
* @var array
20+
*/
21+
private $data = [];
22+
23+
/**
24+
* @var string
25+
*/
26+
private $additionalData;
27+
28+
/**
29+
* Constructor
30+
*
31+
* @param string|null $additionalData
32+
*/
33+
public function __construct($additionalData = null)
34+
{
35+
$this->additionalData = $additionalData;
36+
}
37+
38+
/**
39+
* Has data
40+
*
41+
* @param string|null $key
42+
* @return bool
43+
*/
44+
public function hasData($key = null)
45+
{
46+
return $key !== Swatch::SWATCH_INPUT_TYPE_KEY;
47+
}
48+
49+
/**
50+
* Get data
51+
*
52+
* @param string $key
53+
* @param mixed $index
54+
* @return mixed
55+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
56+
*/
57+
public function getData($key = '', $index = null)
58+
{
59+
if ($key === 'additional_data') {
60+
return $this->additionalData;
61+
}
62+
return $this->data[$key] ?? null;
63+
}
64+
65+
/**
66+
* Set data
67+
*
68+
* @param string|array $key
69+
* @param mixed $value
70+
* @return $this
71+
*/
72+
public function setData($key, $value = null)
73+
{
74+
if (is_array($key)) {
75+
$this->data = array_merge($this->data, $key);
76+
} else {
77+
$this->data[$key] = $value;
78+
}
79+
return $this;
80+
}
81+
82+
/**
83+
* Get ID
84+
*
85+
* @return string
86+
*/
87+
public function getId()
88+
{
89+
return 'id';
90+
}
91+
92+
/**
93+
* Get frontend label
94+
*
95+
* @return string
96+
*/
97+
public function getFrontendLabel()
98+
{
99+
return 'label';
100+
}
101+
102+
/**
103+
* Get attribute code
104+
*
105+
* @return string
106+
*/
107+
public function getAttributeCode()
108+
{
109+
return 'code';
110+
}
111+
112+
/**
113+
* Get source
114+
*
115+
* @return object
116+
*/
117+
public function getSource()
118+
{
119+
return new class {
120+
public function getAllOptions($withEmpty = false)
121+
{
122+
return ['options'];
123+
}
124+
};
125+
}
126+
}

0 commit comments

Comments
 (0)