Skip to content

Commit b76fb79

Browse files
committed
AC-15800::[CE] PHPUnit 12: Refactor Inline Anonymous Classes to Helper Classes in PR #2559 & PR#2579 | Add PHPUnit 12 test helpers for Media Modules
1 parent e028c45 commit b76fb79

File tree

2 files changed

+109
-0
lines changed

2 files changed

+109
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
/**
3+
* Copyright 2024 Adobe
4+
* All Rights Reserved.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Framework\Model\Test\Unit\Helper;
9+
10+
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
11+
12+
/**
13+
* Test helper for AbstractDb class
14+
*/
15+
class AbstractDbTestHelper extends AbstractDb
16+
{
17+
/**
18+
* Constructor - skip parent constructor to avoid dependencies
19+
*/
20+
public function __construct()
21+
{
22+
// Skip parent constructor to avoid dependency injection issues
23+
}
24+
25+
/**
26+
* Protected construct method
27+
*
28+
* @return void
29+
*/
30+
protected function _construct()
31+
{
32+
// Skip parent implementation
33+
}
34+
35+
/**
36+
* Delete folder
37+
*
38+
* @param string $path
39+
* @return bool
40+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
41+
*/
42+
public function deleteFolder($path)
43+
{
44+
return true;
45+
}
46+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
/**
3+
* Copyright 2024 Adobe
4+
* All Rights Reserved.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Framework\Model\Test\Unit\Helper;
9+
10+
use Magento\Framework\Model\AbstractModel;
11+
12+
/**
13+
* Test helper for AbstractModel class
14+
*/
15+
class AbstractModelTestHelper extends AbstractModel
16+
{
17+
/**
18+
* @var \Magento\MediaStorage\Model\File\Storage\Database
19+
*/
20+
private $fileMock;
21+
22+
/**
23+
* Constructor - skip parent constructor to avoid dependencies
24+
*/
25+
public function __construct()
26+
{
27+
// Skip parent constructor to avoid dependency injection issues
28+
}
29+
30+
/**
31+
* Load by filename
32+
*
33+
* @param string $filename
34+
* @return \Magento\MediaStorage\Model\File\Storage\Database
35+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
36+
*/
37+
public function loadByFileName($filename)
38+
{
39+
return $this->fileMock;
40+
}
41+
42+
/**
43+
* Set file mock
44+
*
45+
* @param \Magento\MediaStorage\Model\File\Storage\Database $fileMock
46+
* @return $this
47+
*/
48+
public function setFileMock($fileMock)
49+
{
50+
$this->fileMock = $fileMock;
51+
return $this;
52+
}
53+
54+
/**
55+
* Get file mock
56+
*
57+
* @return \Magento\MediaStorage\Model\File\Storage\Database
58+
*/
59+
public function getFileMock()
60+
{
61+
return $this->fileMock;
62+
}
63+
}

0 commit comments

Comments
 (0)