Laravel version update

Laravel version update
This commit is contained in:
Manish Verma
2018-08-06 18:48:58 +05:30
parent d143048413
commit 126fbb0255
13678 changed files with 1031482 additions and 778530 deletions

View File

@@ -0,0 +1,417 @@
<?php
// Copyright 2004-present Facebook. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
namespace Facebook\WebDriver\Support\Events;
use Facebook\WebDriver\Exception\UnsupportedOperationException;
use Facebook\WebDriver\Exception\WebDriverException;
use Facebook\WebDriver\Interactions\Touch\WebDriverTouchScreen;
use Facebook\WebDriver\JavaScriptExecutor;
use Facebook\WebDriver\WebDriver;
use Facebook\WebDriver\WebDriverBy;
use Facebook\WebDriver\WebDriverDispatcher;
use Facebook\WebDriver\WebDriverElement;
use Facebook\WebDriver\WebDriverOptions;
use Facebook\WebDriver\WebDriverTargetLocator;
use Facebook\WebDriver\WebDriverWait;
class EventFiringWebDriver implements WebDriver, JavaScriptExecutor
{
/**
* @var WebDriver
*/
protected $driver;
/**
* @var WebDriverDispatcher
*/
protected $dispatcher;
/**
* @param WebDriver $driver
* @param WebDriverDispatcher $dispatcher
*/
public function __construct(WebDriver $driver, WebDriverDispatcher $dispatcher = null)
{
$this->dispatcher = $dispatcher ?: new WebDriverDispatcher();
if (!$this->dispatcher->getDefaultDriver()) {
$this->dispatcher->setDefaultDriver($this);
}
$this->driver = $driver;
}
/**
* @return WebDriverDispatcher
*/
public function getDispatcher()
{
return $this->dispatcher;
}
/**
* @return WebDriver
*/
public function getWebDriver()
{
return $this->driver;
}
/**
* @param mixed $url
* @throws WebDriverException
* @return $this
*/
public function get($url)
{
$this->dispatch('beforeNavigateTo', $url, $this);
try {
$this->driver->get($url);
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
throw $exception;
}
$this->dispatch('afterNavigateTo', $url, $this);
return $this;
}
/**
* @param WebDriverBy $by
* @throws WebDriverException
* @return array
*/
public function findElements(WebDriverBy $by)
{
$this->dispatch('beforeFindBy', $by, null, $this);
$elements = [];
try {
foreach ($this->driver->findElements($by) as $element) {
$elements[] = $this->newElement($element);
}
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
throw $exception;
}
$this->dispatch('afterFindBy', $by, null, $this);
return $elements;
}
/**
* @param WebDriverBy $by
* @throws WebDriverException
* @return EventFiringWebElement
*/
public function findElement(WebDriverBy $by)
{
$this->dispatch('beforeFindBy', $by, null, $this);
try {
$element = $this->newElement($this->driver->findElement($by));
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
throw $exception;
}
$this->dispatch('afterFindBy', $by, null, $this);
return $element;
}
/**
* @param string $script
* @param array $arguments
* @throws WebDriverException
* @return mixed
*/
public function executeScript($script, array $arguments = [])
{
if (!$this->driver instanceof JavaScriptExecutor) {
throw new UnsupportedOperationException(
'driver does not implement JavaScriptExecutor'
);
}
$this->dispatch('beforeScript', $script, $this);
try {
$result = $this->driver->executeScript($script, $arguments);
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
throw $exception;
}
$this->dispatch('afterScript', $script, $this);
return $result;
}
/**
* @param string $script
* @param array $arguments
* @throws WebDriverException
* @return mixed
*/
public function executeAsyncScript($script, array $arguments = [])
{
if (!$this->driver instanceof JavaScriptExecutor) {
throw new UnsupportedOperationException(
'driver does not implement JavaScriptExecutor'
);
}
$this->dispatch('beforeScript', $script, $this);
try {
$result = $this->driver->executeAsyncScript($script, $arguments);
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
throw $exception;
}
$this->dispatch('afterScript', $script, $this);
return $result;
}
/**
* @throws WebDriverException
* @return $this
*/
public function close()
{
try {
$this->driver->close();
return $this;
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
throw $exception;
}
}
/**
* @throws WebDriverException
* @return string
*/
public function getCurrentURL()
{
try {
return $this->driver->getCurrentURL();
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
throw $exception;
}
}
/**
* @throws WebDriverException
* @return string
*/
public function getPageSource()
{
try {
return $this->driver->getPageSource();
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
throw $exception;
}
}
/**
* @throws WebDriverException
* @return string
*/
public function getTitle()
{
try {
return $this->driver->getTitle();
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
throw $exception;
}
}
/**
* @throws WebDriverException
* @return string
*/
public function getWindowHandle()
{
try {
return $this->driver->getWindowHandle();
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
throw $exception;
}
}
/**
* @throws WebDriverException
* @return array
*/
public function getWindowHandles()
{
try {
return $this->driver->getWindowHandles();
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
throw $exception;
}
}
/**
* @throws WebDriverException
*/
public function quit()
{
try {
$this->driver->quit();
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
throw $exception;
}
}
/**
* @param null|string $save_as
* @throws WebDriverException
* @return string
*/
public function takeScreenshot($save_as = null)
{
try {
return $this->driver->takeScreenshot($save_as);
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
throw $exception;
}
}
/**
* @param int $timeout_in_second
* @param int $interval_in_millisecond
* @throws WebDriverException
* @return WebDriverWait
*/
public function wait($timeout_in_second = 30, $interval_in_millisecond = 250)
{
try {
return $this->driver->wait($timeout_in_second, $interval_in_millisecond);
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
throw $exception;
}
}
/**
* @throws WebDriverException
* @return WebDriverOptions
*/
public function manage()
{
try {
return $this->driver->manage();
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
throw $exception;
}
}
/**
* @throws WebDriverException
* @return EventFiringWebDriverNavigation
*/
public function navigate()
{
try {
return new EventFiringWebDriverNavigation(
$this->driver->navigate(),
$this->getDispatcher()
);
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
throw $exception;
}
}
/**
* @throws WebDriverException
* @return WebDriverTargetLocator
*/
public function switchTo()
{
try {
return $this->driver->switchTo();
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
throw $exception;
}
}
/**
* @throws WebDriverException
* @return WebDriverTouchScreen
*/
public function getTouch()
{
try {
return $this->driver->getTouch();
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
throw $exception;
}
}
public function execute($name, $params)
{
try {
return $this->driver->execute($name, $params);
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
throw $exception;
}
}
/**
* @param WebDriverElement $element
* @return EventFiringWebElement
*/
protected function newElement(WebDriverElement $element)
{
return new EventFiringWebElement($element, $this->getDispatcher());
}
/**
* @param mixed $method
* @param mixed ...$arguments
*/
protected function dispatch($method, ...$arguments)
{
if (!$this->dispatcher) {
return;
}
$this->dispatcher->dispatch($method, $arguments);
}
/**
* @param WebDriverException $exception
*/
protected function dispatchOnException(WebDriverException $exception)
{
$this->dispatch('onException', $exception, $this);
}
}

