55use Commercetools \Core \Builder \Request \RequestBuilder ;
66use Commercetools \Core \IntegrationTests \ApiTestCase ;
77use Commercetools \Core \IntegrationTests \Channel \ChannelFixture ;
8+ use Commercetools \Core \IntegrationTests \Product \ProductFixture ;
89use Commercetools \Core \IntegrationTests \ProductSelection \ProductSelectionFixture ;
910use Commercetools \Core \Model \Channel \Channel ;
1011use Commercetools \Core \Model \Channel \ChannelDraft ;
1112use Commercetools \Core \Model \Channel \ChannelReference ;
1213use Commercetools \Core \Model \Channel \ChannelRole ;
1314use Commercetools \Core \Model \Common \LocalizedString ;
15+ use Commercetools \Core \Model \Product \Product ;
16+ use Commercetools \Core \Model \Product \ProductReference ;
1417use Commercetools \Core \Model \ProductSelection \ProductSelection ;
15- use Commercetools \Core \Model \ProductSelection \ProductSelectionDraft ;
1618use Commercetools \Core \Model \ProductSelection \ProductSelectionReference ;
17- use Commercetools \Core \Model \ProductSelection \ProductSelectionType ;
18- use Commercetools \Core \Model \Store \ProductSelectionSettingDraft ;
19+ use Commercetools \Core \Model \Store \ProductSelectionSetting ;
1920use Commercetools \Core \Model \Store \Store ;
2021use Commercetools \Core \Model \Store \StoreDraft ;
22+ use Commercetools \Core \Request \ProductSelections \Command \ProductSelectionAddProductAction ;
23+ use Commercetools \Core \Request \ProductSelections \Command \ProductSelectionRemoveProductAction ;
2124use Commercetools \Core \Request \Stores \Command \StoreAddDistributionChannelAction ;
2225use Commercetools \Core \Request \Stores \Command \StoreAddProductSelectionAction ;
2326use Commercetools \Core \Request \Stores \Command \StoreAddSupplyChannelAction ;
@@ -351,8 +354,8 @@ function (ProductSelection $productSelection) use ($client) {
351354 $ client ,
352355 function (Store $ store ) use ($ client , $ productSelection ) {
353356 $ productSelectionReference = ProductSelectionReference::ofId ($ productSelection ->getId ());
354- $ productSelectionSettingDraft = ProductSelectionSettingDraft:: of ()-> setProductSelection ($ productSelectionReference );
355- $ productSelection = [0 => $ productSelectionSettingDraft ];
357+ $ productSelectionSetting = ProductSelectionSetting:: ofProductSelection ($ productSelectionReference );
358+ $ productSelection = [0 => $ productSelectionSetting ];
356359
357360 $ request = RequestBuilder::of ()->stores ()->update ($ store )
358361 ->addAction (StoreSetProductSelectionsAction::ofProductSelections ($ productSelection ));
@@ -370,70 +373,4 @@ function (Store $store) use ($client, $productSelection) {
370373 }
371374 );
372375 }
373-
374- public function testAddProductSelection ()
375- {
376- $ client = $ this ->getApiClient ();
377-
378- ProductSelectionFixture::withProductSelection (
379- $ client ,
380- function (ProductSelection $ productSelection ) use ($ client ) {
381- StoreFixture::withUpdateableStore (
382- $ client ,
383- function (Store $ store ) use ($ client , $ productSelection ) {
384- $ productSelectionReference = ProductSelectionReference::ofId ($ productSelection ->getId ());
385- $ productSelectionSettingDraft = ProductSelectionSettingDraft::of ()->setProductSelection ($ productSelectionReference )->setActive (true );
386-
387- $ request = RequestBuilder::of ()->stores ()->update ($ store )
388- ->addAction (StoreAddProductSelectionAction::ofProductSelection ($ productSelectionSettingDraft ));
389- $ response = $ this ->execute ($ client , $ request );
390- $ result = $ request ->mapFromResponse ($ response );
391-
392- $ this ->assertInstanceOf (Store::class, $ result );
393- $ this ->assertSame ($ store ->getId (), $ result ->getId ());
394- $ this ->assertSame ($ productSelectionReference ->getId (), current ($ result )['productSelections ' ][0 ]['productSelection ' ]['id ' ]);
395- $ this ->assertNotSame ($ store ->getVersion (), $ result ->getVersion ());
396-
397- return $ result ;
398- }
399- );
400- }
401- );
402- }
403-
404- public function testRemoveProductSelection ()
405- {
406- $ client = $ this ->getApiClient ();
407-
408- ProductSelectionFixture::withProductSelection (
409- $ client ,
410- function (ProductSelection $ productSelection ) use ($ client ) {
411- $ productSelectionReference = ProductSelectionReference::ofId ($ productSelection ->getId ());
412- $ productSelectionSettingDraft = ProductSelectionSettingDraft::of ()->setProductSelection ($ productSelectionReference )->setActive (true );
413- StoreFixture::withUpdateableDraftStore (
414- $ client ,
415- function (StoreDraft $ storeDraft ) use ($ productSelectionSettingDraft ) {
416- $ storeDraft ->setKey ("removeProductSelectionStore " )
417- ->setName (LocalizedString::ofLangAndText ('en ' , "removeProductSelectionStore " ))
418- ->setProductSelections ($ productSelectionSettingDraft );
419-
420- return $ storeDraft ;
421- },
422- function (Store $ store ) use ($ client , $ productSelectionReference ) {
423- $ request = RequestBuilder::of ()->stores ()->update ($ store )
424- ->addAction (StoreRemoveProductSelectionAction::ofProductSelection ($ productSelectionReference ));
425- $ response = $ this ->execute ($ client , $ request );
426- $ result = $ request ->mapFromResponse ($ response );
427-
428- $ this ->assertInstanceOf (Store::class, $ result );
429- $ this ->assertSame ($ store ->getId (), $ result ->getId ());
430- $ this ->assertNotSame ($ store ->getVersion (), $ result ->getVersion ());
431- $ this ->assertEmpty ($ result ->getProductSelections ());
432-
433- return $ result ;
434- }
435- );
436- }
437- );
438- }
439376}
0 commit comments