@@ -42,6 +42,46 @@ public function testGetUrlInStore()
4242 $ this ->assertStringEndsWith ('simple-product.html ' , $ this ->_model ->getUrlInStore ($ product ));
4343 }
4444
45+ /**
46+ * @magentoDataFixture Magento/Store/_files/second_store.php
47+ * @magentoConfigFixture default_store web/unsecure/base_url http://sample.com/
48+ * @magentoConfigFixture default_store web/unsecure/base_link_url http://sample.com/
49+ * @magentoConfigFixture fixturestore_store web/unsecure/base_url http://sample-second.com/
50+ * @magentoConfigFixture fixturestore_store web/unsecure/base_link_url http://sample-second.com/
51+ * @magentoDataFixture Magento/Catalog/_files/product_simple_multistore.php
52+ * @dataProvider getUrlsWithSecondStoreProvider
53+ * @magentoAppArea adminhtml
54+ */
55+ public function testGetUrlInStoreWithSecondStore ($ storeCode , $ expectedProductUrl )
56+ {
57+ $ repository = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ()->create (
58+ \Magento \Catalog \Model \ProductRepository::class
59+ );
60+ /** @var \Magento\Store\Model\Store $store */
61+ $ store = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ()
62+ ->create (\Magento \Store \Model \Store::class);
63+ $ store ->load ($ storeCode , 'code ' );
64+ /** @var \Magento\Store\Model\Store $store */
65+
66+ $ product = $ repository ->get ('simple ' );
67+
68+ $ this ->assertEquals (
69+ $ expectedProductUrl ,
70+ $ this ->_model ->getUrlInStore ($ product , ['_scope ' => $ store ->getId (), '_nosid ' => true ])
71+ );
72+ }
73+
74+ /**
75+ * @return array
76+ */
77+ public function getUrlsWithSecondStoreProvider ()
78+ {
79+ return [
80+ 'case1 ' => ['fixturestore ' , 'http://sample-second.com/index.php/simple-product-one.html ' ],
81+ 'case2 ' => ['default ' , 'http://sample.com/index.php/simple-product-one.html ' ]
82+ ];
83+ }
84+
4585 public function testGetProductUrl ()
4686 {
4787 $ repository = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ()->create (
0 commit comments