View File

@@ -0,0 +1,170 @@
<?php
// Copyright 2004-present Facebook. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
namespace Facebook\WebDriver\Support\Events;
use Facebook\WebDriver\Exception\WebDriverException;
use Facebook\WebDriver\WebDriverDispatcher;
use Facebook\WebDriver\WebDriverNavigation;
class EventFiringWebDriverNavigation
{
/**
* @var WebDriverNavigation
*/
protected $navigator;
/**
* @var WebDriverDispatcher
*/
protected $dispatcher;
/**
* @param WebDriverNavigation $navigator
* @param WebDriverDispatcher $dispatcher
*/
public function __construct(WebDriverNavigation $navigator, WebDriverDispatcher $dispatcher)
{
$this->navigator = $navigator;
$this->dispatcher = $dispatcher;
}
/**
* @return WebDriverDispatcher
*/
public function getDispatcher()
{
return $this->dispatcher;
}
/**
* @return WebDriverNavigation
*/
public function getNavigator()
{
return $this->navigator;
}
/**
* @throws WebDriverException
* @return $this
*/
public function back()
{
$this->dispatch(
'beforeNavigateBack',
$this->getDispatcher()->getDefaultDriver()
);
try {
$this->navigator->back();
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
}
$this->dispatch(
'afterNavigateBack',
$this->getDispatcher()->getDefaultDriver()
);
return $this;
}
/**
* @throws WebDriverException
* @return $this
*/
public function forward()
{
$this->dispatch(
'beforeNavigateForward',
$this->getDispatcher()->getDefaultDriver()
);
try {
$this->navigator->forward();
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
}
$this->dispatch(
'afterNavigateForward',
$this->getDispatcher()->getDefaultDriver()
);
return $this;
}
/**
* @throws WebDriverException
* @return $this
*/
public function refresh()
{
try {
$this->navigator->refresh();
return $this;
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
throw $exception;
}
}
/**
* @param mixed $url
* @throws WebDriverException
* @return $this
*/
public function to($url)
{
$this->dispatch(
'beforeNavigateTo',
$url,
$this->getDispatcher()->getDefaultDriver()
);
try {
$this->navigator->to($url);
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
throw $exception;
}
$this->dispatch(
'afterNavigateTo',
$url,
$this->getDispatcher()->getDefaultDriver()
);
return $this;
}
/**
* @param mixed $method
* @param mixed ...$arguments
*/
protected function dispatch($method, ...$arguments)
{
if (!$this->dispatcher) {
return;
}
$this->dispatcher->dispatch($method, $arguments);
}
/**
* @param WebDriverException $exception
*/
protected function dispatchOnException(WebDriverException $exception)
{
$this->dispatch('onException', $exception);
}
}

