Skip to content

Commit

Permalink
Merge pull request #290 from magento-troll/develop
Browse files Browse the repository at this point in the history
[Troll] Bugfixes & Code quality improvements
  • Loading branch information
Ganin, Roman(rganin) committed May 15, 2015
2 parents e9378e4 + 520e354 commit 05b2964
Show file tree
Hide file tree
Showing 18 changed files with 466 additions and 484 deletions.
24 changes: 24 additions & 0 deletions app/code/Magento/Contact/Block/ContactForm.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Contact\Block;

use Magento\Framework\View\Element\Template;

/**
* Main contact form block
*/
class ContactForm extends Template
{
/**
* @param Template\Context $context
* @param array $data
*/
public function __construct(Template\Context $context, array $data = [])
{
parent::__construct($context, $data);
$this->_isScopePrivate = true;
}
}
44 changes: 44 additions & 0 deletions app/code/Magento/Contact/Test/Unit/Block/ContactFormTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Contact\Test\Unit\Block;

use Magento\Contact\Block\ContactForm;

class ContactFormTest extends \PHPUnit_Framework_TestCase
{
/**
* @var \Magento\Contact\Block\ContactForm
*/
protected $contactForm;

/**
* @var \Magento\Framework\View\Element\Template\Context|\PHPUnit_Framework_MockObject_MockObject
*/
protected $contextMock;

/**
* {@inheritDoc}
*/
protected function setUp()
{
$this->contextMock = $this->getMockBuilder('Magento\Framework\View\Element\Template\Context')
->disableOriginalConstructor()
->getMock();

$this->contactForm = new ContactForm(
$this->contextMock
);
}

/**
* @return void
*/
public function testScope()
{
$this->assertTrue($this->contactForm->isScopePrivate());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</head>
<body>
<referenceContainer name="content">
<block class="Magento\Framework\View\Element\Template" name="contactForm" template="Magento_Contact::form.phtml">
<block class="Magento\Contact\Block\ContactForm" name="contactForm" template="Magento_Contact::form.phtml">
<container name="form.additional.info" label="Form Additional Info"/>
</block>
</referenceContainer>
Expand Down
137 changes: 0 additions & 137 deletions app/code/Magento/Reports/Block/Adminhtml/Product/Grid.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
/**
* Adminhtml abandoned shopping carts report grid block
*
* @method \Magento\Reports\Model\Resource\Quote\Collection getCollection
*
* @author Magento Core Team <core@magentocommerce.com>
* @SuppressWarnings(PHPMD.DepthOfInheritance)
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\Shopcart
/**
* @var \Magento\Reports\Model\Resource\Quote\CollectionFactory
*/
protected $_quotesFactory;
protected $quoteItemCollectionFactory;

/**
* @var \Magento\Quote\Model\QueryResolver
Expand All @@ -26,18 +26,18 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\Shopcart
/**
* @param \Magento\Backend\Block\Template\Context $context
* @param \Magento\Backend\Helper\Data $backendHelper
* @param \Magento\Reports\Model\Resource\Quote\CollectionFactoryInterface $quotesFactory
* @param \Magento\Reports\Model\Resource\Quote\Item\CollectionFactory $quoteItemCollectionFactory
* @param \Magento\Quote\Model\QueryResolver $queryResolver
* @param array $data
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\Backend\Helper\Data $backendHelper,
\Magento\Reports\Model\Resource\Quote\CollectionFactoryInterface $quotesFactory,
\Magento\Quote\Model\QueryResolver $queryResolver,
\Magento\Reports\Model\Resource\Quote\Item\CollectionFactory $quoteItemCollectionFactory,
array $data = []
) {
$this->_quotesFactory = $quotesFactory;
$this->quoteItemCollectionFactory = $quoteItemCollectionFactory;
$this->queryResolver = $queryResolver;
parent::__construct($context, $backendHelper, $data);
}
Expand All @@ -56,7 +56,8 @@ protected function _construct()
*/
protected function _prepareCollection()
{
$collection = $this->_quotesFactory->create();
/** @var \Magento\Reports\Model\Resource\Quote\Item\Collection $collection */
$collection = $this->quoteItemCollectionFactory->create();
$collection->prepareActiveCartItems();
$this->setCollection($collection);
return parent::_prepareCollection();
Expand All @@ -68,11 +69,11 @@ protected function _prepareCollection()
protected function _prepareColumns()
{
$this->addColumn(
'entity_id',
'product_id',
[
'header' => __('ID'),
'align' => 'right',
'index' => 'entity_id',
'index' => 'product_id',
'sortable' => false,
'header_css_class' => 'col-id',
'column_css_class' => 'col-id'
Expand Down Expand Up @@ -146,6 +147,6 @@ protected function _prepareColumns()
*/
public function getRowUrl($row)
{
return $this->getUrl('catalog/product/edit', ['id' => $row->getEntityId()]);
return $this->getUrl('catalog/product/edit', ['id' => $row->getProductId()]);
}
}
4 changes: 2 additions & 2 deletions app/code/Magento/Reports/Model/Resource/Order/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -900,8 +900,8 @@ public function addCreateAtPeriodFilter($period)
$this->addFieldToFilter(
$fieldToFilter,
[
'from' => $from->format(\Magento\Framework\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT),
'to' => $to->format(\Magento\Framework\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT)
'from' => $from->format(\Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT),
'to' => $to->format(\Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT)
]
);

Expand Down
Loading

0 comments on commit 05b2964

Please sign in to comment.