10
10
use Magento \Store \Api \StoreRepositoryInterface ;
11
11
use Magento \Store \Model \StoreManagerInterface ;
12
12
use Magento \Framework \Event \ManagerInterface ;
13
+ use Magento \Sales \Model \ResourceModel \Order \CollectionFactory as OrderCollectionFactory ;
13
14
15
+ /**
16
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
17
+ */
14
18
class OrderTest extends \PHPUnit \Framework \TestCase
15
19
{
16
20
/**
@@ -59,10 +63,10 @@ protected function tearDown()
59
63
$ registry ->unregister ('isSecureArea ' );
60
64
$ registry ->register ('isSecureArea ' , true );
61
65
62
- /** @var \Magento\Sales\Model\Order $order */
63
- $ order = $ this -> objectManager -> create (\ Magento \ Sales \ Model \Order::class);
64
- $ order ->loadByIncrementId ( $ this -> orderIncrementId );
65
- $ order -> delete ();
66
+ $ orderCollection = $ this -> objectManager -> create (OrderCollectionFactory::class)-> create ();
67
+ foreach ( $ orderCollection as $ order ) {
68
+ $ order ->delete ( );
69
+ }
66
70
67
71
$ registry ->unregister ('isSecureArea ' );
68
72
$ registry ->register ('isSecureArea ' , false );
@@ -140,11 +144,11 @@ public function testSaveOrder()
140
144
* Check that store name with length within 255 chars can be saved in table sales_order
141
145
*
142
146
* @magentoDataFixture Magento/Store/_files/store_with_long_name.php
147
+ * @magentoDbIsolation disabled
143
148
* @return void
144
149
*/
145
150
public function testSaveStoreName ()
146
151
{
147
- $ storeName = str_repeat ('a ' , 220 );
148
152
$ store = $ this ->storeRepository ->get ('test_2 ' );
149
153
$ this ->storeManager ->setCurrentStore ($ store ->getId ());
150
154
$ eventManager = $ this ->objectManager ->get (ManagerInterface::class);
@@ -154,13 +158,10 @@ public function testSaveStoreName()
154
158
$ payment ->setMethod ('checkmo ' );
155
159
$ order ->setStoreId ($ store ->getId ())->setPayment ($ payment );
156
160
$ this ->resourceModel ->save ($ order );
157
- $ this ->resourceModel ->load ($ order , $ storeName , 'store_name ' );
158
- $ name = [
159
- 'Main Website ' ,
160
- 'Main Website Store ' ,
161
- $ storeName ,
162
- ];
163
- $ expectedStoreName = implode (PHP_EOL , $ name );
164
- $ this ->assertEquals ($ expectedStoreName , $ order ->getStoreName ());
161
+ $ orderRepository = $ this ->objectManager ->create (\Magento \Sales \Api \OrderRepositoryInterface::class);
162
+ $ order = $ orderRepository ->get ($ order ->getId ());
163
+ $ this ->assertEquals (255 , strlen ($ order ->getStoreName ()));
164
+ $ this ->assertContains ($ store ->getWebsite ()->getName (), $ order ->getStoreName ());
165
+ $ this ->assertContains ($ store ->getGroup ()->getName (), $ order ->getStoreName ());
165
166
}
166
167
}
0 commit comments