View File

@@ -0,0 +1,414 @@
<?php
// Copyright 2004-present Facebook. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
namespace Facebook\WebDriver\Support\Events;
use Facebook\WebDriver\Exception\WebDriverException;
use Facebook\WebDriver\Interactions\Internal\WebDriverCoordinates;
use Facebook\WebDriver\Internal\WebDriverLocatable;
use Facebook\WebDriver\WebDriverBy;
use Facebook\WebDriver\WebDriverDimension;
use Facebook\WebDriver\WebDriverDispatcher;
use Facebook\WebDriver\WebDriverElement;
use Facebook\WebDriver\WebDriverPoint;
class EventFiringWebElement implements WebDriverElement, WebDriverLocatable
{
/**
* @var WebDriverElement
*/
protected $element;
/**
* @var WebDriverDispatcher
*/
protected $dispatcher;
/**
* @param WebDriverElement $element
* @param WebDriverDispatcher $dispatcher
*/
public function __construct(WebDriverElement $element, WebDriverDispatcher $dispatcher)
{
$this->element = $element;
$this->dispatcher = $dispatcher;
}
/**
* @return WebDriverDispatcher
*/
public function getDispatcher()
{
return $this->dispatcher;
}
/**
* @return WebDriverElement
*/
public function getElement()
{
return $this->element;
}
/**
* @param mixed $value
* @throws WebDriverException
* @return $this
*/
public function sendKeys($value)
{
$this->dispatch('beforeChangeValueOf', $this);
try {
$this->element->sendKeys($value);
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
throw $exception;
}
$this->dispatch('afterChangeValueOf', $this);
return $this;
}
/**
* @throws WebDriverException
* @return $this
*/
public function click()
{
$this->dispatch('beforeClickOn', $this);
try {
$this->element->click();
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
throw $exception;
}
$this->dispatch('afterClickOn', $this);
return $this;
}
/**
* @param WebDriverBy $by
* @throws WebDriverException
* @return EventFiringWebElement
*/
public function findElement(WebDriverBy $by)
{
$this->dispatch(
'beforeFindBy',
$by,
$this,
$this->dispatcher->getDefaultDriver()
);
try {
$element = $this->newElement($this->element->findElement($by));
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
throw $exception;
}
$this->dispatch(
'afterFindBy',
$by,
$this,
$this->dispatcher->getDefaultDriver()
);
return $element;
}
/**
* @param WebDriverBy $by
* @throws WebDriverException
* @return array
*/
public function findElements(WebDriverBy $by)
{
$this->dispatch(
'beforeFindBy',
$by,
$this,
$this->dispatcher->getDefaultDriver()
);
try {
$elements = [];
foreach ($this->element->findElements($by) as $element) {
$elements[] = $this->newElement($element);
}
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
throw $exception;
}
$this->dispatch(
'afterFindBy',
$by,
$this,
$this->dispatcher->getDefaultDriver()
);
return $elements;
}
/**
* @throws WebDriverException
* @return $this
*/
public function clear()
{
try {
$this->element->clear();
return $this;
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
throw $exception;
}
}
/**
* @param string $attribute_name
* @throws WebDriverException
* @return string
*/
public function getAttribute($attribute_name)
{
try {
return $this->element->getAttribute($attribute_name);
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
throw $exception;
}
}
/**
* @param string $css_property_name
* @throws WebDriverException
* @return string
*/
public function getCSSValue($css_property_name)
{
try {
return $this->element->getCSSValue($css_property_name);
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
throw $exception;
}
}
/**
* @throws WebDriverException
* @return WebDriverPoint
*/
public function getLocation()
{
try {
return $this->element->getLocation();
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
throw $exception;
}
}
/**
* @throws WebDriverException
* @return WebDriverPoint
*/
public function getLocationOnScreenOnceScrolledIntoView()
{
try {
return $this->element->getLocationOnScreenOnceScrolledIntoView();
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
throw $exception;
}
}
/**
* @return WebDriverCoordinates
*/
public function getCoordinates()
{
try {
return $this->element->getCoordinates();
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
throw $exception;
}
}
/**
* @throws WebDriverException
* @return WebDriverDimension
*/
public function getSize()
{
try {
return $this->element->getSize();
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
throw $exception;
}
}
/**
* @throws WebDriverException
* @return string
*/
public function getTagName()
{
try {
return $this->element->getTagName();
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
throw $exception;
}
}
/**
* @throws WebDriverException
* @return string
*/
public function getText()
{
try {
return $this->element->getText();
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
throw $exception;
}
}
/**
* @throws WebDriverException
* @return bool
*/
public function isDisplayed()
{
try {
return $this->element->isDisplayed();
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
throw $exception;
}
}
/**
* @throws WebDriverException
* @return bool
*/
public function isEnabled()
{
try {
return $this->element->isEnabled();
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
throw $exception;
}
}
/**
* @throws WebDriverException
* @return bool
*/
public function isSelected()
{
try {
return $this->element->isSelected();
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
throw $exception;
}
}
/**
* @throws WebDriverException
* @return $this
*/
public function submit()
{
try {
$this->element->submit();
return $this;
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
throw $exception;
}
}
/**
* @throws WebDriverException
* @return string
*/
public function getID()
{
try {
return $this->element->getID();
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
throw $exception;
}
}
/**
* Test if two element IDs refer to the same DOM element.
*
* @param WebDriverElement $other
* @return bool
*/
public function equals(WebDriverElement $other)
{
try {
return $this->element->equals($other);
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
throw $exception;
}
}
/**
* @param WebDriverException $exception
*/
protected function dispatchOnException(WebDriverException $exception)
{
$this->dispatch(
'onException',
$exception,
$this->dispatcher->getDefaultDriver()
);
}
/**
* @param mixed $method
* @param mixed ...$arguments
*/
protected function dispatch($method, ...$arguments)
{
if (!$this->dispatcher) {
return;
}
$this->dispatcher->dispatch($method, $arguments);
}
/**
* @param WebDriverElement $element
* @return static
*/
protected function newElement(WebDriverElement $element)
{
return new static($element, $this->getDispatcher());
}
}

View File

@@ -0,0 +1,45 @@
<?php
// Copyright 2004-present Facebook. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
namespace Facebook\WebDriver\Support;
class XPathEscaper
{
/**
* Converts xpath strings with both quotes and ticks into:
* `foo'"bar` -> `concat('foo', "'" ,'"bar')`
*
* @param string $xpathToEscape The xpath to be converted.
* @return string The escaped string.
*/
public static function escapeQuotes($xpathToEscape)
{
// Single quotes not present => we can quote in them
if (mb_strpos($xpathToEscape, "'") === false) {
return sprintf("'%s'", $xpathToEscape);
}
// Double quotes not present => we can quote in them
if (mb_strpos($xpathToEscape, '"') === false) {
return sprintf('"%s"', $xpathToEscape);
}
// Both single and double quotes are present
return sprintf(
"concat('%s')",
str_replace("'", "', \"'\" ,'", $xpathToEscape)
);
}
}