Last active
December 8, 2020 07:54
-
-
Save iamdylanngo/ca256c9b06cc515c5cc43646ae32e8d1 to your computer and use it in GitHub Desktop.
CleanTableCronJob
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Demo\Demo\Cron; | |
// Need move to CleanTableCronJobTest class | |
use Magento\Catalog\Model\ProductRepository; | |
use Magento\Store\Model\StoreManagerInterface; | |
class CleanTableCronJob | |
{ | |
/** | |
* @var StoreManagerInterface | |
*/ | |
private $storeManager; | |
/** | |
* @var ProductRepository | |
*/ | |
private $productRepository; | |
public function __construct( | |
StoreManagerInterface $storeManager, | |
ProductRepository $productRepository | |
) { | |
$this->storeManager = $storeManager; | |
$this->productRepository = $productRepository; | |
} | |
/** | |
* CronJob Description | |
* | |
* @return void | |
*/ | |
public function execute(): void | |
{ | |
// todo: implement cronjob logic here | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
namespace Demo\Demo\Test\Unit\Cron; | |
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; | |
use PHPUnit\Framework\TestCase; | |
use Mockery; | |
use Demo\Demo\Cron\CleanTableCronJob; | |
// Auto import | |
use Magento\Catalog\Model\ProductRepository; | |
use Magento\Store\Model\StoreManagerInterface; | |
class CleanTableCronJobTest extends TestCase | |
{ | |
/** | |
* @var ObjectManager | |
*/ | |
public $objectManager; | |
protected function setUp() | |
{ | |
parent::setUp(); | |
$this->objectManager = new ObjectManager($this); | |
$this->storeManager = Mockery::mock(StoreManagerInterface:class); | |
$this->productRepository = Mockery::mock(ProductRepository:class); | |
} | |
protected function tearDown() | |
{ | |
parent::tearDown(); | |
Mockery::close(); | |
} | |
/** | |
* @return object|CleanTableCronJob | |
*/ | |
public function getSubjectUnderTest() | |
{ | |
return $this->objectManager->getObject(CleanTableCronJob::class, [ | |
]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment