Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,47 @@ env:
global:
- TEST_DAV=$(tests/travis/changed_app.sh dav)
- TC=litmus-v2
- SRV_HOST_NAME=owncloud
- SRV_HOST_PORT=8888
matrix:
- DB=sqlite

branches:
only:
- master
- /^stable\d+(\.\d+)?$/
- /^.*selenium.*$/

addons:
apt:
packages:
- realpath
hosts:
- owncloud
sauce_connect:
username: "individual-it"
jwt:
secure: "WaPqAVjcC6B4T5NWA1nffrywsnR9UZ5u3c2DrNLDR12cXJti0SbxGcE2Er8EGS1iCMxqMnpZfchbCelYmew5FOyeErqMTtni3lZ1gAu4KM35V5gUaRau8uEvTZk7AVHfDRSYlB/TJJV8sl8I33i3UvzUgsz4Il41X8qribycQOWoUCsiABIy/Fm05MhWugKjzBJ3Au/ZnNkYEjLW5z1cPymiuvNsUGvm9ushu2WwEc31hsS9lvpOcNVgdPJy2OaxNIZip8yH0c9gteo6rE7oElc81773K4QFf/0H0pD7Q4lUhqdHTn/aNyqWu8QaiS2BtygFKR15vxqbkloPQovM7S/Xr+PV7wQxItLE/E0QD8FkvIjoIVC4L448Mw+zBntpdGtmV4/UJJLl+VRFlLf5l2Do5fum1SeLI0kYaaN9rTXsFp/rmC7vT6dk3CiAm9owD69uWTVUecTqx2gRgNRdEXvL7t/6AZ8kspmWYdL9ekBSQ83rXlo7p8ZZm/Iu4k10JPCKxGfxVHFLVlPB6Z43+yBAtNjLkPdDP3+2FxU4LvvDKKXn2eESwkG2Mq5dEm4HAethygPJ48QmTYGPgg4b6PlcxWHoiC7qGZYWYj0Pmxt3kE6iZ4wxHG4cCU5p0/2MyGXzynjLz1qC6CZtXZbuyXDfrjvwcPXvvuANg0IX3hw="

before_install:
- make
- sh -c "if [ '$TEST_DAV' = '1' ]; then bash tests/travis/before_install.sh $DB; fi"
- if [ ! -z "$SAUCE_USERNAME" ] && [ ! -z "$SAUCE_ACCESS_KEY" ]; then export TEST_SELENIUM=1 ; else export TEST_SELENIUM=0 ; fi
- sh -c "if [ '$TEST_DAV' = '1' ] || [ '$TEST_SELENIUM' = '1' ]; then bash tests/travis/before_install.sh $DB; fi"

install:
- sh -c "if [ '$TEST_DAV' = '1' ]; then bash tests/travis/install.sh $DB; fi"
- sh -c "if [ '$TEST_DAV' = '1' ] || [ '$TEST_SELENIUM' = '1' ]; then bash tests/travis/install.sh $DB; fi"
- sh -c "if [ '$TEST_DAV' = '1' ]; then bash apps/dav/tests/travis/$TC/install.sh; fi"

before_script:
- sh -c "if [ '$TEST_SELENIUM' = '1' ]; then bash tests/travis/start_php_dev_server.sh; fi"

script:
- sh -c "if [ '$TC' = 'syntax' ]; then make test-php-lint ; fi"
- sh -c "if [ '$TEST_DAV' != '1' ]; then echo \"Not testing DAV\"; fi"
- sh -c "if [ '$TEST_DAV' = '1' ]; then echo \"Testing DAV\"; fi"

- sh -c "if [ '$TEST_DAV' = '1' ]; then bash apps/dav/tests/travis/$TC/script.sh; fi"
- sh -c "if [ '$TEST_SELENIUM' = '1' ]; then phpunit -c tests/phpunit-selenium-autotest.xml; fi"

