| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * (c) FSi sp. z o.o. <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * For the full copyright and license information, please view the LICENSE | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * file that was distributed with this source code. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | declare(strict_types=1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | namespace FSi\Bundle\AdminBundle\Behat\Context; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use Behat\Gherkin\Node\TableNode; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | use FSi\Bundle\AdminBundle\Admin\AbstractElement; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use FSi\Bundle\AdminBundle\Admin\Element; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | use FSi\Bundle\AdminBundle\Admin\ManagerInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | use FSi\Bundle\AdminBundle\Behat\Page\AdminPanel; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | use FSi\Bundle\AdminBundle\Behat\Page\Page; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | class AdminContext extends AbstractContext | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |      * @var AdminPanel | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |     private $adminPanelPage; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |     public function __construct(AdminPanel $adminPanelPage) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |         $this->adminPanelPage = $adminPanelPage; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |      * @BeforeScenario | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |     public function resizeWindow() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |         if ($this->isSeleniumDriverUsed()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |             $this->getSession()->resizeWindow(1280, 1024); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |      * @Given /^the following admin elements were registered$/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |     public function theFollowingAdminElementsWereRegistered(TableNode $table) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |         foreach ($table->getHash() as $serviceRow) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |             $id = $serviceRow['Id']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |             $class = $serviceRow['Class']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |             expect($this->getAdminManager()->hasElement($id))->toBe(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |             expect($this->getAdminManager()->getElement($id))->toBeAnInstanceOf($class); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |             if (array_key_exists('Parent', $serviceRow) && !empty($serviceRow['Parent'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |                 expect($this->getAdminManager()->getElement($id)->getParentId())->toBe($serviceRow['Parent']); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |      * @Given /^("[^"]*" element) have following options defined$/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |     public function elementHaveFollowingOptionsDefined( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |         AbstractElement $adminElement, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |         TableNode $options | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |     ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |         foreach ($options->getHash() as $optionRow) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |             $option = $optionRow['Option']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |             $value = $optionRow['Value']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |             expect($adminElement->hasOption($option))->toBe(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |             expect($adminElement->getOption($option))->toBe($value); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |      * @Given /^there are following admin elements available$/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |     public function thereAreFollowingAdminElementsAvailable(TableNode $table) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |         foreach ($table->getHash() as $elementRow) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |             $id = $elementRow['Id']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |             $name = $elementRow['Name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |             expect($this->getAdminManager()->hasElement($id))->toBe(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |             expect($this->getAdminManager()->getElement($id)->getName())->toBe($name); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |      * @Then /^I should see "([^"]*)" title at top bar$/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |     public function iShouldSeeTitleAtTopBar($navbarBrandText) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |         expect($this->adminPanelPage->getNavbarBrandText())->toBe($navbarBrandText); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |      * @Given I should see :page page header :headerContent | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |     public function iShouldSeePageHeader(Page $page, $headerContent) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |         expect($page->getHeader())->toBe($headerContent); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |      * @Given /^translations are enabled in application$/ | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 105 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 106 |  |  |     public function translationsAreEnabledInApplication() | 
            
                                                                        
                            
            
                                    
            
            
                | 107 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 108 |  |  |         $translator = $this->getContainer()->get('translator'); | 
            
                                                                        
                            
            
                                    
            
            
                | 109 |  |  |         expect($translator)->toBeAnInstanceOf('Symfony\Component\Translation\TranslatorInterface'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 110 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |      * @Then /^I should see language dropdown button in navigation bar with text "([^"]*)"$/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |      * @Then /^I should see language dropdown button with text "([^"]*)"$/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |     public function iShouldSeeLanguageDropdownButtonInNavigationBarWithText($button) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |         expect($this->adminPanelPage->getLanguageDropdown()->hasLink($button))->toBe(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |      * @Given /^language dropdown button should have following links$/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |     public function languageDropdownButtonShouldHaveFollowingLinks(TableNode $dropdownLinks) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |         $links = $this->adminPanelPage->getLanguageDropdownOptions(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |         foreach ($dropdownLinks->getHash() as $link) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |             expect($links)->toContain($link['Link']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |      * @When /^I click "([^"]*)" link from language dropdown button$/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |     public function iClickLinkFromLanguageDropdownButton($link) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |         $this->adminPanelPage->getLanguageDropdown()->clickLink($link); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |      * @Transform /^"([^"]*)" element/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |     public function transformListNameToAdminElement(string $id): Element | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |         return $this->getAdminManager()->getElement($id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |      * @Transform /^(\d+)/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |     public function castStringToNumber(string $number): int | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |         return (int) $number; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |      * @Transform /^first|second|third$/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |     public function castWordToNumber(string $word): int | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |         switch ($word) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |             case 'first': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |                 return 1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |             case 'second': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |                 return 2; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |             case 'third': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |                 return 3; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |     private function getAdminManager(): ManagerInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |         return $this->getContainer()->get('test.admin.manager'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 176 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 177 |  |  |  | 
            
                        
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.