From b06f148c1043d366bbf64d9c155beac69853661b Mon Sep 17 00:00:00 2001 From: andreaspenz Date: Wed, 21 Jan 2015 08:55:25 +0100 Subject: [PATCH 1/5] Allow camelcase in vendorname - changed regex in menu.xsd --- app/code/Magento/Backend/etc/menu.xsd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Backend/etc/menu.xsd b/app/code/Magento/Backend/etc/menu.xsd index 311bc95d85aaa..5ba2e6a84e93e 100644 --- a/app/code/Magento/Backend/etc/menu.xsd +++ b/app/code/Magento/Backend/etc/menu.xsd @@ -131,7 +131,7 @@ - + From 498f6cafae8b8ca470aaed69806db8b14450b29c Mon Sep 17 00:00:00 2001 From: andreaspenz Date: Wed, 21 Jan 2015 09:02:49 +0100 Subject: [PATCH 2/5] Allow camelcase in vendorname - fix files for unit-tests --- .../Config/_files/invalidMenuXmlArray.php | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/dev/tests/unit/testsuite/Magento/Backend/Model/Menu/Config/_files/invalidMenuXmlArray.php b/dev/tests/unit/testsuite/Magento/Backend/Model/Menu/Config/_files/invalidMenuXmlArray.php index 5ce31bbd979ee..a187bc629dcbb 100644 --- a/dev/tests/unit/testsuite/Magento/Backend/Model/Menu/Config/_files/invalidMenuXmlArray.php +++ b/dev/tests/unit/testsuite/Magento/Backend/Model/Menu/Config/_files/invalidMenuXmlArray.php @@ -209,7 +209,7 @@ 'resource="test_Value::value"/>', [ "Element 'add', attribute 'resource': [facet 'pattern'] The value 'test_Value::value' is not " . - "accepted by the pattern '[A-Z]+[a-z0-9]{1,}_[A-Z]+[A-Z0-9a-z]{1,}::[A-Za-z_0-9]{1,}'.", + "accepted by the pattern '[A-Z]+[A-Za-z0-9]{1,}_[A-Z]+[A-Z0-9a-z]{1,}::[A-Za-z_0-9]{1,}'.", "Element 'add', attribute 'resource': 'test_Value::value' is not a valid value of the atomic " . "type 'typeResource'." ], @@ -220,7 +220,7 @@ 'resource="Test_value::value"/>', [ "Element 'add', attribute 'resource': [facet 'pattern'] The value 'Test_value::value' is not " . - "accepted by the pattern '[A-Z]+[a-z0-9]{1,}_[A-Z]+[A-Z0-9a-z]{1,}::[A-Za-z_0-9]{1,}'.", + "accepted by the pattern '[A-Z]+[A-Za-z0-9]{1,}_[A-Z]+[A-Z0-9a-z]{1,}::[A-Za-z_0-9]{1,}'.", "Element 'add', attribute 'resource': 'Test_value::value' is not a valid value of the atomic " . "type 'typeResource'." ], @@ -231,7 +231,7 @@ 'resource="M#$%23_value::value"/>', [ "Element 'add', attribute 'resource': [facet 'pattern'] The value 'M#$%23_value::value' is not " . - "accepted by the pattern '[A-Z]+[a-z0-9]{1,}_[A-Z]+[A-Z0-9a-z]{1,}::[A-Za-z_0-9]{1,}'.", + "accepted by the pattern '[A-Z]+[A-Za-z0-9]{1,}_[A-Z]+[A-Z0-9a-z]{1,}::[A-Za-z_0-9]{1,}'.", "Element 'add', attribute 'resource': 'M#$%23_value::value' is not a valid value of the atomic " . "type 'typeResource'." ], @@ -242,7 +242,7 @@ 'resource="_value::value"/>', [ "Element 'add', attribute 'resource': [facet 'pattern'] The value '_value::value' is not accepted by " . - "the pattern '[A-Z]+[a-z0-9]{1,}_[A-Z]+[A-Z0-9a-z]{1,}::[A-Za-z_0-9]{1,}'.", + "the pattern '[A-Z]+[A-Za-z0-9]{1,}_[A-Z]+[A-Z0-9a-z]{1,}::[A-Za-z_0-9]{1,}'.", "Element 'add', attribute 'resource': '_value::value' is not a valid value of the atomic " . "type 'typeResource'." ], @@ -253,7 +253,7 @@ '', [ "Element 'add', attribute 'resource': [facet 'pattern'] The value 'Magento_::value' is not " . - "accepted by the pattern '[A-Z]+[a-z0-9]{1,}_[A-Z]+[A-Z0-9a-z]{1,}::[A-Za-z_0-9]{1,}'.", + "accepted by the pattern '[A-Z]+[A-Za-z0-9]{1,}_[A-Z]+[A-Z0-9a-z]{1,}::[A-Za-z_0-9]{1,}'.", "Element 'add', attribute 'resource': 'Magento_::value' is not a valid value of the atomic " . "type 'typeResource'." ], @@ -264,7 +264,7 @@ 'resource="Test_Value:value"/>', [ "Element 'add', attribute 'resource': [facet 'pattern'] The value 'Test_Value:value' is not " . - "accepted by the pattern '[A-Z]+[a-z0-9]{1,}_[A-Z]+[A-Z0-9a-z]{1,}::[A-Za-z_0-9]{1,}'.", + "accepted by the pattern '[A-Z]+[A-Za-z0-9]{1,}_[A-Z]+[A-Z0-9a-z]{1,}::[A-Za-z_0-9]{1,}'.", "Element 'add', attribute 'resource': 'Test_Value:value' is not a valid value of the atomic " . "type 'typeResource'." ], @@ -275,7 +275,7 @@ 'resource="Test_Value::"/>', [ "Element 'add', attribute 'resource': [facet 'pattern'] The value 'Test_Value::' is not " . - "accepted by the pattern '[A-Z]+[a-z0-9]{1,}_[A-Z]+[A-Z0-9a-z]{1,}::[A-Za-z_0-9]{1,}'.", + "accepted by the pattern '[A-Z]+[A-Za-z0-9]{1,}_[A-Z]+[A-Z0-9a-z]{1,}::[A-Za-z_0-9]{1,}'.", "Element 'add', attribute 'resource': 'Test_Value::' " . "is not a valid value of the atomic type 'typeResource'." ], @@ -608,7 +608,7 @@ 'resource="test_Value::value"/>', [ "Element 'update', attribute 'resource': [facet 'pattern'] The value 'test_Value::value' is not " . - "accepted by the pattern '[A-Z]+[a-z0-9]{1,}_[A-Z]+[A-Z0-9a-z]{1,}::[A-Za-z_0-9]{1,}'.", + "accepted by the pattern '[A-Z]+[A-Za-z0-9]{1,}_[A-Z]+[A-Z0-9a-z]{1,}::[A-Za-z_0-9]{1,}'.", "Element 'update', attribute 'resource': 'test_Value::value' is not a valid value of the atomic " . "type 'typeResource'." ], @@ -618,7 +618,7 @@ 'resource="Test_value::value"/>', [ "Element 'update', attribute 'resource': [facet 'pattern'] The value 'Test_value::value' is not " . - "accepted by the pattern '[A-Z]+[a-z0-9]{1,}_[A-Z]+[A-Z0-9a-z]{1,}::[A-Za-z_0-9]{1,}'.", + "accepted by the pattern '[A-Z]+[A-Za-z0-9]{1,}_[A-Z]+[A-Z0-9a-z]{1,}::[A-Za-z_0-9]{1,}'.", "Element 'update', attribute 'resource': 'Test_value::value' is not a valid value of the atomic " . "type 'typeResource'." ], @@ -628,7 +628,7 @@ 'resource="M#$%23_value::value"/>', [ "Element 'update', attribute 'resource': [facet 'pattern'] The value 'M#$%23_value::value' is not " . - "accepted by the pattern '[A-Z]+[a-z0-9]{1,}_[A-Z]+[A-Z0-9a-z]{1,}::[A-Za-z_0-9]{1,}'.", + "accepted by the pattern '[A-Z]+[A-Za-z0-9]{1,}_[A-Z]+[A-Z0-9a-z]{1,}::[A-Za-z_0-9]{1,}'.", "Element 'update', attribute 'resource': 'M#$%23_value::value' is not a valid value of the atomic " . "type 'typeResource'." ], @@ -638,7 +638,7 @@ 'resource="_value::value"/>', [ "Element 'update', attribute 'resource': [facet 'pattern'] The value '_value::value' is not " . - "accepted by the pattern '[A-Z]+[a-z0-9]{1,}_[A-Z]+[A-Z0-9a-z]{1,}::[A-Za-z_0-9]{1,}'.", + "accepted by the pattern '[A-Z]+[A-Za-z0-9]{1,}_[A-Z]+[A-Z0-9a-z]{1,}::[A-Za-z_0-9]{1,}'.", "Element 'update', attribute 'resource': '_value::value' is not a valid value of the atomic " . "type 'typeResource'." ], @@ -648,7 +648,7 @@ 'resource="Magento_::value"/>', [ "Element 'update', attribute 'resource': [facet 'pattern'] The value 'Magento_::value' is not " . - "accepted by the pattern '[A-Z]+[a-z0-9]{1,}_[A-Z]+[A-Z0-9a-z]{1,}::[A-Za-z_0-9]{1,}'.", + "accepted by the pattern '[A-Z]+[A-Za-z0-9]{1,}_[A-Z]+[A-Z0-9a-z]{1,}::[A-Za-z_0-9]{1,}'.", "Element 'update', attribute 'resource': 'Magento_::value' is not a valid value of the atomic " . "type 'typeResource'." ], @@ -658,7 +658,7 @@ 'resource="Test_Value:value"/>', [ "Element 'update', attribute 'resource': [facet 'pattern'] The value 'Test_Value:value' is not " . - "accepted by the pattern '[A-Z]+[a-z0-9]{1,}_[A-Z]+[A-Z0-9a-z]{1,}::[A-Za-z_0-9]{1,}'.", + "accepted by the pattern '[A-Z]+[A-Za-z0-9]{1,}_[A-Z]+[A-Z0-9a-z]{1,}::[A-Za-z_0-9]{1,}'.", "Element 'update', attribute 'resource': 'Test_Value:value' is not a valid value of the atomic " . "type 'typeResource'." ], @@ -668,7 +668,7 @@ 'resource="Test_Value::"/>', [ "Element 'update', attribute 'resource': [facet 'pattern'] The value 'Test_Value::' is not " . - "accepted by the pattern '[A-Z]+[a-z0-9]{1,}_[A-Z]+[A-Z0-9a-z]{1,}::[A-Za-z_0-9]{1,}'.", + "accepted by the pattern '[A-Z]+[A-Za-z0-9]{1,}_[A-Z]+[A-Z0-9a-z]{1,}::[A-Za-z_0-9]{1,}'.", "Element 'update', attribute 'resource': 'Test_Value::' is not a valid value of the atomic " . "type 'typeResource'." ], From 59c1d9d519374ba65834afdb27d00d7980e77c5e Mon Sep 17 00:00:00 2001 From: slirx Date: Sat, 7 Feb 2015 00:58:34 +0200 Subject: [PATCH 3/5] Fix: wrong parameter for getting base url for 'media' path in "Image" form element. --- lib/internal/Magento/Framework/Data/Form/Element/Image.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/Magento/Framework/Data/Form/Element/Image.php b/lib/internal/Magento/Framework/Data/Form/Element/Image.php index c4d143c05db84..9c3577813ca0d 100644 --- a/lib/internal/Magento/Framework/Data/Form/Element/Image.php +++ b/lib/internal/Magento/Framework/Data/Form/Element/Image.php @@ -50,7 +50,7 @@ public function getElementHtml() $url = $this->_getUrl(); if (!preg_match("/^http\:\/\/|https\:\/\//", $url)) { - $url = $this->_urlBuilder->getBaseUrl('media') . $url; + $url = $this->_urlBuilder->getBaseUrl(['_type' => \Magento\Framework\UrlInterface::URL_TYPE_MEDIA]) . $url; } $html = ' - + From 360364f3e950fe628d089a7c352ff9a2294e0f9e Mon Sep 17 00:00:00 2001 From: Christopher O'Toole Date: Sat, 7 Feb 2015 14:23:59 -0600 Subject: [PATCH 5/5] MAGETWO-33727: Wrong parameter for getting base url for 'media' path in "Image" form element. #1025 - Import UrlInterface to short line to under 120 characters - Add integration test to catch regression - Modify unit test to catch regression --- .../Framework/Data/Form/Element/ImageTest.php | 36 +++++++++++++++++++ .../Framework/Data/Form/Element/ImageTest.php | 17 +++++++-- .../Framework/Data/Form/Element/Image.php | 10 +++--- 3 files changed, 56 insertions(+), 7 deletions(-) create mode 100644 dev/tests/integration/testsuite/Magento/Framework/Data/Form/Element/ImageTest.php diff --git a/dev/tests/integration/testsuite/Magento/Framework/Data/Form/Element/ImageTest.php b/dev/tests/integration/testsuite/Magento/Framework/Data/Form/Element/ImageTest.php new file mode 100644 index 0000000000000..885210800ed13 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Framework/Data/Form/Element/ImageTest.php @@ -0,0 +1,36 @@ +create('Magento\Framework\Data\Form\ElementFactory'); + $this->imageElement = $elementFactory->create('Magento\Framework\Data\Form\Element\Image', []); + $form = $objectManager->create('Magento\Framework\Data\Form'); + $this->imageElement->setForm($form); + } + + public function testGetElementHtml() + { + $filePath = 'some/path/to/file.jpg'; + $this->imageElement->setValue($filePath); + $html = $this->imageElement->getElementHtml(); + + $this->assertContains('media/' . $filePath, $html); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Data/Form/Element/ImageTest.php b/dev/tests/unit/testsuite/Magento/Framework/Data/Form/Element/ImageTest.php index a48451fca5acd..aae483343d502 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Data/Form/Element/ImageTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/Data/Form/Element/ImageTest.php @@ -9,6 +9,8 @@ */ namespace Magento\Framework\Data\Form\Element; +use Magento\Framework\UrlInterface; + class ImageTest extends \PHPUnit_Framework_TestCase { /** @@ -16,6 +18,11 @@ class ImageTest extends \PHPUnit_Framework_TestCase */ protected $_objectManagerMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $urlBuilder; + /** * @var \Magento\Framework\Data\Form\Element\Image */ @@ -32,12 +39,12 @@ protected function setUp() false ); $escaperMock = $this->getMock('\Magento\Framework\Escaper', [], [], '', false); - $urlBuilderMock = $this->getMock('\Magento\Framework\Url', [], [], '', false); + $this->urlBuilder = $this->getMock('\Magento\Framework\Url', [], [], '', false); $this->_image = new \Magento\Framework\Data\Form\Element\Image( $factoryMock, $collectionFactoryMock, $escaperMock, - $urlBuilderMock + $this->urlBuilder ); $formMock = new \Magento\Framework\Object(); $formMock->getHtmlIdPrefix('id_prefix'); @@ -81,12 +88,16 @@ public function testGetElementHtmlWithoutValue() public function testGetElementHtmlWithValue() { $this->_image->setValue('test_value'); + $this->urlBuilder->expects($this->once()) + ->method('getBaseUrl') + ->with(['_type' => UrlInterface::URL_TYPE_MEDIA]) + ->willReturn('http://localhost/media/'); $html = $this->_image->getElementHtml(); $this->assertContains('class="input-file"', $html); $this->assertContains('assertContains('type="file"', $html); $this->assertContains('value="test_value"', $html); - $this->assertContains('assertContains('assertContains('_urlBuilder = $urlBuilder; @@ -50,7 +52,7 @@ public function getElementHtml() $url = $this->_getUrl(); if (!preg_match("/^http\:\/\/|https\:\/\//", $url)) { - $url = $this->_urlBuilder->getBaseUrl(['_type' => \Magento\Framework\UrlInterface::URL_TYPE_MEDIA]) . $url; + $url = $this->_urlBuilder->getBaseUrl(['_type' => UrlInterface::URL_TYPE_MEDIA]) . $url; } $html = '