Skip to content

Commit 04890dd

Browse files
author
Mike Weis
committed
Merge branch 'develop' into FearlessKiwis-MAGETWO-28251-Catalog-Additional-Methods-2
2 parents 7e9af16 + 9ae0a13 commit 04890dd

File tree

12 files changed

+149
-52
lines changed

12 files changed

+149
-52
lines changed

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Use the following table to verify you have the correct prerequisites to install
2727
</tr>
2828
<tr>
2929
<td>Apache 2.2 or 2.4</td>
30-
<td>Ubuntu: <code>apache -v</code><br>
30+
<td>Ubuntu: <code>apache2 -v</code><br>
3131
CentOS: <code>httpd -v</code></td>
3232
<td><a href="http://devdocs.magento.com/guides/v1.0/install-gde/prereq/apache.html">Apache</a></td>
3333
</tr>
@@ -57,3 +57,17 @@ After verifying your prerequisites, perform the following tasks in order to prep
5757
* <a href="http://devdocs.magento.com/guides/v1.0/install-gde/install/install-web.html">Install Magento software using the web interface</a>
5858
* <a href="http://devdocs.magento.com/guides/v1.0/install-gde/install/install-cli.html">Install Magento software using the command line</a>
5959
2. <a href="http://devdocs.magento.com/guides/v1.0/install-gde/install/verify.html">Verify the installation</a>
60+
61+
<h2>Contributing to the Magento 2 code base</h2>
62+
Contributions can take the form of new components or features, changes to existing features, tests, documentation (such as developer guides, user guides, examples, or specifications), bug fixes, optimizations, or just good suggestions.
63+
64+
To make learn about how to make a contribution, click [here][1].
65+
66+
To learn about issues, click [here][2]. To open an issue, click [here][3].
67+
68+
To suggest documentation improvements, click [here][4].
69+
70+
[1]: <http://devdocs.magento.com/guides/v1.0/contributor-guide/CONTRIBUTING.html>
71+
[2]: <http://devdocs.magento.com/guides/v1.0/contributor-guide/CONTRIBUTING.html#report>
72+
[3]: <https://github.com/magento/magento2/issues>
73+
[4]: <http://devdocs.magento.com>

app/code/Magento/MediaStorage/Model/File/Storage/Response.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,17 @@ class Response extends Http implements \Magento\Framework\App\Response\FileInter
2929
* @param CookieManagerInterface $cookieManager
3030
* @param CookieMetadataFactory $cookieMetadataFactory
3131
* @param \Magento\Framework\App\Http\Context $context
32+
* @param \Magento\Framework\Stdlib\DateTime $dateTime
3233
* @param \Magento\Framework\File\Transfer\Adapter\Http $transferAdapter
3334
*/
3435
public function __construct(
3536
CookieManagerInterface $cookieManager,
3637
CookieMetadataFactory $cookieMetadataFactory,
3738
\Magento\Framework\App\Http\Context $context,
39+
\Magento\Framework\Stdlib\DateTime $dateTime,
3840
\Magento\Framework\File\Transfer\Adapter\Http $transferAdapter
3941
) {
40-
parent::__construct($cookieManager, $cookieMetadataFactory, $context);
42+
parent::__construct($cookieManager, $cookieMetadataFactory, $context, $dateTime);
4143
$this->_transferAdapter = $transferAdapter;
4244
}
4345

