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 | /** |
||
| 70 | * @var string The Xpath for extracting the price from a page |
||
| 71 | */ |
||
| 72 | |||
| 73 | public $productPagePriceXpath; |
||
| 74 | |||
| 75 | public $myAccountTitle; |
||
| 76 | |||
| 77 | /** |
||
| 78 | * @var array Instructions in an Xpath array syntax to get to the login page. |
||
| 79 | */ |
||
| 80 | |||
| 81 | public $navigateToCustomerPageInstructions = []; |
||
| 82 | |||
| 83 | /** |
||
| 84 | * @var array Instructions in an Xpath array syntax to get to the shopping cart |
||
| 85 | */ |
||
| 86 | |||
| 87 | public $cartNavigationInstructions = []; |
||
| 88 | |||
| 89 | /** |
||
| 90 | * @var array Instructions in an Xpath array syntax to get to the start of the checkout page |
||
| 91 | */ |
||
| 92 | |||
| 93 | public $checkoutNavigationInstructions = []; |
||
| 94 | |||
| 95 | /** |
||
| 96 | * @var array Instructions in an Xpath array syntax to get to the customer registration page |
||
| 97 | */ |
||
| 98 | |||
| 99 | public $registrationNavigationInstructions = []; |
||
| 100 | |||
| 101 | /** |
||
| 102 | * @var array Instructions in an Xpath array syntax to get to the customer registration page |
||
| 103 | */ |
||
| 104 | |||
| 105 | public $logoutNavigationInstructions = []; |
||
| 106 | |||
| 107 | public $registerFirstNameXpath; |
||
| 108 | public $registerLastNameXpath; |
||
| 109 | public $registerEmailXpath; |
||
| 110 | public $registerPasswordXpath; |
||
| 111 | public $registerConfirmPasswordXpath; |
||
| 112 | public $registerNewsletterXpath; |
||
| 113 | public $registerSubmitXpath; |
||
| 114 | |||
| 115 | public $logoutSuccessXpath; |
||
| 116 | |||
| 117 | /** |
||
| 118 | * This is a hard one. Each of the summary checkout products will be iterated over until they cannot be found. Having |
||
| 119 | * this work in a manner that gets all of the products, in all languages, in all themes, is quite difficult and |
||
| 120 | * so the Xpath selector needs to be one that can find each individual column with an incrementing iterator. |
||
| 121 | * |
||
| 122 | * @see Magium\Magento\Actions\Checkout\Extractors\CartSummary for an example on how this is done |
||
| 123 | * |
||
| 124 | * @var string |
||
| 125 | */ |
||
| 126 | |||
| 127 | public $cartSummaryCheckoutProductLoopPriceXpath; |
||
| 128 | public $cartSummaryCheckoutProductLoopNameXpath; |
||
| 129 | public $cartSummaryCheckoutProductLoopQtyXpath; |
||
| 130 | public $cartSummaryCheckoutProductLoopSubtotalXpath; |
||
| 131 | |||
| 132 | public $cartSummaryCheckoutSubTotal; |
||
| 133 | public $cartSummaryCheckoutTax; |
||
| 134 | public $cartSummaryCheckoutGrandTotal; |
||
| 135 | public $cartSummaryCheckoutShippingTotal; |
||
| 136 | |||
| 137 | public $layeredNavigationTestXpath; |
||
| 138 | |||
| 139 | public $breadCrumbXpath; |
||
| 140 | |||
| 141 | public $productListBaseXpath; |
||
| 142 | public $productListDescriptionXpath; |
||
| 143 | public $productListTitleXpath; |
||
| 144 | public $productListCompareLinkXpath; |
||
| 145 | public $productListImageXpath; |
||
| 146 | public $productListLinkXpath; |
||
| 147 | public $productListOriginalPriceXpath; |
||
| 148 | public $productListPriceXpath; |
||
| 149 | public $productListWishlistLinkXpath; |
||
| 150 | public $productListAddToCartLinkXpath; |
||
| 151 | |||
| 152 | public $productGridBaseXpath; |
||
| 153 | public $productGridDescriptionXpath; |
||
| 154 | public $productGridTitleXpath; |
||
| 155 | public $productGridCompareLinkXpath; |
||
| 156 | public $productGridImageXpath; |
||
| 157 | public $productGridLinkXpath; |
||
| 158 | public $productGridOriginalPriceXpath; |
||
| 159 | public $productGridPriceXpath; |
||
| 160 | public $productGridWishlistLinkXpath; |
||
| 161 | public $productGridAddToCartLinkXpath; |
||
| 162 | |||
| 163 | public $productCollectionViewModeXpath; |
||
| 164 | public $productCollectionSortByXpath; |
||
| 165 | public $productCollectionShowCountXpath; |
||
| 166 | public $productCollectionShowCountOptionsXpath; |
||
| 167 | public $productCollectionProductCountXpath; |
||
| 168 | |||
| 169 | public $simpleProductQtyXpath; |
||
| 170 | |||
| 171 | public $layeredNavigationBaseXpath; |
||
| 172 | |||
| 173 | public $searchInputXpath; |
||
| 174 | public $searchSubmitXpath; |
||
| 175 | |||
| 176 | public $searchSuggestionTextXpath; |
||
| 177 | public $searchSuggestionCountXpath; |
||
| 178 | |||
| 179 | public $storeSwitcherInstructionsXpath; |
||
| 180 | |||
| 181 | public $configurableProductLabelXpath; |
||
| 182 | public $configurableSwatchSelectorXpath; |
||
| 183 | public $configurableSwatchImgXpath; |
||
| 184 | public $configurableSwatchNotAvailableXpath; |
||
| 185 | public $configurableSwatchOptionLabelAttributeName; |
||
| 186 | |||
| 187 | public $configurableProductOptionXpath; |
||
| 188 | |||
| 189 | public $viewModeAttributeName; |
||
| 190 | |||
| 191 | public $breadCrumbMemberXpath; |
||
| 192 | public $breadCrumbSelectorXpath; |
||
| 193 | |||
| 194 | public $layeredNavigationFilterNameXpath; |
||
| 195 | |||
| 196 | public $layeredNavigationFilterTypesXpath; |
||
| 197 | public $layeredNavigationFilterLinkXpath; |
||
| 198 | public $layeredNavigationFilterNameElementXpath; |
||
| 199 | public $layeredNavigationSwatchAppliesXpath; |
||
| 200 | public $layeredNavigationSwatchFilterTypesXpath; |
||
| 201 | public $layeredNavigationSwatchTitleAttribute; |
||
| 202 | |||
| 203 | abstract public function getCustomerThemeClass(); |
||
| 205 | |||
| 206 | public $guaranteedPageLoadedElementDisplayedXpath = '//div[contains(concat(" ",normalize-space(@class)," ")," footer ")]'; |
||
| 207 | |||
| 208 | public $contactUsNameXpath = '//form[@id="contactForm"]/descendant::input[@id="name"]'; |
||
| 209 | public $contactUsEmailXpath = '//form[@id="contactForm"]/descendant::input[@id="email"]'; |
||
| 210 | public $contactUsTelephoneXpath = '//form[@id="contactForm"]/descendant::input[@id="telephone"]'; |
||
| 211 | public $contactUsCommentXpath = '//form[@id="contactForm"]/descendant::textarea[@id="comment"]'; |
||
| 212 | public $contactUsSubmitXpath = '//form[@id="contactForm"]/descendant::button'; |
||
| 213 | |||
| 214 | public $useClicksToNavigate = false; |
||
| 215 | |||
| 216 | public function getUseClicksToNavigate() |
||
| 220 | |||
| 221 | public function configure(AbstractTestCase $testCase) |
||
| 225 | |||
| 226 | /** |
||
| 227 | * @return mixed |
||
| 228 | */ |
||
| 229 | public function getConfigurableSwatchOptionLabelAttributeName() |
||
| 233 | |||
| 234 | /** |
||
| 235 | * @return string |
||
| 236 | */ |
||
| 237 | public function getContactUsSubmitXpath() |
||
| 241 | |||
| 242 | /** |
||
| 243 | * @return string |
||
| 244 | */ |
||
| 245 | public function getContactUsNameXpath() |
||
| 249 | |||
| 250 | /** |
||
| 251 | * @return string |
||
| 252 | */ |
||
| 253 | public function getContactUsEmailXpath() |
||
| 257 | |||
| 258 | /** |
||
| 259 | * @return string |
||
| 260 | */ |
||
| 261 | public function getContactUsCommentXpath() |
||
| 265 | |||
| 266 | /** |
||
| 267 | * @return string |
||
| 268 | */ |
||
| 269 | public function getContactUsTelephoneXpath() |
||
| 273 | |||
| 274 | |||
| 275 | |||
| 276 | /** |
||
| 277 | * @return array |
||
| 278 | */ |
||
| 279 | public function getCartNavigationInstructions() |
||
| 283 | |||
| 284 | /** |
||
| 285 | * @return string |
||
| 286 | */ |
||
| 287 | public function getLayeredNavigationSwatchTitleAttribute() |
||
| 291 | |||
| 292 | /** |
||
| 293 | * @return mixed |
||
| 294 | */ |
||
| 295 | public function getLayeredNavigationSwatchAppliesXpath($name) |
||
| 301 | |||
| 302 | /** |
||
| 303 | * @return mixed |
||
| 304 | */ |
||
| 305 | public function getLayeredNavigationSwatchFilterTypesXpath($name) |
||
| 309 | |||
| 310 | /** |
||
| 311 | * @return mixed |
||
| 312 | */ |
||
| 313 | public function getLayeredNavigationFilterNameElementXpath($name) |
||
| 317 | |||
| 318 | /** |
||
| 319 | * @return string |
||
| 320 | */ |
||
| 321 | public function getLayeredNavigationFilterTypesXpath($type) |
||
| 325 | |||
| 326 | /** |
||
| 327 | * @return string |
||
| 328 | */ |
||
| 329 | public function getLayeredNavigationFilterLinkXpath($type) |
||
| 333 | |||
| 334 | |||
| 335 | |||
| 336 | /** |
||
| 337 | * @return mixed |
||
| 338 | */ |
||
| 339 | public function getLayeredNavigationFilterNameXpath() |
||
| 343 | |||
| 344 | public function getBreadCrumbMemberXpath($name) |
||
| 348 | |||
| 349 | /** |
||
| 350 | * @return mixed |
||
| 351 | */ |
||
| 352 | public function getBreadCrumbSelectorXpath($test) |
||
| 356 | |||
| 357 | /** |
||
| 358 | * @return string |
||
| 359 | */ |
||
| 360 | public function getProductPagePriceXpath() |
||
| 364 | |||
| 365 | /** |
||
| 366 | * @return mixed |
||
| 367 | */ |
||
| 368 | public function getConfigurableProductOptionXpath($swatchCount, $label) |
||
| 380 | |||
| 381 | public function getConfigurableSwatchImgXpath($swatchCount, $optionCount) |
||
| 392 | |||
| 393 | /** |
||
| 394 | * @return string |
||
| 395 | */ |
||
| 396 | public function getConfigurableLabelXpath() |
||
| 400 | |||
| 401 | public function filterConfigurableProductOptionName($swatch) |
||
| 405 | |||
| 406 | /** |
||
| 407 | * @return string |
||
| 408 | */ |
||
| 409 | public function getConfigurableSwatchNotAvailableXpath($swatchCount, $optionCount) |
||
| 420 | |||
| 421 | /** |
||
| 422 | * @return string |
||
| 423 | */ |
||
| 424 | public function getConfigurableSwatchSelectorXpath($swatchCount, $optionCount) |
||
| 435 | |||
| 436 | |||
| 437 | |||
| 438 | /** |
||
| 439 | * @return mixed |
||
| 440 | */ |
||
| 441 | public function getDefaultSimpleProductName() |
||
| 445 | |||
| 446 | /** |
||
| 447 | * @return mixed |
||
| 448 | */ |
||
| 449 | public function getDefaultConfigurableProductName() |
||
| 453 | |||
| 454 | /** |
||
| 455 | * @return mixed |
||
| 456 | */ |
||
| 457 | public function getSimpleProductQtyXpath() |
||
| 461 | |||
| 462 | public function getGuaranteedPageLoadedElementDisplayedXpath() |
||
| 466 | |||
| 467 | /** |
||
| 468 | * @param mixed $guaranteedPageLoadedElementDisplayedXpath |
||
| 469 | */ |
||
| 470 | public function setGuaranteedPageLoadedElementDisplayedXpath($guaranteedPageLoadedElementDisplayedXpath) |
||
| 474 | |||
| 475 | /** |
||
| 476 | * @return mixed |
||
| 477 | */ |
||
| 478 | public function getStoreSwitcherInstructionsXpath($store) |
||
| 488 | |||
| 489 | /** |
||
| 490 | * @return mixed |
||
| 491 | */ |
||
| 492 | public function getSearchSuggestionTextXpath($count) |
||
| 497 | |||
| 498 | /** |
||
| 499 | * @return mixed |
||
| 500 | */ |
||
| 501 | public function getSearchSuggestionCountXpath($count) |
||
| 506 | |||
| 507 | /** |
||
| 508 | * @return mixed |
||
| 509 | */ |
||
| 510 | public function getSearchSubmitXpath() |
||
| 514 | |||
| 515 | /** |
||
| 516 | * @return mixed |
||
| 517 | */ |
||
| 518 | public function getSearchInputXpath() |
||
| 522 | |||
| 523 | /** |
||
| 524 | * @return mixed |
||
| 525 | */ |
||
| 526 | public function getCategorySpecificProductPageXpath($productName) |
||
| 531 | |||
| 532 | /** |
||
| 533 | * @return mixed |
||
| 534 | */ |
||
| 535 | public function getHomeXpath() |
||
| 539 | |||
| 540 | /** |
||
| 541 | * @return mixed |
||
| 542 | */ |
||
| 543 | public function getLayeredNavigationBaseXpath() |
||
| 547 | |||
| 548 | /** |
||
| 549 | * @return mixed |
||
| 550 | */ |
||
| 551 | public function getProductCollectionViewModeXpath() |
||
| 555 | |||
| 556 | /** |
||
| 557 | * @return mixed |
||
| 558 | */ |
||
| 559 | public function getProductCollectionSortByXpath() |
||
| 563 | |||
| 564 | public function getViewModeAttributeName() |
||
| 568 | |||
| 569 | /** |
||
| 570 | * @return mixed |
||
| 571 | */ |
||
| 572 | public function getProductCollectionShowCountXpath() |
||
| 576 | |||
| 577 | /** |
||
| 578 | * @return mixed |
||
| 579 | */ |
||
| 580 | public function getProductCollectionShowCountOptionsXpath() |
||
| 584 | |||
| 585 | /** |
||
| 586 | * @return mixed |
||
| 587 | */ |
||
| 588 | public function getProductCollectionProductCountXpath() |
||
| 592 | |||
| 593 | |||
| 594 | |||
| 595 | /** |
||
| 596 | * @return mixed |
||
| 597 | */ |
||
| 598 | public function getProductListAddToCartLinkXpath($count) |
||
| 602 | |||
| 603 | /** |
||
| 604 | * @return mixed |
||
| 605 | */ |
||
| 606 | public function getProductGridAddToCartLinkXpath($count) |
||
| 610 | |||
| 611 | /** |
||
| 612 | * @return mixed |
||
| 613 | */ |
||
| 614 | public function getProductListDescriptionXpath($count) |
||
| 618 | |||
| 619 | /** |
||
| 620 | * @return mixed |
||
| 621 | */ |
||
| 622 | public function getProductListTitleXpath($count) |
||
| 626 | |||
| 627 | /** |
||
| 628 | * @return mixed |
||
| 629 | */ |
||
| 630 | public function getProductListCompareLinkXpath($count) |
||
| 634 | |||
| 635 | /** |
||
| 636 | * @return mixed |
||
| 637 | */ |
||
| 638 | public function getProductListImageXpath($count) |
||
| 642 | |||
| 643 | /** |
||
| 644 | * @return mixed |
||
| 645 | */ |
||
| 646 | public function getProductListLinkXpath($count) |
||
| 650 | |||
| 651 | /** |
||
| 652 | * @return mixed |
||
| 653 | */ |
||
| 654 | public function getProductListOriginalPriceXpath($count) |
||
| 658 | |||
| 659 | /** |
||
| 660 | * @return mixed |
||
| 661 | */ |
||
| 662 | public function getProductListPriceXpath($count) |
||
| 666 | |||
| 667 | /** |
||
| 668 | * @return mixed |
||
| 669 | */ |
||
| 670 | public function getProductListWishlistLinkXpath($count) |
||
| 674 | |||
| 675 | /** |
||
| 676 | * @return mixed |
||
| 677 | */ |
||
| 678 | public function getProductGridDescriptionXpath($count) |
||
| 682 | |||
| 683 | /** |
||
| 684 | * @return mixed |
||
| 685 | */ |
||
| 686 | public function getProductGridTitleXpath($count) |
||
| 690 | |||
| 691 | /** |
||
| 692 | * @return mixed |
||
| 693 | */ |
||
| 694 | public function getProductGridCompareLinkXpath($count) |
||
| 698 | |||
| 699 | /** |
||
| 700 | * @return mixed |
||
| 701 | */ |
||
| 702 | public function getProductGridImageXpath($count) |
||
| 706 | |||
| 707 | /** |
||
| 708 | * @return mixed |
||
| 709 | */ |
||
| 710 | public function getProductGridLinkXpath($count) |
||
| 714 | |||
| 715 | /** |
||
| 716 | * @return mixed |
||
| 717 | */ |
||
| 718 | public function getProductGridOriginalPriceXpath($count) |
||
| 722 | |||
| 723 | /** |
||
| 724 | * @return mixed |
||
| 725 | */ |
||
| 726 | public function getProductGridPriceXpath($count) |
||
| 730 | |||
| 731 | /** |
||
| 732 | * @return mixed |
||
| 733 | */ |
||
| 734 | public function getProductGridWishlistLinkXpath($count) |
||
| 738 | |||
| 739 | /** |
||
| 740 | * @return mixed |
||
| 741 | */ |
||
| 742 | public function getBreadCrumbXpath() |
||
| 746 | |||
| 747 | /** |
||
| 748 | * @return mixed |
||
| 749 | */ |
||
| 750 | public function getLayeredNavigationTestXpath() |
||
| 754 | |||
| 755 | public function getBaseUrl() |
||
| 759 | |||
| 760 | /** |
||
| 761 | * @return string |
||
| 762 | */ |
||
| 763 | public function getLogoutSuccessXpath() |
||
| 767 | |||
| 768 | /** |
||
| 769 | * @return array |
||
| 770 | */ |
||
| 771 | public function getLogoutNavigationInstructions() |
||
| 775 | |||
| 776 | |||
| 777 | /** |
||
| 778 | * @return string |
||
| 779 | */ |
||
| 780 | public function getMyAccountTitle() |
||
| 784 | |||
| 785 | /** |
||
| 786 | * @return string |
||
| 787 | */ |
||
| 788 | public function getRegisterFirstNameXpath() |
||
| 792 | |||
| 793 | /** |
||
| 794 | * @return string |
||
| 795 | */ |
||
| 796 | public function getRegisterLastNameXpath() |
||
| 800 | |||
| 801 | /** |
||
| 802 | * @return string |
||
| 803 | */ |
||
| 804 | public function getRegisterEmailXpath() |
||
| 808 | |||
| 809 | /** |
||
| 810 | * @return string |
||
| 811 | */ |
||
| 812 | public function getRegisterPasswordXpath() |
||
| 816 | |||
| 817 | /** |
||
| 818 | * @return string |
||
| 819 | */ |
||
| 820 | public function getRegisterConfirmPasswordXpath() |
||
| 824 | |||
| 825 | /** |
||
| 826 | * @return string |
||
| 827 | */ |
||
| 828 | public function getRegisterNewsletterXpath() |
||
| 832 | |||
| 833 | /** |
||
| 834 | * @return string |
||
| 835 | */ |
||
| 836 | public function getRegisterSubmitXpath() |
||
| 840 | |||
| 841 | /** |
||
| 842 | * @return array |
||
| 843 | */ |
||
| 844 | public function getRegistrationNavigationInstructions() |
||
| 848 | |||
| 849 | public function getCheckoutNavigationInstructions() |
||
| 853 | |||
| 854 | public function getProductPageForCategory() |
||
| 858 | |||
| 859 | public function getAddToCartSuccessXpath() |
||
| 863 | |||
| 864 | public function getNavigateToCustomerPageInstructions() |
||
| 868 | |||
| 869 | public function getNavigationBaseXPathSelector() |
||
| 873 | |||
| 874 | public function getNavigationChildXPathSelector($text) |
||
| 879 | |||
| 880 | public function getNavigationPathToSimpleProductCategory() |
||
| 884 | |||
| 885 | public function getNavigationPathToConfigurableProductCategory() |
||
| 889 | |||
| 890 | public function getCategoryAddToCartButtonXPathSelector() |
||
| 894 | |||
| 895 | |||
| 896 | public function getAddToCartXpath() |
||
| 900 | |||
| 901 | |||
| 902 | |||
| 903 | } |
||
| 904 |