Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove "Undefined fields" from app folder #11625

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,14 @@ class WebsiteTest extends \PHPUnit\Framework\TestCase
*/
protected $website;

/**
* @var \Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing\Validator\Website|\PHPUnit_Framework_MockObject_MockObject
*/
protected $websiteString;

protected function setUp()
{
$this->webSiteModel = $this->getMockBuilder(\Magento\Store\Model\WebSite::class)
$this->webSiteModel = $this->getMockBuilder(\Magento\Store\Model\Website::class)
->setMethods(['getBaseCurrency'])
->disableOriginalConstructor()
->getMock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ class RedirectTest extends \PHPUnit\Framework\TestCase
*/
protected $helperMock;

/**
* @var Redirect
*/
protected $controller;

protected function setUp()
{
$this->directpostSessionMock = $this->getMockBuilder(\Magento\Authorizenet\Model\Directpost\Session::class)
Expand Down
5 changes: 5 additions & 0 deletions app/code/Magento/Backend/Block/Dashboard/Bar.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ class Bar extends \Magento\Backend\Block\Dashboard\AbstractDashboard
*/
protected $_currentCurrencyCode = null;

/**
* @var \Magento\Directory\Model\Currency
*/
protected $_currency;

/**
* @return array
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@

class RefreshStatistics extends \Magento\Reports\Controller\Adminhtml\Report\Statistics
{
/**
* @var \Psr\Log\LoggerInterface
*/
private $logger;

/**
* @param \Magento\Backend\App\Action\Context $context
* @param \Magento\Framework\Stdlib\DateTime\Filter\Date $dateFilter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
*/
namespace Magento\Backend\Test\Unit\App\Action\Plugin;

use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Backend\App\AbstractAction;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;

class MassactionKeyTest extends \PHPUnit\Framework\TestCase
{
Expand All @@ -28,9 +28,6 @@ class MassactionKeyTest extends \PHPUnit\Framework\TestCase

protected function setUp()
{
$this->closureMock = function () {
return 'Expected';
};
$this->subjectMock = $this->createMock(\Magento\Backend\App\AbstractAction::class);
$this->requestMock = $this->getMockForAbstractClass(
RequestInterface::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ class AnchorRendererTest extends \PHPUnit\Framework\TestCase
*/
private $menuItemMock;

/**
* @var Item|\PHPUnit_Framework_MockObject_MockObject
*/
private $menuItemWithoutChildrenMock;

/**
* @var Escaper|\PHPUnit_Framework_MockObject_MockObject
*/
Expand Down
17 changes: 11 additions & 6 deletions app/code/Magento/Backend/Test/Unit/Block/MenuTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
*/
namespace Magento\Backend\Test\Unit\Block;

use Magento\Backend\Model\Menu\Item;
use Magento\Backend\Model\Menu as MenuModel;
use Magento\Backend\Block\AnchorRenderer;
use Magento\Backend\Block\Menu;
use Magento\Backend\Model\UrlInterface;
use Magento\Backend\Model\Menu\Filter\IteratorFactory;
use Magento\Backend\Block\MenuItemChecker;
use Magento\Backend\Model\Auth\Session;
use Magento\Backend\Model\Menu as MenuModel;
use Magento\Backend\Model\Menu\Config;
use Magento\Backend\Model\Menu\Filter\IteratorFactory;
use Magento\Backend\Model\Menu\Item;
use Magento\Backend\Model\UrlInterface;
use Magento\Framework\Locale\ResolverInterface;
use Magento\Backend\Block\MenuItemChecker;
use Magento\Backend\Block\AnchorRenderer;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;

class MenuTest extends \PHPUnit\Framework\TestCase
Expand Down Expand Up @@ -74,6 +74,11 @@ class MenuTest extends \PHPUnit\Framework\TestCase
*/
private $menu;

/**
* @var MenuItemChecker|\PHPUnit_Framework_MockObject_MockObject
*/
private $menuItemChecker;

protected function setUp()
{
$this->activeItemMock = $this->getMockBuilder(Item::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ protected function _factory($request, $response = null)
if (!$response) {
/** @var $response \Magento\Framework\App\ResponseInterface|\PHPUnit_Framework_MockObject_MockObject */
$response = $this->createMock(\Magento\Framework\App\Response\Http::class);
/** @noinspection PhpUndefinedFieldInspection */
$response->headersSentThrowsException = false;
}
$helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
Expand Down
5 changes: 5 additions & 0 deletions app/code/Magento/Backup/Model/Fs/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ class Collection extends \Magento\Framework\Data\Collection\Filesystem
*/
protected $_backup = null;

/**
* @var \Magento\Framework\Filesystem
*/
protected $_filesystem;

/**
* @param \Magento\Framework\Data\Collection\EntityFactory $entityFactory
* @param \Magento\Backup\Helper\Data $backupData
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public function handle(array $handlingSubject, array $response)
private function getVaultPaymentToken(Transaction $transaction)
{
// Check token existing in gateway response
/** @noinspection PhpUndefinedFieldInspection */
$token = $transaction->paypalDetails->token;
if (empty($token)) {
return null;
Expand All @@ -95,6 +96,7 @@ private function getVaultPaymentToken(Transaction $transaction)
$paymentToken = $this->paymentTokenFactory->create();
$paymentToken->setGatewayToken($token);
$paymentToken->setExpiresAt($this->getExpirationDate());
/** @noinspection PhpUndefinedFieldInspection */
$details = json_encode([
'payerEmail' => $transaction->paypalDetails->payerEmail
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public function handle(array $handlingSubject, array $response)
protected function getVaultPaymentToken(Transaction $transaction)
{
// Check token existing in gateway response
/** @noinspection PhpUndefinedFieldInspection */
$token = $transaction->creditCardDetails->token;
if (empty($token)) {
return null;
Expand All @@ -107,6 +108,7 @@ protected function getVaultPaymentToken(Transaction $transaction)
$paymentToken->setGatewayToken($token);
$paymentToken->setExpiresAt($this->getExpirationDate($transaction));

/** @noinspection PhpUndefinedFieldInspection */
$paymentToken->setTokenDetails($this->convertDetailsToJSON([
'type' => $this->getCreditCardType($transaction->creditCardDetails->cardType),
'maskedCC' => $transaction->creditCardDetails->last4,
Expand All @@ -122,6 +124,7 @@ protected function getVaultPaymentToken(Transaction $transaction)
*/
private function getExpirationDate(Transaction $transaction)
{
/** @noinspection PhpUndefinedFieldInspection */
$expDate = new \DateTime(
$transaction->creditCardDetails->expirationYear
. '-'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use Magento\Sales\Api\Data\OrderPaymentExtensionInterfaceFactory;
use Magento\Sales\Model\Order\Payment;
use Magento\Vault\Api\Data\PaymentTokenInterface;
use Magento\Vault\Api\Data\PaymentTokenInterfaceFactory;
use Magento\Vault\Model\AccountPaymentTokenFactory;
use Magento\Vault\Model\PaymentToken;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
Expand Down Expand Up @@ -122,7 +121,7 @@ protected function setUp()
->disableOriginalConstructor()
->setMethods(['create'])
->getMock();

$this->handler = new VaultDetailsHandler(
$this->paymentTokenFactory,
$this->paymentExtensionFactory,
Expand Down Expand Up @@ -153,7 +152,7 @@ public function testHandle()
->method('readTransaction')
->with($response)
->willReturn($transaction);

$this->paymentDataObject->expects(static::once())
->method('getPayment')
->willReturn($this->paymentInfo);
Expand All @@ -171,7 +170,7 @@ public function testHandle()
$this->dateTimeFactory->expects(static::once())
->method('create')
->willReturn($dateTime);

$this->handler->handle($this->subject, $response);

$extensionAttributes = $this->paymentInfo->getExtensionAttributes();
Expand All @@ -182,7 +181,9 @@ public function testHandle()
$tokenDetails = json_decode($paymentToken->getTokenDetails(), true);

static::assertSame($this->paymentToken, $paymentToken);
/** @noinspection PhpUndefinedFieldInspection */
static::assertEquals($transaction->paypalDetails->token, $paymentToken->getGatewayToken());
/** @noinspection PhpUndefinedFieldInspection */
static::assertEquals($transaction->paypalDetails->payerEmail, $tokenDetails['payerEmail']);
static::assertEquals($expirationDate, $paymentToken->getExpiresAt());
}
Expand All @@ -193,6 +194,7 @@ public function testHandle()
public function testHandleWithoutToken()
{
$transaction = $this->getTransaction();
/** @noinspection PhpUndefinedFieldInspection */
$transaction->paypalDetails->token = null;

$response = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use Magento\Braintree\Gateway\Config\Config;
use Magento\Braintree\Gateway\Helper\SubjectReader;
use Magento\Braintree\Gateway\Response\VaultDetailsHandler;
use Magento\Framework\DataObject;
use Magento\Payment\Gateway\Data\PaymentDataObject;
use Magento\Sales\Api\Data\OrderPaymentExtensionInterface;
use Magento\Sales\Api\Data\OrderPaymentExtensionInterfaceFactory;
Expand Down Expand Up @@ -69,6 +68,11 @@ class VaultDetailsHandlerTest extends \PHPUnit\Framework\TestCase
*/
private $config;

/**
* @var \Magento\Framework\Serialize\Serializer\Json|\PHPUnit_Framework_MockObject_MockObject
*/
private $serializer;

protected function setUp()
{
$this->paymentToken = $this->createMock(PaymentTokenInterface::class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
*/
namespace Magento\Braintree\Test\Unit\Gateway\Validator;

use Braintree\Result\Error;
use Braintree\Result\Successful;
use Braintree\Transaction;
use Magento\Braintree\Gateway\Helper\SubjectReader;
use Magento\Braintree\Gateway\Validator\ResponseValidator;
use Magento\Framework\Phrase;
use Magento\Payment\Gateway\Validator\ResultInterface;
use Magento\Payment\Gateway\Validator\ResultInterfaceFactory;
use Magento\Braintree\Gateway\Validator\ResponseValidator;
use Magento\Braintree\Gateway\Helper\SubjectReader;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
use Braintree\Result\Error;
use Braintree\Result\Successful;

/**
* Class ResponseValidatorTest
Expand Down Expand Up @@ -130,6 +130,7 @@ public function dataProviderTestValidate()
{
$successTrue = new Successful();
$successTrue->success = true;
/** @noinspection PhpUndefinedFieldInspection */
$successTrue->transaction = new \stdClass();
$successTrue->transaction->status = Transaction::AUTHORIZED;

Expand All @@ -138,6 +139,7 @@ public function dataProviderTestValidate()

$transactionDeclined = new Successful();
$transactionDeclined->success = true;
/** @noinspection PhpUndefinedFieldInspection */
$transactionDeclined->transaction = new \stdClass();
$transactionDeclined->transaction->status = Transaction::SETTLEMENT_DECLINED;

Expand Down
7 changes: 6 additions & 1 deletion app/code/Magento/Bundle/Model/LinkManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\EntityManager\MetadataPool;
use Magento\Framework\Exception\CouldNotSaveException;
use Magento\Framework\Exception\InputException;
use Magento\Framework\EntityManager\MetadataPool;

/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
Expand Down Expand Up @@ -53,6 +53,11 @@ class LinkManagement implements \Magento\Bundle\Api\ProductLinkManagementInterfa
*/
private $metadataPool;

/**
* @var \Magento\Store\Model\StoreManagerInterface
*/
private $storeManager;

/**
* @param ProductRepositoryInterface $productRepository
* @param \Magento\Bundle\Api\Data\LinkInterfaceFactory $linkFactory
Expand Down
11 changes: 8 additions & 3 deletions app/code/Magento/Bundle/Pricing/Price/BundleOptionPrice.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ class BundleOptionPrice extends AbstractPrice implements BundleOptionPriceInterf
*/
protected $maximalPrice;

/**
* @var array
*/
private $optionSelectionAmountCache;

/**
* @param Product $saleableItem
* @param float $quantity
Expand Down Expand Up @@ -118,13 +123,13 @@ public function getOptionSelectionAmount($selection)
]
);

if (!isset($this->optionSelecionAmountCache[$cacheKey])) {
if (!isset($this->optionSelectionAmountCache[$cacheKey])) {
$selectionPrice = $this->selectionFactory
->create($this->product, $selection, $selection->getSelectionQty());
$this->optionSelecionAmountCache[$cacheKey] = $selectionPrice->getAmount();
$this->optionSelectionAmountCache[$cacheKey] = $selectionPrice->getAmount();
}

return $this->optionSelecionAmountCache[$cacheKey];
return $this->optionSelectionAmountCache[$cacheKey];
}

/**
Expand Down
8 changes: 7 additions & 1 deletion app/code/Magento/Bundle/Test/Unit/Model/Product/TypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Magento\Bundle\Model\Selection;
use Magento\Catalog\Model\Product;
use Magento\Catalog\Model\Product\Option\Type\DefaultType;
use Magento\CatalogRule\Model\ResourceModel\Product\CollectionProcessor;
use Magento\Framework\DataObject;
use Magento\Framework\EntityManager\EntityMetadataInterface;
use Magento\Framework\EntityManager\MetadataPool;
Expand Down Expand Up @@ -87,6 +88,11 @@ class TypeTest extends \PHPUnit\Framework\TestCase
*/
private $serializer;

/**
* @var CollectionProcessor|\PHPUnit_Framework_MockObject_MockObject
*/
private $catalogRuleProcessor;

/**
* @return void
*/
Expand Down Expand Up @@ -145,7 +151,7 @@ protected function setUp()
->getMock();

$this->catalogRuleProcessor = $this->getMockBuilder(
\Magento\CatalogRule\Model\ResourceModel\Product\CollectionProcessor::class
CollectionProcessor::class
)
->disableOriginalConstructor()
->getMock();
Expand Down
5 changes: 5 additions & 0 deletions app/code/Magento/Catalog/Block/Product/View/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ class Options extends \Magento\Framework\View\Element\Template
*/
protected $_catalogData;

/**
* @var \Magento\Framework\Stdlib\ArrayUtils
*/
protected $arrayUtils;

/**
* @param \Magento\Framework\View\Element\Template\Context $context
* @param \Magento\Framework\Pricing\Helper\Data $pricingHelper
Expand Down
5 changes: 5 additions & 0 deletions app/code/Magento/Catalog/CustomerData/CompareProducts.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ class CompareProducts implements SectionSourceInterface
*/
protected $productUrl;

/**
* @var \Magento\Catalog\Helper\Output
*/
protected $outputHelper;

/**
* @param \Magento\Catalog\Helper\Product\Compare $helper
* @param \Magento\Catalog\Model\Product\Url $productUrl
Expand Down
Loading