app/code/Magento/Quote/Model/Quote.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1538,8 +1538,8 @@ public function addProduct(
15381538
/**
15391539
* Error message
15401540
*/
1541-
if (is_string($cartCandidates)) {
1542-
return $cartCandidates;
1541+
if (is_string($cartCandidates) || $cartCandidates instanceof \Magento\Framework\Phrase) {
1542+
return strval($cartCandidates);
15431543
}
15441544

15451545
/**

app/code/Magento/Sales/view/adminhtml/web/order/create/scripts.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,7 @@ AdminOrder.prototype = {
668668
if (confirm(confirmMessage)) {
669669
this.collectElementsValue = false;
670670
order.sidebarApplyChanges({'sidebar[empty_customer_cart]': 1});
671+
this.collectElementsValue = true;
671672
}
672673
},
673674

dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/TestCase/ControllerAbstractTest.php

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,11 @@ class ControllerAbstractTest extends \Magento\TestFramework\TestCase\AbstractCon
1717

1818
protected function setUp()
1919
{
20-
$this->messageManager = $this->getMock('\Magento\Framework\Message\Manager', [], [], '', false);
21-
$request = new \Magento\TestFramework\Request(
22-
$this->getMock('Magento\Framework\Stdlib\Cookie\CookieReaderInterface'),
23-
$this->getMock('Magento\Framework\App\Route\ConfigInterface\Proxy', [], [], '', false),
24-
$this->getMock('Magento\Framework\App\Request\PathInfoProcessorInterface'),
25-
$this->getMock('Magento\Framework\ObjectManagerInterface')
26-
);
27-
$response = new \Magento\TestFramework\Response(
28-
$this->getMock('Magento\Framework\Stdlib\CookieManagerInterface'),
29-
$this->getMock('Magento\Framework\Stdlib\Cookie\CookieMetadataFactory', [], [], '', false),
30-
$this->getMock('Magento\Framework\App\Http\Context', [], [], '', false)
31-
);
20+
$testObjectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
3221

22+
$this->messageManager = $this->getMock('\Magento\Framework\Message\Manager', [], [], '', false);
23+
$request = $testObjectManager->getObject('Magento\TestFramework\Request');
24+
$response = $testObjectManager->getObject('Magento\TestFramework\Response');
3325
$this->_objectManager = $this->getMock(
3426
'Magento\TestFramework\ObjectManager',
3527
['get', 'create'],

dev/tests/integration/testsuite/Magento/Reports/Model/Resource/Report/Product/Viewed/CollectionTest.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,6 @@ public function tableForPeriodDataProvider()
119119
'date_from' => $dateYearAgo,
120120
'date_to' => null,
121121
],
122-
[
123-
'period' => 'month',
124-
'table' => 'report_viewed_product_aggregated_yearly',
125-
'date_from' => null,
126-
'date_to' => $dateNow,
127-
],
128122
[
129123
'period' => 'year',
130124
'table' => 'report_viewed_product_aggregated_yearly',

lib/internal/Magento/Framework/App/Response/Http.php

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,42 +11,44 @@
1111
use Magento\Framework\App\ObjectManager;
1212
use Magento\Framework\Stdlib\Cookie\CookieMetadataFactory;
1313
use Magento\Framework\Stdlib\CookieManagerInterface;
14+
use Magento\Framework\Stdlib\DateTime;
1415

1516
class Http extends \Magento\Framework\HTTP\PhpEnvironment\Response
1617
{
17-
/**
18-
* Cookie to store page vary string
19-
*/
18+
/** Cookie to store page vary string */
2019
const COOKIE_VARY_STRING = 'X-Magento-Vary';
2120

22-
/**
23-
* @var \Magento\Framework\Stdlib\CookieManagerInterface
24-
*/
21+
/** Format for expiration timestamp headers */
22+
const EXPIRATION_TIMESTAMP_FORMAT = 'D, d M Y H:i:s T';
23+
24+
/** @var \Magento\Framework\Stdlib\CookieManagerInterface */
2525
protected $cookieManager;
2626

27-
/**
28-
* @var \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory
29-
*/
27+
/** @var \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory */
3028
protected $cookieMetadataFactory;
3129

32-
/**
33-
* @var \Magento\Framework\App\Http\Context
34-
*/
30+
/** @var \Magento\Framework\App\Http\Context */
3531
protected $context;
3632

33+
/** @var DateTime */
34+
protected $dateTime;
35+
3736
/**
3837
* @param CookieManagerInterface $cookieManager
3938
* @param CookieMetadataFactory $cookieMetadataFactory
4039
* @param Context $context
40+
* @param DateTime $dateTime
4141
*/
4242
public function __construct(
4343
CookieManagerInterface $cookieManager,
4444
CookieMetadataFactory $cookieMetadataFactory,
45-
Context $context
45+
Context $context,
46+
DateTime $dateTime
4647
) {
4748
$this->cookieManager = $cookieManager;
4849
$this->cookieMetadataFactory = $cookieMetadataFactory;
4950
$this->context = $context;
51+
$this->dateTime = $dateTime;
5052
}
5153

5254
/**
@@ -97,7 +99,7 @@ public function setPublicHeaders($ttl)
9799
}
98100
$this->setHeader('pragma', 'cache', true);
99101
$this->setHeader('cache-control', 'public, max-age=' . $ttl . ', s-maxage=' . $ttl, true);
100-
$this->setHeader('expires', gmdate('D, d M Y H:i:s T', strtotime('+' . $ttl . ' seconds')), true);
102+
$this->setHeader('expires', $this->getExpirationHeader('+' . $ttl . ' seconds'), true);
101103
}
102104

103105
/**
@@ -114,7 +116,7 @@ public function setPrivateHeaders($ttl)
114116
}
115117
$this->setHeader('pragma', 'cache', true);
116118
$this->setHeader('cache-control', 'private, max-age=' . $ttl, true);
117-
$this->setHeader('expires', gmdate('D, d M Y H:i:s T', strtotime('+' . $ttl . ' seconds')), true);
119+
$this->setHeader('expires', $this->getExpirationHeader('+' . $ttl . ' seconds'), true);
118120
}
119121

120122
/**
@@ -126,7 +128,7 @@ public function setNoCacheHeaders()
126128
{
127129
$this->setHeader('pragma', 'no-cache', true);
128130
$this->setHeader('cache-control', 'no-store, no-cache, must-revalidate, max-age=0', true);
129-
$this->setHeader('expires', gmdate('D, d M Y H:i:s T', strtotime('-1 year')), true);
131+
$this->setHeader('expires', $this->getExpirationHeader('-1 year'), true);
130132
}
131133

132134
/**
@@ -160,4 +162,15 @@ public function __wakeup()
160162
$this->cookieManager = $objectManager->create('Magento\Framework\Stdlib\CookieManagerInterface');
161163
$this->cookieMetadataFactory = $objectManager->get('Magento\Framework\Stdlib\Cookie\CookieMetadataFactory');
162164
}
165+
166+
/**
167+
* Given a time input, returns the formatted header
168+
*
169+
* @param string $time
170+
* @return string
171+
*/
172+
protected function getExpirationHeader($time)
173+
{
174+
return $this->dateTime->gmDate(self::EXPIRATION_TIMESTAMP_FORMAT, $this->dateTime->strToTime($time));
175+
}
163176
}

lib/internal/Magento/Framework/App/Test/Unit/Response/HttpTest.php

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
class HttpTest extends \PHPUnit_Framework_TestCase
1414
{
1515
/**
16-
* @var \Magento\Framework\App\Response\Http
16+
* @var Http
1717
*/
1818
protected $model;
1919

@@ -32,6 +32,9 @@ class HttpTest extends \PHPUnit_Framework_TestCase
3232
*/
3333
protected $contextMock;
3434

35+
/** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\App\Http\Context */
36+
protected $dateTimeMock;
37+
3538
protected function setUp()
3639
{
3740
$objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
@@ -41,12 +44,18 @@ protected function setUp()
4144
$this->cookieManagerMock = $this->getMock('Magento\Framework\Stdlib\CookieManagerInterface');
4245
$this->contextMock = $this->getMockBuilder('Magento\Framework\App\Http\Context')->disableOriginalConstructor()
4346
->getMock();
47+
48+
$this->dateTimeMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime')
49+
->disableOriginalConstructor()
50+
->getMock();
51+
4452
$this->model = $objectManager->getObject(
4553
'Magento\Framework\App\Response\Http',
4654
[
4755
'cookieManager' => $this->cookieManagerMock,
4856
'cookieMetadataFactory' => $this->cookieMetadataFactoryMock,
49-
'context' => $this->contextMock
57+
'context' => $this->contextMock,
58+
'dateTime' => $this->dateTimeMock
5059
]
5160
);
5261
$this->model->headersSentThrowsException = false;
@@ -118,14 +127,24 @@ public function testSendVaryEmptyData()
118127
public function testSetPublicHeaders()
119128
{
120129
$ttl = 120;
130+
$timestamp = 1000000;
121131
$pragma = 'cache';
122132
$cacheControl = 'max-age=' . $ttl . ', public, s-maxage=' . $ttl;
123-
$expiresResult = gmdate('D, d M Y H:i:s T', time() + $ttl);
133+
$expiresResult ='Thu, 01 Jan 1970 00:00:00 GMT';
134+
135+
$this->dateTimeMock->expects($this->once())
136+
->method('strToTime')
137+
->with('+' . $ttl . ' seconds')
138+
->willReturn($timestamp);
139+
$this->dateTimeMock->expects($this->once())
140+
->method('gmDate')
141+
->with(Http::EXPIRATION_TIMESTAMP_FORMAT, $timestamp)
142+
->willReturn($expiresResult);
124143

125144
$this->model->setPublicHeaders($ttl);
126145
$this->assertEquals($pragma, $this->model->getHeader('Pragma')->getFieldValue());
127146
$this->assertEquals($cacheControl, $this->model->getHeader('Cache-Control')->getFieldValue());
128-
$this->assertLessThanOrEqual($expiresResult, $this->model->getHeader('Expires')->getFieldValue());
147+
$this->assertSame($expiresResult, $this->model->getHeader('Expires')->getFieldValue());
129148
}
130149

131150
/**
@@ -146,14 +165,24 @@ public function testSetPublicHeadersWithoutTtl()
146165
public function testSetPrivateHeaders()
147166
{
148167
$ttl = 120;
168+
$timestamp = 1000000;
149169
$pragma = 'cache';
150170
$cacheControl = 'max-age=' . $ttl . ', private';
151-
$expires = gmdate('D, d M Y H:i:s T', strtotime('+' . $ttl . ' seconds'));
171+
$expiresResult ='Thu, 01 Jan 1970 00:00:00 GMT';
172+
173+
$this->dateTimeMock->expects($this->once())
174+
->method('strToTime')
175+
->with('+' . $ttl . ' seconds')
176+
->willReturn($timestamp);
177+
$this->dateTimeMock->expects($this->once())
178+
->method('gmDate')
179+
->with(Http::EXPIRATION_TIMESTAMP_FORMAT, $timestamp)
180+
->willReturn($expiresResult);
152181

153182
$this->model->setPrivateHeaders($ttl);
154183
$this->assertEquals($pragma, $this->model->getHeader('Pragma')->getFieldValue());
155184
$this->assertEquals($cacheControl, $this->model->getHeader('Cache-Control')->getFieldValue());
156-
$this->assertEquals($expires, $this->model->getHeader('Expires')->getFieldValue());
185+
$this->assertEquals($expiresResult, $this->model->getHeader('Expires')->getFieldValue());
157186
}
158187

159188
/**
@@ -173,14 +202,24 @@ public function testSetPrivateHeadersWithoutTtl()
173202
*/
174203
public function testSetNoCacheHeaders()
175204
{
205+
$timestamp = 1000000;
176206
$pragma = 'no-cache';
177207
$cacheControl = 'max-age=0, must-revalidate, no-cache, no-store';
178-
$expires = gmdate('D, d M Y H:i:s T', strtotime('-1 year'));
208+
$expiresResult ='Thu, 01 Jan 1970 00:00:00 GMT';
209+
210+
$this->dateTimeMock->expects($this->once())
211+
->method('strToTime')
212+
->with('-1 year')
213+
->willReturn($timestamp);
214+
$this->dateTimeMock->expects($this->once())
215+
->method('gmDate')
216+
->with(Http::EXPIRATION_TIMESTAMP_FORMAT, $timestamp)
217+
->willReturn($expiresResult);
179218

180219
$this->model->setNoCacheHeaders();
181220
$this->assertEquals($pragma, $this->model->getHeader('Pragma')->getFieldValue());
182221
$this->assertEquals($cacheControl, $this->model->getHeader('Cache-Control')->getFieldValue());
183-
$this->assertEquals($expires, $this->model->getHeader('Expires')->getFieldValue());
222+
$this->assertEquals($expiresResult, $this->model->getHeader('Expires')->getFieldValue());
184223
}
185224

186225
/**

lib/internal/Magento/Framework/App/Test/Unit/View/Deployment/VersionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
use \Magento\Framework\App\View\Deployment\Version;
1010

11-
1211
class VersionTest extends \PHPUnit_Framework_TestCase
1312
{
1413
/**
@@ -71,6 +70,7 @@ public function getValueFromStorageDataProvider()
7170

7271
public function testGetValueDefaultModeSaving()
7372
{
73+
$this->markTestSkipped('MAGETWO-35794');
7474
$this->appState
7575
->expects($this->once())
7676
->method('getMode')

lib/internal/Magento/Framework/Data/Form/Element/Textarea.php

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@
1515

1616
class Textarea extends AbstractElement
1717
{
18+
/**
19+
* Default number of rows
20+
*/
21+
const DEFAULT_ROWS = 2;
22+
23+
/**
24+
* Default number of columns
25+
*/
26+
const DEFAULT_COLS = 15;
27+
1828
/**
1929
* @param Factory $factoryElement
2030
* @param CollectionFactory $factoryCollection
@@ -30,8 +40,12 @@ public function __construct(
3040
parent::__construct($factoryElement, $factoryCollection, $escaper, $data);
3141
$this->setType('textarea');
3242
$this->setExtType('textarea');
33-
$this->setRows(2);
34-
$this->setCols(15);
43+
if (!$this->getRows()) {
44+
$this->setRows(self::DEFAULT_ROWS);
45+
}
46+
if (!$this->getCols()) {
47+
$this->setCols(self::DEFAULT_COLS);
48+
}
3549
}
3650

3751
/**
@@ -65,9 +79,8 @@ public function getHtmlAttributes()
6579
public function getElementHtml()
6680
{
6781
$this->addClass('textarea');
68-
$html = '<textarea id="' . $this->getHtmlId() . '" name="' . $this->getName() . '" ' . $this->serialize(
69-
$this->getHtmlAttributes()
70-
) . $this->_getUiId() . ' >';
82+
$html = '<textarea id="' . $this->getHtmlId() . '" name="' . $this->getName() . '" '
83+
. $this->serialize($this->getHtmlAttributes()) . $this->_getUiId() . ' >';
7184
$html .= $this->getEscapedValue();
7285
$html .= "</textarea>";
7386
$html .= $this->getAfterElementHtml();

0 commit comments

Comments
 (0)