init
This commit is contained in:
+46
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\Framework\App\TestStubs;
|
||||
|
||||
use Magento\Backend\App\Action;
|
||||
use Magento\Framework\App\ResponseInterface;
|
||||
use Magento\Framework\Controller\ResultInterface;
|
||||
use Magento\Framework\View\Result\Page;
|
||||
use Magento\Framework\View\Result\PageFactory;
|
||||
|
||||
/**
|
||||
* Stub inheritance based backend action controller for testing purposes.
|
||||
*/
|
||||
class InheritanceBasedBackendAction extends Action
|
||||
{
|
||||
/**
|
||||
* @var PageFactory
|
||||
*/
|
||||
private $pageFactory;
|
||||
|
||||
/**
|
||||
* @param Action\Context $context
|
||||
* @param PageFactory $pageFactory
|
||||
*/
|
||||
public function __construct(Action\Context $context, PageFactory $pageFactory)
|
||||
{
|
||||
parent::__construct($context);
|
||||
$this->pageFactory = $pageFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates Page
|
||||
*
|
||||
* @return ResponseInterface|ResultInterface|Page
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
return $this->pageFactory->create();
|
||||
}
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\Framework\App\TestStubs;
|
||||
|
||||
use Magento\Framework\App\Action\Action;
|
||||
use Magento\Framework\App\Action\Context;
|
||||
use Magento\Framework\App\ResponseInterface;
|
||||
use Magento\Framework\Controller\ResultInterface;
|
||||
use Magento\Framework\View\Result\Page;
|
||||
use Magento\Framework\View\Result\PageFactory;
|
||||
|
||||
/**
|
||||
* Stub inheritance based frontend action controller for testing purposes.
|
||||
*/
|
||||
class InheritanceBasedFrontendAction extends Action
|
||||
{
|
||||
/**
|
||||
* @var PageFactory
|
||||
*/
|
||||
private $pageFactory;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $executeWasCalled = false;
|
||||
|
||||
/**
|
||||
* @param Context $context
|
||||
* @param PageFactory $pageFactory
|
||||
*/
|
||||
public function __construct(Context $context, PageFactory $pageFactory)
|
||||
{
|
||||
parent::__construct($context);
|
||||
$this->pageFactory = $pageFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs `execute()` method to create Page
|
||||
*
|
||||
* @return ResponseInterface|ResultInterface|Page
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
$this->executeWasCalled = true;
|
||||
return $this->pageFactory->create();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether execute method was called
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isExecuted(): bool
|
||||
{
|
||||
return $this->executeWasCalled;
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\Framework\App\TestStubs;
|
||||
|
||||
use Magento\Framework\App\ActionInterface;
|
||||
use Magento\Framework\App\ResponseInterface;
|
||||
use Magento\Framework\Controller\ResultInterface;
|
||||
use Magento\Framework\View\Result\Page;
|
||||
use Magento\Framework\View\Result\PageFactory;
|
||||
|
||||
/**
|
||||
* Stub interface action controller implementation for testing purposes.
|
||||
*/
|
||||
class InterfaceOnlyBackendAction implements ActionInterface
|
||||
{
|
||||
/**
|
||||
* @var PageFactory
|
||||
*/
|
||||
private $pageFactory;
|
||||
|
||||
/**
|
||||
* @param PageFactory $pageFactory
|
||||
*/
|
||||
public function __construct(PageFactory $pageFactory)
|
||||
{
|
||||
$this->pageFactory = $pageFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates Page object
|
||||
*
|
||||
* @return ResponseInterface|ResultInterface|Page
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
return $this->pageFactory->create();
|
||||
}
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\Framework\App\TestStubs;
|
||||
|
||||
use Magento\Framework\App\ActionInterface;
|
||||
use Magento\Framework\App\ResponseInterface;
|
||||
use Magento\Framework\Controller\ResultInterface;
|
||||
use Magento\Framework\View\Result\Page;
|
||||
use Magento\Framework\View\Result\PageFactory;
|
||||
|
||||
/**
|
||||
* Stub interface only based frontend action controller for testing purposes.
|
||||
*/
|
||||
class InterfaceOnlyFrontendAction implements ActionInterface
|
||||
{
|
||||
/**
|
||||
* @var PageFactory
|
||||
*/
|
||||
private $pageFactory;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $executeWasCalled = false;
|
||||
|
||||
/**
|
||||
* @param PageFactory $pageFactory
|
||||
*/
|
||||
public function __construct(PageFactory $pageFactory)
|
||||
{
|
||||
$this->pageFactory = $pageFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates Page object
|
||||
*
|
||||
* @return ResponseInterface|ResultInterface|Page
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
$this->executeWasCalled = true;
|
||||
return $this->pageFactory->create();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether `execute()` method was ran
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isExecuted(): bool
|
||||
{
|
||||
return $this->executeWasCalled;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user