matrix:
include:
Expand Down
44 changes: 44 additions & 0 deletions tests/Core/Frontend/LoginTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
/**
* ownCloud
*
* @author Artur Neumann
* @copyright 2017 Artur Neumann [email protected]
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/

use Test\SeleniumTestCase;

class LoginTest extends SeleniumTestCase {

public function testNormalLogin() {

$this->webDriver->get($this->rootURL);
$login = $this->webDriver->findElement ( WebDriverBy::id("user"));
$login->click();
$login->sendKeys("admin");

$login = $this->webDriver->findElement ( WebDriverBy::id("password"));
$login->click();
$login->sendKeys("admin");

$login = $this->webDriver->findElement ( WebDriverBy::id("submit"));
$login->click();
sleep(5);
$fileElement = $this->webDriver->findElement(WebDriverBy::xpath("//span[@class='innernametext']"));
$this->assertEquals($fileElement->getText(), "welcome");
}
}
1 change: 1 addition & 0 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
}

require_once __DIR__ . '/../lib/base.php';
require_once __DIR__ . '/vendor/facebook/webdriver/lib/__init__.php';

// especially with code coverage it will require some more time
set_time_limit(0);
Expand Down
98 changes: 98 additions & 0 deletions tests/lib/SeleniumTestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<?php
/**
* ownCloud
*
* @author Artur Neumann
* @copyright 2017 Artur Neumann [email protected]
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/

namespace Test;

use Test\TestCase;

abstract class SeleniumTestCase extends TestCase {
protected $webDriver;
protected $rootURL;

protected function setUp() {
parent::setUp();

$sauceUserName = getenv("SAUCE_USERNAME");
$sauceAccessKey = getenv("SAUCE_ACCESS_KEY");
$capabilities = array (
\WebDriverCapabilityType::BROWSER_NAME => 'chrome',
'tunnel-identifier' => getenv('TRAVIS_JOB_NUMBER')
);
$this->rootURL="http://". getenv('SRV_HOST_NAME') .":" . getenv('SRV_HOST_PORT'). "/" . getenv('SRV_HOST_URL');

if ($sauceAccessKey != "") {
$this->webDriver = \RemoteWebDriver::create ( 'http://'.$sauceUserName.':'.$sauceAccessKey.'@localhost:4445/wd/hub', $capabilities );
} else {
$this->webDriver = \RemoteWebDriver::create ( 'http://localhost:4444/wd/hub', $capabilities );
}

}

public static function setUpBeforeClass() {
$dataDir = \OC::$server->getConfig()->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data-autotest');
if (!file_exists($dataDir . "/admin")) {
mkdir($dataDir . "/admin");
mkdir($dataDir . "/admin/files");
copy(\OC::$SERVERROOT . '/core/skeleton/welcome.txt', $dataDir. "/admin/files/welcome.txt");
}
}

protected function tearDown() {
parent::tearDown();
$this->webDriver->quit ();
}

/**
* waits till an element is displayed on page
* @param WebDriverElement $element to wait for
* @param INT $timeout max. time to wait
*/
protected function waitTillElementIsDisplayed($element, $timeout = 30) {
for($counter = 0; $counter <= $timeout; $counter ++) {
try {
if ($element->isDisplayed () === false) {
break;
}
} catch ( Exception $e ) {
break;
}

sleep (1);
}
}

