This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
1 | <?php |
||
2 | /** |
||
3 | * Base test class. |
||
4 | * |
||
5 | * @package Tests |
||
6 | * |
||
7 | * @see https://github.com/php-webdriver/php-webdriver |
||
8 | * |
||
9 | * @copyright YetiForce S.A. |
||
10 | * @license YetiForce Public License 6.5 (licenses/LicenseEN.txt or yetiforce.com) |
||
11 | * @author Mariusz Krzaczkowski <[email protected]> |
||
12 | */ |
||
13 | |||
14 | namespace tests; |
||
15 | |||
16 | use Facebook\WebDriver\Remote\DesiredCapabilities; |
||
0 ignored issues
–
show
|
|||
17 | use Facebook\WebDriver\Remote\RemoteWebDriver; |
||
0 ignored issues
–
show
The type
Facebook\WebDriver\Remote\RemoteWebDriver was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
18 | use Facebook\WebDriver\WebDriverBy; |
||
0 ignored issues
–
show
The type
Facebook\WebDriver\WebDriverBy was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
19 | use PHPUnit\Framework\TestCase; |
||
0 ignored issues
–
show
The type
PHPUnit\Framework\TestCase was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
20 | |||
21 | abstract class GuiBase extends TestCase |
||
22 | { |
||
23 | /** @var mixed Last logs. */ |
||
24 | public $logs; |
||
25 | |||
26 | /** @var \Facebook\WebDriver\Remote\RemoteWebDriver Web driver. */ |
||
27 | protected $driver; |
||
28 | |||
29 | /** @var bool Is login */ |
||
30 | protected $isLogin = false; |
||
31 | |||
32 | /** |
||
33 | * Not success test. |
||
34 | * |
||
35 | * @codeCoverageIgnore |
||
36 | * |
||
37 | * @param \Throwable $t |
||
38 | * |
||
39 | * @return void |
||
40 | */ |
||
41 | protected function onNotSuccessfulTest(\Throwable $t): void |
||
42 | { |
||
43 | if (isset($this->logs)) { |
||
44 | echo "\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ LOGS:\n"; |
||
45 | \print_r($this->logs); |
||
46 | \print_r($t); |
||
47 | file_put_contents(ROOT_DIRECTORY . '/cache/logs/selenium_logs.log', print_r($this->logs, true)); |
||
48 | } |
||
49 | echo "\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"; |
||
50 | print_r($t->__toString()); |
||
51 | echo "\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"; |
||
52 | if (null !== $this->driver) { |
||
53 | file_put_contents(ROOT_DIRECTORY . '/cache/logs/selenium_source.html', $this->driver->getPageSource()); |
||
54 | echo 'URL: '; |
||
55 | $this->driver->getCurrentURL(); |
||
56 | echo PHP_EOL; |
||
57 | echo 'Title: '; |
||
58 | $this->driver->getTitle(); |
||
59 | echo PHP_EOL; |
||
60 | echo 'Browser logs: '; |
||
61 | print_r($this->driver->manage()->getLog('browser')); |
||
62 | $this->driver->takeScreenshot(ROOT_DIRECTORY . '/cache/logs/selenium_screenshot.png'); |
||
63 | } else { |
||
64 | echo 'No $this->driver'; |
||
65 | } |
||
66 | echo "\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"; |
||
67 | throw $t; |
||
68 | } |
||
69 | |||
70 | /** |
||
71 | * Setup test. |
||
72 | * |
||
73 | * @return void |
||
74 | */ |
||
75 | protected function setUp(): void |
||
76 | { |
||
77 | parent::setUp(); |
||
78 | if (empty($this->driver)) { |
||
79 | $capabilities = DesiredCapabilities::chrome(); |
||
80 | $capabilities->setCapability('chromeOptions', ['args' => ['headless', 'disable-dev-shm-usage', 'no-sandbox']]); |
||
81 | $this->driver = RemoteWebDriver::create('http://localhost:4444/wd/hub', $capabilities, 60000, 60000); |
||
82 | } |
||
83 | if (!$this->isLogin) { |
||
84 | $this->login(); |
||
85 | } |
||
86 | } |
||
87 | |||
88 | /** |
||
89 | * Go to URL. |
||
90 | * |
||
91 | * @param string $url |
||
92 | * |
||
93 | * @throws \ReflectionException |
||
94 | * |
||
95 | * @return void |
||
96 | */ |
||
97 | public function url(string $url): void |
||
98 | { |
||
99 | $this->driver->get(\App\Config::main('site_URL') . $url); |
||
100 | } |
||
101 | |||
102 | /** |
||
103 | * Testing login page display. |
||
104 | * |
||
105 | * @return void |
||
106 | */ |
||
107 | public function login(): void |
||
108 | { |
||
109 | $this->driver->get(\App\Config::main('site_URL') . 'index.php?module=Users&view=Login'); |
||
110 | $this->logs = [ |
||
111 | 'test' => __METHOD__, |
||
112 | 'url' => $this->driver->getCurrentURL(), |
||
113 | 'getPageSource' => $this->driver->getPageSource(), |
||
114 | ]; |
||
115 | $this->driver->findElement(WebDriverBy::id('username'))->sendKeys('demo'); |
||
116 | $this->driver->findElement(WebDriverBy::id('password'))->sendKeys(\Tests\Base\A_User::$defaultPassrowd); |
||
117 | $this->driver->findElement(WebDriverBy::tagName('form'))->submit(); |
||
118 | $this->isLogin = true; |
||
119 | } |
||
120 | |||
121 | /** |
||
122 | * Find error or exceptions. |
||
123 | * |
||
124 | * @return void |
||
125 | */ |
||
126 | public function findError(): void |
||
127 | { |
||
128 | $source = $this->driver->getPageSource(); |
||
129 | if (false !== stripos($source, 'YetiError!!!')) { |
||
130 | // @codeCoverageIgnoreStart |
||
131 | throw new \Exception('An error has been found'); |
||
132 | // @codeCoverageIgnoreEnd |
||
133 | } |
||
134 | if (false !== stripos($source, 'YetiForceError!!!')) { |
||
135 | // @codeCoverageIgnoreStart |
||
136 | throw new \Exception('An error has been found'); |
||
137 | // @codeCoverageIgnoreEnd |
||
138 | } |
||
139 | if (false !== stripos($source, 'Undefined variable:')) { |
||
140 | // @codeCoverageIgnoreStart |
||
141 | throw new \Exception('Undefined variable found'); |
||
142 | // @codeCoverageIgnoreEnd |
||
143 | } |
||
144 | $browserLogs = $this->driver->manage()->getLog('browser'); |
||
145 | if ($browserLogs) { |
||
146 | /** @codeCoverageIgnoreStart */ |
||
147 | $log = ''; |
||
148 | foreach ($browserLogs as $value) { |
||
149 | if ('SEVERE' === $value['level']) { |
||
150 | $log .= "[{$value['level']}] {$value['message']}\n"; |
||
151 | } |
||
152 | } |
||
153 | if ($log) { |
||
154 | throw new \Exception('A JavaScript error has occurred: ' . PHP_EOL . $log); |
||
155 | } |
||
156 | // @codeCoverageIgnoreEnd |
||
157 | } |
||
158 | $this->logs = [ |
||
159 | 'test' => __METHOD__, |
||
160 | 'url' => $this->driver->getCurrentURL(), |
||
161 | 'getPageSource' => $source, |
||
162 | ]; |
||
163 | } |
||
164 | } |
||
165 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths