Skip to content

Commit 9b026f0

Browse files
committed
Merge remote-tracking branch 'ogresCE/MAGETWO-48217-public-prs' into PR_Branch
2 parents e4777db + 5277358 commit 9b026f0

File tree

6 files changed

+89
-36
lines changed

6 files changed

+89
-36
lines changed

app/code/Magento/PageCache/Block/System/Config/Form/Field/Export.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,10 @@ protected function _getElementHtml(\Magento\Framework\Data\Form\Element\Abstract
2727
'varnish' => $this->getVarnishVersion()
2828
];
2929

30-
$url = $this->getUrl("*/PageCache/exportVarnishConfig", $params);
3130
$data = [
3231
'id' => 'system_full_page_cache_varnish_export_button_version' . $this->getVarnishVersion(),
33-
'label' => __('Export VCL for Varnish ') . $this->getVarnishVersion(),
34-
'onclick' => "setLocation('" . $url . "')",
32+
'label' => $this->_getLabel(),
33+
'onclick' => "setLocation('" . $this->_getUrl($params) . "')",
3534
];
3635

3736
$html = $buttonBlock->setData($data)->toHtml();
@@ -49,13 +48,20 @@ public function getVarnishVersion()
4948
}
5049

5150
/**
52-
* Return PageCache TTL value from config
53-
* to avoid saving empty field
51+
* @return \Magento\Framework\Phrase
52+
*/
53+
protected function _getLabel()
54+
{
55+
return __('Export VCL for Varnish %1', $this->getVarnishVersion());
56+
}
57+
58+
/**
59+
* @param array $params
5460
*
5561
* @return string
5662
*/
57-
public function getTtlValue()
63+
protected function _getUrl($params = [])
5864
{
59-
return $this->_scopeConfig->getValue(\Magento\PageCache\Model\Config::XML_PAGECACHE_TTL);
65+
return $this->getUrl('*/PageCache/exportVarnishConfig', $params);
6066
}
6167
}

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

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -347,37 +347,22 @@ public function getElementHtml()
347347
$html = '';
348348
$htmlId = $this->getHtmlId();
349349

350-
if (($beforeElementHtml = $this->getBeforeElementHtml())) {
351-
$html .= '<label class="addbefore" for="' .
352-
$htmlId .
353-
'">' .
354-
$beforeElementHtml .
355-
'</label>';
350+
$beforeElementHtml = $this->getBeforeElementHtml();
351+
if ($beforeElementHtml) {
352+
$html .= '<label class="addbefore" for="' . $htmlId . '">' . $beforeElementHtml . '</label>';
356353
}
357354

358-
$html .= '<input id="' .
359-
$htmlId .
360-
'" name="' .
361-
$this->getName() .
362-
'" ' .
363-
$this->_getUiId() .
364-
' value="' .
365-
$this->getEscapedValue() .
366-
'" ' .
367-
$this->serialize(
368-
$this->getHtmlAttributes()
369-
) . '/>';
370-
371-
if (($afterElementJs = $this->getAfterElementJs())) {
355+
$html .= '<input id="' . $htmlId . '" name="' . $this->getName() . '" ' . $this->_getUiId() . ' value="' .
356+
$this->getEscapedValue() . '" ' . $this->serialize($this->getHtmlAttributes()) . '/>';
357+
358+
$afterElementJs = $this->getAfterElementJs();
359+
if ($afterElementJs) {
372360
$html .= $afterElementJs;
373361
}
374362

375-
if (($afterElementHtml = $this->getAfterElementHtml())) {
376-
$html .= '<label class="addafter" for="' .
377-
$htmlId .
378-
'">' .
379-
$afterElementHtml .
380-
'</label>';
363+
$afterElementHtml = $this->getAfterElementHtml();
364+
if ($afterElementHtml) {
365+
$html .= '<label class="addafter" for="' . $htmlId . '">' . $afterElementHtml . '</label>';
381366
}
382367

383368
return $html;
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Framework\Filesystem\Test\Unit\Driver;
8+
9+
use Magento\Framework\Filesystem\Driver\File;
10+
11+
class FileTest extends \PHPUnit_Framework_TestCase
12+
{
13+
/** @var string Result of file_get_contents() function */
14+
public static $fileGetContents;
15+
16+
/** @var bool Result of file_put_contents() function */
17+
public static $filePutContents;
18+
19+
public function setUp()
20+
{
21+
self::$fileGetContents = '';
22+
self::$filePutContents = true;
23+
}
24+
25+
/**
26+
* @dataProvider dataProviderForTestGetAbsolutePath
27+
*/
28+
public function testGetAbsolutePath($basePath, $path, $expected)
29+
{
30+
$file = new File();
31+
$this->assertEquals($expected, $file->getAbsolutePath($basePath, $path));
32+
}
33+
34+
public function dataProviderForTestGetAbsolutePath()
35+
{
36+
return [
37+
['/root/path/', 'sub', '/root/path/sub'],
38+
['/root/path/', '/sub', '/root/path/sub'],
39+
['/root/path/', '../sub', '/root/path/../sub'],
40+
['/root/path/', '/root/path/sub', '/root/path/root/path/sub'],
41+
];
42+
}
43+
44+
/**
45+
* @dataProvider dataProviderForTestGetRelativePath
46+
*/
47+
public function testGetRelativePath($basePath, $path, $expected)
48+
{
49+
$file = new File();
50+
$this->assertEquals($expected, $file->getRelativePath($basePath, $path));
51+
}
52+
53+
public function dataProviderForTestGetRelativePath()
54+
{
55+
return [
56+
['/root/path/', 'sub', 'sub'],
57+
['/root/path/', '/sub', '/sub'],
58+
['/root/path/', '/root/path/sub', 'sub'],
59+
['/root/path/sub', '/root/path/other', '/root/path/other'],
60+
];
61+
}
62+
}

pub/errors/processorFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66
namespace Magento\Framework\Error;
77

8-
require_once __DIR__ . '/../../app/bootstrap.php';
8+
require_once realpath(__DIR__) . '/../../app/bootstrap.php';
99
require_once 'processor.php';
1010

1111
/**

pub/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Magento\Framework\App\Filesystem\DirectoryList;
1111

1212
try {
13-
require __DIR__ . '/../app/bootstrap.php';
13+
require realpath(__DIR__) . '/../app/bootstrap.php';
1414
} catch (\Exception $e) {
1515
echo <<<HTML
1616
<div style="font:12px/1.35em arial, helvetica, sans-serif;">

pub/static.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* See COPYING.txt for license details.
77
*/
88

9-
require __DIR__ . '/../app/bootstrap.php';
9+
require realpath(__DIR__) . '/../app/bootstrap.php';
1010
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);
1111
/** @var \Magento\Framework\App\StaticResource $app */
1212
$app = $bootstrap->createApplication('Magento\Framework\App\StaticResource');

0 commit comments

Comments
 (0)