/**
* waits till an element is stale
* @param WebDriverElement $element to wait for
* @param INT $timeout max. time to wait
*/
protected function waitTillElementIsStale($element, $timeout = 30) {
for ($i=0; $i<=$timeout; $i++) {
try {
$element->findElements(\WebDriverBy::id("does-not-matter"));
} catch (StaleElementReferenceException $e) {
return true;
}
sleep(1);
}
}
}
21 changes: 21 additions & 0 deletions tests/phpunit-selenium-autotest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8" ?>
<phpunit bootstrap="bootstrap.php"
verbose="true"
timeoutForSmallTests="900"
timeoutForMediumTests="900"
timeoutForLargeTests="900"
>
<testsuite name='ownCloud'>
<directory suffix='.php'>Core/Frontend</directory>
</testsuite>
<!-- filters for code coverage -->
<filter>
<!-- whitelist processUncoveredFilesFromWhitelist="true" -->
<whitelist>
<directory suffix=".php">..</directory>
</whitelist>
</filter>
<listeners>
<listener class="StartSessionListener" file="startsessionlistener.php" />
</listeners>
</phpunit>
20 changes: 20 additions & 0 deletions tests/travis/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ cat > ./tests/autoconfig-sqlite.php <<DELIM
<?php
\$AUTOCONFIG = array (
'installed' => false,
'trusted_domains' =>
array (
0 => 'localhost',
1 => '$SRV_HOST_NAME',
),
'dbtype' => 'sqlite',
'dbtableprefix' => 'oc_',
'adminlogin' => '$ADMINLOGIN',
Expand All @@ -57,6 +62,11 @@ cat > ./tests/autoconfig-mysql.php <<DELIM
<?php
\$AUTOCONFIG = array (
'installed' => false,
'trusted_domains' =>
array (
0 => 'localhost',
1 => '$SRV_HOST_NAME',
),
'dbtype' => 'mysql',
'dbtableprefix' => 'oc_',
'adminlogin' => '$ADMINLOGIN',
Expand All @@ -73,6 +83,11 @@ cat > ./tests/autoconfig-pgsql.php <<DELIM
<?php
\$AUTOCONFIG = array (
'installed' => false,
'trusted_domains' =>
array (
0 => 'localhost',
1 => '$SRV_HOST_NAME',
),
'dbtype' => 'pgsql',
'dbtableprefix' => 'oc_',
'adminlogin' => '$ADMINLOGIN',
Expand All @@ -89,6 +104,11 @@ cat > ./tests/autoconfig-oracle.php <<DELIM
<?php
\$AUTOCONFIG = array (
'installed' => false,
'trusted_domains' =>
array (
0 => 'localhost',
1 => '$SRV_HOST_NAME',
),
'dbtype' => 'oci',
'dbtableprefix' => 'oc_',
'adminlogin' => '$ADMINLOGIN',
Expand Down
12 changes: 12 additions & 0 deletions tests/travis/start_php_dev_server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
#
# ownCloud
#
# @author Artur Neumann
# @copyright 2017 Artur Neumann [email protected]
#


set -e

php -S $SRV_HOST_NAME:$SRV_HOST_PORT > /dev/null 2>&1 &
105 changes: 105 additions & 0 deletions tests/vendor/facebook/webdriver/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
php-webdriver -- WebDriver bindings for PHP
===========================================

## DESCRIPTION

This WebDriver client aims to be as close as possible to bindings in other languages. The concepts are very similar to the Java, .NET, Python and Ruby bindings for WebDriver.

Looking for documentation about php-webdriver? See http://facebook.github.io/php-webdriver/

The PHP client was rewritten from scratch. Using the old version? Check out Adam Goucher's fork of it at https://github.com/Element-34/php-webdriver

Any complaint, question, idea? You can post it on the user group https://www.facebook.com/groups/phpwebdriver/.

## GETTING THE CODE

### Github
git clone [email protected]:facebook/php-webdriver.git

### Packagist
Add the dependency. https://packagist.org/packages/facebook/webdriver

{
"require": {
"facebook/webdriver": "dev-master"
}
}

Download the composer.phar

curl -sS https://getcomposer.org/installer | php

Install the library.

php composer.phar install



## GETTING STARTED

* All you need as the server for this client is the selenium-server-standalone-#.jar file provided here: http://selenium-release.storage.googleapis.com/index.html

* Download and run that file, replacing # with the current server version.

java -jar selenium-server-standalone-#.jar

* Then when you create a session, be sure to pass the url to where your server is running.

// This would be the url of the host running the server-standalone.jar
$host = 'http://localhost:4444/wd/hub'; // this is the default

* Launch Firefox

$driver = RemoteWebDriver::create($host, DesiredCapabilities::firefox());

* Launch Chrome

$driver = RemoteWebDriver::create($host, DesiredCapabilities::chrome());

* You can also customize the desired capabilities.

$desired_capabilities = DesiredCapabilities::firefox();
$desired_capabilities->setJavascriptEnabled(false);
RemoteWebDriver::create($host, $desired_capabilities);

* See https://code.google.com/p/selenium/wiki/DesiredCapabilities for more details.

## RUN UNIT TESTS

To run unit tests simply run:

./vendor/bin/phpunit -c ./tests

Note: For the functional test suite, a running selenium server is required.

## MORE INFORMATION

Check out the Selenium docs and wiki at http://docs.seleniumhq.org/docs/ and https://code.google.com/p/selenium/wiki

Learn how to integrate it with PHPUnit [Blogpost](http://codeception.com/11-12-2013/working-with-phpunit-and-selenium-webdriver.html) | [Demo Project](https://github.com/DavertMik/php-webdriver-demo)

## SUPPORT

We have a great community willing to try and help you!

Currently we offer support in two manners:

### Via our Facebook Group

If you have questions or are an active contributor consider joining our facebook group and contributing to the communal discussion and support

https://www.facebook.com/groups/phpwebdriver/

### Via Github

If you're reading this you've already found our Github repository. If you have a question, feel free to submit it as an issue and our staff will do their best to help you as soon as possible.

## CONTRIBUTING

We love to have your help to make php-webdriver better. Feel free to

* open an [issue](https://github.com/facebook/php-webdriver/issues) if you run into any problem.
* fork the project and submit [pull request](https://github.com/facebook/php-webdriver/pulls). Before the pull requests can be accepted, a [Contributors Licensing Agreement](http://developers.facebook.com/opensource/cla) must be signed.

When you are going to contribute, please keep in mind that this webdriver client aims to be as close as possible to other languages Java/Ruby/Python/C#.
FYI, here is the overview of [the official Java API](http://selenium.googlecode.com/svn/trunk/docs/api/java/index.html?overview-summary.html)
Loading