@@ -63,4 +63,62 @@ public function chooseUpgradeOtherComponents()
63
63
$ this ->_rootElement ->find ("[for=yesUpdateComponents] " , Locator::SELECTOR_CSS )->click ();
64
64
$ this ->waitForElementVisible ("[ng-show='componentsProcessed'] " );
65
65
}
66
+
67
+ /**
68
+ * Set maximum compatible sample data for each row
69
+ *
70
+ * @param string $sampleDataVersion
71
+ * @return void
72
+ * @SuppressWarnings(PHPMD.UnusedLocalVariable)
73
+ */
74
+ public function chooseVersionUpgradeOtherComponents ($ sampleDataVersion )
75
+ {
76
+ $ perPageSelect = $ this ->_rootElement ->find (
77
+ "select#perPage " ,
78
+ Locator::SELECTOR_CSS ,
79
+ 'select '
80
+ );
81
+ $ fixtureVersion = $ sampleDataVersion ;
82
+ $ fixtureVersion = '100.0.* ' ;
83
+ $ perPageSelect ->setValue (200 );
84
+ sleep (1 );
85
+
86
+ $ elementsArray = $ this ->_rootElement ->getElements ("table.data-grid tbody tr " );
87
+
88
+ foreach ($ elementsArray as $ key => $ rowElement ) {
89
+ $ textElement = $ this ->_rootElement ->find (
90
+ "//table//tbody//tr[ " . ($ key + 1 ) . "]//td//*[contains(text(),'sample')] " ,
91
+ Locator::SELECTOR_XPATH
92
+ );
93
+ if (preg_match ('/magento.+sample.+data/ ' , $ textElement ->getText ())) {
94
+ $ selectElement = $ this ->_rootElement ->find (
95
+ '//table//tbody//tr[ ' . ($ key +1 ) . ']//td//select ' ,
96
+ Locator::SELECTOR_XPATH ,
97
+ 'select '
98
+ );
99
+
100
+ $ fixtureVersion = str_replace ('* ' , '[0-9]+ ' , $ fixtureVersion );
101
+ $ toSelectValue = $ selectElement ->getValue ();
102
+ $ toSelectValueOriginal = $ toSelectValue ;
103
+ $ toSelectVersion = '0 ' ;
104
+ foreach ($ selectElement ->getElements ('option ' ) as $ option ) {
105
+ $ optionText = $ option ->getText ();
106
+ if (preg_match ('/ ' . $ fixtureVersion .'/ ' , $ optionText )) {
107
+ if (preg_match ('/([0-9\.\-a-zA-Z]+)/ ' , $ optionText , $ match )) {
108
+ if (!empty ($ match ) > 0 ) {
109
+ if (version_compare ($ match [0 ], $ toSelectVersion , '> ' )) {
110
+ $ toSelectVersion = $ match [0 ];
111
+ $ toSelectValue = $ optionText ;
112
+ }
113
+ }
114
+ }
115
+ }
116
+ }
117
+
118
+ if ($ toSelectValue !== $ toSelectValueOriginal ) {
119
+ $ selectElement ->setValue ($ toSelectValue );
120
+ }
121
+ }
122
+ }
123
+ }
66
124
}
0 commit comments