Complex classes like AbstractThemeConfiguration often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use AbstractThemeConfiguration, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 9 | abstract class AbstractThemeConfiguration extends AbstractConfigurableElement implements NavigableThemeInterface |
||
| 10 | { |
||
| 11 | |||
| 12 | public $homeXpath; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * @var string The Xpath string that finds the base of the navigation menu |
||
| 16 | */ |
||
| 17 | public $navigationBaseXPathSelector; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @var string The Xpath string that can be used iteratively to find child navigation nodes |
||
| 21 | */ |
||
| 22 | |||
| 23 | public $navigationChildXPathSelector; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @var string A simple, default path to use for categories. |
||
| 27 | */ |
||
| 28 | |||
| 29 | public $navigationPathToSimpleProductCategory; |
||
| 30 | |||
| 31 | public $navigationPathToConfigurableProductCategory; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * @var string Xpath to add a Simple product to the cart from the product's page |
||
| 35 | */ |
||
| 36 | |||
| 37 | public $addToCartXpath; |
||
| 38 | |||
| 39 | public $defaultSimpleProductName; |
||
| 40 | public $defaultConfigurableProductName; |
||
| 41 | |||
| 42 | /** |
||
| 43 | * @var string Xpath to add a Simple product to the cart from the category page |
||
| 44 | */ |
||
| 45 | |||
| 46 | public $categoryAddToCartButtonXPathSelector; |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @var string Xpath to find a product's link on a category page. Used to navigate to the product from the category |
||
| 50 | */ |
||
| 51 | |||
| 52 | public $categoryProductPageXpath; |
||
| 53 | |||
| 54 | public $categorySpecificProductPageXpath; |
||
| 55 | |||
| 56 | |||
| 57 | /** |
||
| 58 | * @var string Xpath used after a product has been added to the cart to verify that the product has been added to the cart |
||
| 59 | */ |
||
| 60 | |||
| 61 | public $addToCartSuccessXpath; |
||
| 62 | |||
| 63 | /** |
||
| 64 | * @var string The base URL of the installation |
||
| 65 | */ |
||
| 66 | |||
| 67 | public $baseUrl; |
||
| 68 | |||
| 69 | public $myAccountTitle; |
||
| 70 | |||
| 71 | /** |
||
| 72 | * @var array Instructions in an Xpath array syntax to get to the login page. |
||
| 73 | */ |
||
| 74 | |||
| 75 | public $navigateToCustomerPageInstructions = []; |
||
| 76 | |||
| 77 | /** |
||
| 78 | * @var array Instructions in an Xpath array syntax to get to the shopping cart |
||
| 79 | */ |
||
| 80 | |||
| 81 | public $cartNavigationInstructions = []; |
||
| 82 | |||
| 83 | /** |
||
| 84 | * @var array Instructions in an Xpath array syntax to get to the start of the checkout page |
||
| 85 | */ |
||
| 86 | |||
| 87 | public $checkoutNavigationInstructions = []; |
||
| 88 | |||
| 89 | /** |
||
| 90 | * @var array Instructions in an Xpath array syntax to get to the customer registration page |
||
| 91 | */ |
||
| 92 | |||
| 93 | public $registrationNavigationInstructions = []; |
||
| 94 | |||
| 95 | /** |
||
| 96 | * @var array Instructions in an Xpath array syntax to get to the customer registration page |
||
| 97 | */ |
||
| 98 | |||
| 99 | public $logoutNavigationInstructions = []; |
||
| 100 | |||
| 101 | public $registerFirstNameXpath; |
||
| 102 | public $registerLastNameXpath; |
||
| 103 | public $registerEmailXpath; |
||
| 104 | public $registerPasswordXpath; |
||
| 105 | public $registerConfirmPasswordXpath; |
||
| 106 | public $registerNewsletterXpath; |
||
| 107 | public $registerSubmitXpath; |
||
| 108 | |||
| 109 | public $logoutSuccessXpath; |
||
| 110 | |||
| 111 | /** |
||
| 112 | * This is a hard one. Each of the summary checkout products will be iterated over until they cannot be found. Having |
||
| 113 | * this work in a manner that gets all of the products, in all languages, in all themes, is quite difficult and |
||
| 114 | * so the Xpath selector needs to be one that can find each individual column with an incrementing iterator. |
||
| 115 | * |
||
| 116 | * @see Magium\Magento\Actions\Checkout\Extractors\CartSummary for an example on how this is done |
||
| 117 | * |
||
| 118 | * @var string |
||
| 119 | */ |
||
| 120 | |||
| 121 | public $cartSummaryCheckoutProductLoopPriceXpath; |
||
| 122 | public $cartSummaryCheckoutProductLoopNameXpath; |
||
| 123 | public $cartSummaryCheckoutProductLoopQtyXpath; |
||
| 124 | public $cartSummaryCheckoutProductLoopSubtotalXpath; |
||
| 125 | |||
| 126 | public $cartSummaryCheckoutSubTotal; |
||
| 127 | public $cartSummaryCheckoutTax; |
||
| 128 | public $cartSummaryCheckoutGrandTotal; |
||
| 129 | public $cartSummaryCheckoutShippingTotal; |
||
| 130 | |||
| 131 | public $layeredNavigationTestXpath; |
||
| 132 | |||
| 133 | public $breadCrumbXpath; |
||
| 134 | |||
| 135 | public $productListBaseXpath; |
||
| 136 | public $productListDescriptionXpath; |
||
| 137 | public $productListTitleXpath; |
||
| 138 | public $productListCompareLinkXpath; |
||
| 139 | public $productListImageXpath; |
||
| 140 | public $productListLinkXpath; |
||
| 141 | public $productListOriginalPriceXpath; |
||
| 142 | public $productListPriceXpath; |
||
| 143 | public $productListWishlistLinkXpath; |
||
| 144 | public $productListAddToCartLinkXpath; |
||
| 145 | |||
| 146 | public $productGridBaseXpath; |
||
| 147 | public $productGridDescriptionXpath; |
||
| 148 | public $productGridTitleXpath; |
||
| 149 | public $productGridCompareLinkXpath; |
||
| 150 | public $productGridImageXpath; |
||
| 151 | public $productGridLinkXpath; |
||
| 152 | public $productGridOriginalPriceXpath; |
||
| 153 | public $productGridPriceXpath; |
||
| 154 | public $productGridWishlistLinkXpath; |
||
| 155 | public $productGridAddToCartLinkXpath; |
||
| 156 | |||
| 157 | public $productCollectionViewModeXpath; |
||
| 158 | public $productCollectionSortByXpath; |
||
| 159 | public $productCollectionShowCountXpath; |
||
| 160 | public $productCollectionShowCountOptionsXpath; |
||
| 161 | public $productCollectionProductCountXpath; |
||
| 162 | |||
| 163 | public $simpleProductQtyXpath; |
||
| 164 | |||
| 165 | public $layeredNavigationBaseXpath; |
||
| 166 | |||
| 167 | public $searchInputXpath; |
||
| 168 | public $searchSubmitXpath; |
||
| 169 | |||
| 170 | public $searchSuggestionTextXpath; |
||
| 171 | public $searchSuggestionCountXpath; |
||
| 172 | |||
| 173 | public $storeSwitcherInstructionsXpath; |
||
| 174 | |||
| 175 | public $configurableProductLabelXpath; |
||
| 176 | public $configurableSwatchSelectorXpath; |
||
| 177 | public $configurableSwatchImgXpath; |
||
| 178 | public $configurableSwatchNotAvailableXpath; |
||
| 179 | public $configurableSwatchOptionLabelAttributeName; |
||
| 180 | |||
| 181 | public $configurableProductOptionXpath; |
||
| 182 | |||
| 183 | public $viewModeAttributeName; |
||
| 184 | |||
| 185 | public $breadCrumbMemberXpath; |
||
| 186 | public $breadCrumbSelectorXpath; |
||
| 187 | |||
| 188 | public $layeredNavigationFilterNameXpath; |
||
| 189 | |||
| 190 | public $layeredNavigationFilterTypesXpath; |
||
| 191 | public $layeredNavigationFilterLinkXpath; |
||
| 192 | public $layeredNavigationFilterNameElementXpath; |
||
| 193 | public $layeredNavigationSwatchAppliesXpath; |
||
| 194 | public $layeredNavigationSwatchFilterTypesXpath; |
||
| 195 | public $layeredNavigationSwatchTitleAttribute; |
||
| 196 | |||
| 197 | abstract public function getCustomerThemeClass(); |
||
| 199 | |||
| 200 | public $guaranteedPageLoadedElementDisplayedXpath = '//div[contains(concat(" ",normalize-space(@class)," ")," footer ")]'; |
||
| 201 | |||
| 202 | public $contactUsNameXpath = '//form[@id="contactForm"]/descendant::input[@id="name"]'; |
||
| 203 | public $contactUsEmailXpath = '//form[@id="contactForm"]/descendant::input[@id="email"]'; |
||
| 204 | public $contactUsTelephoneXpath = '//form[@id="contactForm"]/descendant::input[@id="telephone"]'; |
||
| 205 | public $contactUsCommentXpath = '//form[@id="contactForm"]/descendant::textarea[@id="comment"]'; |
||
| 206 | public $contactUsSubmitXpath = '//form[@id="contactForm"]/descendant::button'; |
||
| 207 | |||
| 208 | public $useClicksToNavigate = false; |
||
| 209 | |||
| 210 | public function getUseClicksToNavigate() |
||
| 214 | |||
| 215 | public function configure(AbstractTestCase $testCase) |
||
| 219 | |||
| 220 | /** |
||
| 221 | * @return mixed |
||
| 222 | */ |
||
| 223 | public function getConfigurableSwatchOptionLabelAttributeName() |
||
| 227 | |||
| 228 | /** |
||
| 229 | * @return string |
||
| 230 | */ |
||
| 231 | public function getContactUsSubmitXpath() |
||
| 235 | |||
| 236 | /** |
||
| 237 | * @return string |
||
| 238 | */ |
||
| 239 | public function getContactUsNameXpath() |
||
| 243 | |||
| 244 | /** |
||
| 245 | * @return string |
||
| 246 | */ |
||
| 247 | public function getContactUsEmailXpath() |
||
| 251 | |||
| 252 | /** |
||
| 253 | * @return string |
||
| 254 | */ |
||
| 255 | public function getContactUsCommentXpath() |
||
| 259 | |||
| 260 | /** |
||
| 261 | * @return string |
||
| 262 | */ |
||
| 263 | public function getContactUsTelephoneXpath() |
||
| 267 | |||
| 268 | |||
| 269 | |||
| 270 | /** |
||
| 271 | * @return array |
||
| 272 | */ |
||
| 273 | public function getCartNavigationInstructions() |
||
| 277 | |||
| 278 | /** |
||
| 279 | * @return string |
||
| 280 | */ |
||
| 281 | public function getLayeredNavigationSwatchTitleAttribute() |
||
| 285 | |||
| 286 | /** |
||
| 287 | * @return mixed |
||
| 288 | */ |
||
| 289 | public function getLayeredNavigationSwatchAppliesXpath($name) |
||
| 295 | |||
| 296 | /** |
||
| 297 | * @return mixed |
||
| 298 | */ |
||
| 299 | public function getLayeredNavigationSwatchFilterTypesXpath($name) |
||
| 303 | |||
| 304 | /** |
||
| 305 | * @return mixed |
||
| 306 | */ |
||
| 307 | public function getLayeredNavigationFilterNameElementXpath($name) |
||
| 311 | |||
| 312 | /** |
||
| 313 | * @return string |
||
| 314 | */ |
||
| 315 | public function getLayeredNavigationFilterTypesXpath($type) |
||
| 319 | |||
| 320 | /** |
||
| 321 | * @return string |
||
| 322 | */ |
||
| 323 | public function getLayeredNavigationFilterLinkXpath($type) |
||
| 327 | |||
| 328 | |||
| 329 | |||
| 330 | /** |
||
| 331 | * @return mixed |
||
| 332 | */ |
||
| 333 | public function getLayeredNavigationFilterNameXpath() |
||
| 337 | |||
| 338 | public function getBreadCrumbMemberXpath($name) |
||
| 342 | |||
| 343 | /** |
||
| 344 | * @return mixed |
||
| 345 | */ |
||
| 346 | public function getBreadCrumbSelectorXpath($test) |
||
| 350 | |||
| 351 | |||
| 352 | |||
| 353 | /** |
||
| 354 | * @return mixed |
||
| 355 | */ |
||
| 356 | public function getConfigurableProductOptionXpath($swatchCount, $label) |
||
| 368 | |||
| 369 | public function getConfigurableSwatchImgXpath($swatchCount, $optionCount) |
||
| 380 | |||
| 381 | /** |
||
| 382 | * @return string |
||
| 383 | */ |
||
| 384 | public function getConfigurableLabelXpath() |
||
| 388 | |||
| 389 | public function filterConfigurableProductOptionName($swatch) |
||
| 393 | |||
| 394 | /** |
||
| 395 | * @return string |
||
| 396 | */ |
||
| 397 | public function getConfigurableSwatchNotAvailableXpath($swatchCount, $optionCount) |
||
| 408 | |||
| 409 | /** |
||
| 410 | * @return string |
||
| 411 | */ |
||
| 412 | public function getConfigurableSwatchSelectorXpath($swatchCount, $optionCount) |
||
| 423 | |||
| 424 | |||
| 425 | |||
| 426 | /** |
||
| 427 | * @return mixed |
||
| 428 | */ |
||
| 429 | public function getDefaultSimpleProductName() |
||
| 433 | |||
| 434 | /** |
||
| 435 | * @return mixed |
||
| 436 | */ |
||
| 437 | public function getDefaultConfigurableProductName() |
||
| 441 | |||
| 442 | /** |
||
| 443 | * @return mixed |
||
| 444 | */ |
||
| 445 | public function getSimpleProductQtyXpath() |
||
| 449 | |||
| 450 | public function getGuaranteedPageLoadedElementDisplayedXpath() |
||
| 454 | |||
| 455 | /** |
||
| 456 | * @param mixed $guaranteedPageLoadedElementDisplayedXpath |
||
| 457 | */ |
||
| 458 | public function setGuaranteedPageLoadedElementDisplayedXpath($guaranteedPageLoadedElementDisplayedXpath) |
||
| 462 | |||
| 463 | /** |
||
| 464 | * @return mixed |
||
| 465 | */ |
||
| 466 | public function getStoreSwitcherInstructionsXpath($store) |
||
| 476 | |||
| 477 | /** |
||
| 478 | * @return mixed |
||
| 479 | */ |
||
| 480 | public function getSearchSuggestionTextXpath($count) |
||
| 485 | |||
| 486 | /** |
||
| 487 | * @return mixed |
||
| 488 | */ |
||
| 489 | public function getSearchSuggestionCountXpath($count) |
||
| 494 | |||
| 495 | /** |
||
| 496 | * @return mixed |
||
| 497 | */ |
||
| 498 | public function getSearchSubmitXpath() |
||
| 502 | |||
| 503 | /** |
||
| 504 | * @return mixed |
||
| 505 | */ |
||
| 506 | public function getSearchInputXpath() |
||
| 510 | |||
| 511 | /** |
||
| 512 | * @return mixed |
||
| 513 | */ |
||
| 514 | public function getCategorySpecificProductPageXpath($productName) |
||
| 519 | |||
| 520 | /** |
||
| 521 | * @return mixed |
||
| 522 | */ |
||
| 523 | public function getHomeXpath() |
||
| 527 | |||
| 528 | /** |
||
| 529 | * @return mixed |
||
| 530 | */ |
||
| 531 | public function getLayeredNavigationBaseXpath() |
||
| 535 | |||
| 536 | /** |
||
| 537 | * @return mixed |
||
| 538 | */ |
||
| 539 | public function getProductCollectionViewModeXpath() |
||
| 543 | |||
| 544 | /** |
||
| 545 | * @return mixed |
||
| 546 | */ |
||
| 547 | public function getProductCollectionSortByXpath() |
||
| 551 | |||
| 552 | public function getViewModeAttributeName() |
||
| 556 | |||
| 557 | /** |
||
| 558 | * @return mixed |
||
| 559 | */ |
||
| 560 | public function getProductCollectionShowCountXpath() |
||
| 564 | |||
| 565 | /** |
||
| 566 | * @return mixed |
||
| 567 | */ |
||
| 568 | public function getProductCollectionShowCountOptionsXpath() |
||
| 572 | |||
| 573 | /** |
||
| 574 | * @return mixed |
||
| 575 | */ |
||
| 576 | public function getProductCollectionProductCountXpath() |
||
| 580 | |||
| 581 | |||
| 582 | |||
| 583 | /** |
||
| 584 | * @return mixed |
||
| 585 | */ |
||
| 586 | public function getProductListAddToCartLinkXpath($count) |
||
| 590 | |||
| 591 | /** |
||
| 592 | * @return mixed |
||
| 593 | */ |
||
| 594 | public function getProductGridAddToCartLinkXpath($count) |
||
| 598 | |||
| 599 | /** |
||
| 600 | * @return mixed |
||
| 601 | */ |
||
| 602 | public function getProductListDescriptionXpath($count) |
||
| 606 | |||
| 607 | /** |
||
| 608 | * @return mixed |
||
| 609 | */ |
||
| 610 | public function getProductListTitleXpath($count) |
||
| 614 | |||
| 615 | /** |
||
| 616 | * @return mixed |
||
| 617 | */ |
||
| 618 | public function getProductListCompareLinkXpath($count) |
||
| 622 | |||
| 623 | /** |
||
| 624 | * @return mixed |
||
| 625 | */ |
||
| 626 | public function getProductListImageXpath($count) |
||
| 630 | |||
| 631 | /** |
||
| 632 | * @return mixed |
||
| 633 | */ |
||
| 634 | public function getProductListLinkXpath($count) |
||
| 638 | |||
| 639 | /** |
||
| 640 | * @return mixed |
||
| 641 | */ |
||
| 642 | public function getProductListOriginalPriceXpath($count) |
||
| 646 | |||
| 647 | /** |
||
| 648 | * @return mixed |
||
| 649 | */ |
||
| 650 | public function getProductListPriceXpath($count) |
||
| 654 | |||
| 655 | /** |
||
| 656 | * @return mixed |
||
| 657 | */ |
||
| 658 | public function getProductListWishlistLinkXpath($count) |
||
| 662 | |||
| 663 | /** |
||
| 664 | * @return mixed |
||
| 665 | */ |
||
| 666 | public function getProductGridDescriptionXpath($count) |
||
| 670 | |||
| 671 | /** |
||
| 672 | * @return mixed |
||
| 673 | */ |
||
| 674 | public function getProductGridTitleXpath($count) |
||
| 678 | |||
| 679 | /** |
||
| 680 | * @return mixed |
||
| 681 | */ |
||
| 682 | public function getProductGridCompareLinkXpath($count) |
||
| 686 | |||
| 687 | /** |
||
| 688 | * @return mixed |
||
| 689 | */ |
||
| 690 | public function getProductGridImageXpath($count) |
||
| 694 | |||
| 695 | /** |
||
| 696 | * @return mixed |
||
| 697 | */ |
||
| 698 | public function getProductGridLinkXpath($count) |
||
| 702 | |||
| 703 | /** |
||
| 704 | * @return mixed |
||
| 705 | */ |
||
| 706 | public function getProductGridOriginalPriceXpath($count) |
||
| 710 | |||
| 711 | /** |
||
| 712 | * @return mixed |
||
| 713 | */ |
||
| 714 | public function getProductGridPriceXpath($count) |
||
| 718 | |||
| 719 | /** |
||
| 720 | * @return mixed |
||
| 721 | */ |
||
| 722 | public function getProductGridWishlistLinkXpath($count) |
||
| 726 | |||
| 727 | /** |
||
| 728 | * @return mixed |
||
| 729 | */ |
||
| 730 | public function getBreadCrumbXpath() |
||
| 734 | |||
| 735 | /** |
||
| 736 | * @return mixed |
||
| 737 | */ |
||
| 738 | public function getLayeredNavigationTestXpath() |
||
| 742 | |||
| 743 | public function getBaseUrl() |
||
| 747 | |||
| 748 | /** |
||
| 749 | * @return string |
||
| 750 | */ |
||
| 751 | public function getLogoutSuccessXpath() |
||
| 755 | |||
| 756 | /** |
||
| 757 | * @return array |
||
| 758 | */ |
||
| 759 | public function getLogoutNavigationInstructions() |
||
| 763 | |||
| 764 | |||
| 765 | /** |
||
| 766 | * @return string |
||
| 767 | */ |
||
| 768 | public function getMyAccountTitle() |
||
| 772 | |||
| 773 | /** |
||
| 774 | * @return string |
||
| 775 | */ |
||
| 776 | public function getRegisterFirstNameXpath() |
||
| 780 | |||
| 781 | /** |
||
| 782 | * @return string |
||
| 783 | */ |
||
| 784 | public function getRegisterLastNameXpath() |
||
| 788 | |||
| 789 | /** |
||
| 790 | * @return string |
||
| 791 | */ |
||
| 792 | public function getRegisterEmailXpath() |
||
| 796 | |||
| 797 | /** |
||
| 798 | * @return string |
||
| 799 | */ |
||
| 800 | public function getRegisterPasswordXpath() |
||
| 804 | |||
| 805 | /** |
||
| 806 | * @return string |
||
| 807 | */ |
||
| 808 | public function getRegisterConfirmPasswordXpath() |
||
| 812 | |||
| 813 | /** |
||
| 814 | * @return string |
||
| 815 | */ |
||
| 816 | public function getRegisterNewsletterXpath() |
||
| 820 | |||
| 821 | /** |
||
| 822 | * @return string |
||
| 823 | */ |
||
| 824 | public function getRegisterSubmitXpath() |
||
| 828 | |||
| 829 | /** |
||
| 830 | * @return array |
||
| 831 | */ |
||
| 832 | public function getRegistrationNavigationInstructions() |
||
| 836 | |||
| 837 | public function getCheckoutNavigationInstructions() |
||
| 841 | |||
| 842 | public function getProductPageForCategory() |
||
| 846 | |||
| 847 | public function getAddToCartSuccessXpath() |
||
| 851 | |||
| 852 | public function getNavigateToCustomerPageInstructions() |
||
| 856 | |||
| 857 | public function getNavigationBaseXPathSelector() |
||
| 861 | |||
| 862 | public function getNavigationChildXPathSelector($text) |
||
| 867 | |||
| 868 | public function getNavigationPathToSimpleProductCategory() |
||
| 872 | |||
| 873 | public function getNavigationPathToConfigurableProductCategory() |
||
| 877 | |||
| 878 | public function getCategoryAddToCartButtonXPathSelector() |
||
| 882 | |||
| 883 | |||
| 884 | public function getAddToCartXpath() |
||
| 888 | |||
| 889 | |||
| 890 | |||
| 891 | } |