Commit 769a1a11 authored by Dominik Hebeler's avatar Dominik Hebeler

Resolve "Integrate automated testing"

parent 9795ccc1
......@@ -3,7 +3,7 @@ APP_DEBUG=true
APP_LOG_LEVEL=debug
LOG_CHANNEL=stderr
APP_KEY=
APP_URL=http://localhost
APP_URL=http://nginx
BOT_PROTECTION=true
......@@ -37,3 +37,7 @@ MAIL_ENCRYPTION=null
PUSHER_APP_ID=
PUSHER_KEY=
PUSHER_SECRET=
PROJECT_NAME=MetaGer
BRANCH_NAME=Local
COMMIT_NAME=Testing
\ No newline at end of file
......@@ -30,6 +30,7 @@ stages:
- incremental rollout 50%
- incremental rollout 100%
- performance
- integrationtest
- cleanup
......@@ -129,7 +130,7 @@ prepare_composer:
stage: prepare
image: prooph/composer:7.3
script:
- composer install
- composer install --no-dev
artifacts:
paths:
- vendor
......@@ -201,3 +202,18 @@ production:
ROLLOUT_RESOURCE_TYPE: deployment
environment:
url: https://metager.de
integrationtest:
stage: integrationtest
image:
name: prooph/composer:7.3
entrypoint: ["/bin/sh"]
script:
# Install Dev Dependencies
- composer install
- URL=$(cat environment_url.txt | tr -d '\n')
- sed -i "s#^APP_URL=.*#APP_URL=$URL#g" .env
- sed -i "s#^BRANCH_NAME=.*#BRANCH_NAME=$CI_COMMIT_REF_NAME#g" .env
- sed -i "s#^COMMIT_NAME=.*#COMMIT_NAME=$CI_COMMIT_REF_SLUG#g" .env
- ./vendor/phpunit/phpunit/phpunit
<?php
namespace App;
use BrowserStack\Local;
use Facebook\WebDriver\Remote\RemoteWebDriver;
class Browserstack
{
private $webdriver, $bs_local = null;
private $LOCALCAPABILITIES = array();
private $CAPABILITIES = array();
public function __construct()
{
$this->setCapabilities();
$caps = null;
if ($this->isLocal()) {
$caps = $this->LOCALCAPABILITIES;
$this->bs_local = new Local();
$bs_local_args = array("key" => env("WEBDRIVER_KEY", ""));
$this->bs_local->start($bs_local_args);
} else {
$caps = $this->CAPABILITIES;
}
$this->webdriver = RemoteWebDriver::create(
getenv("WEBDRIVER_URL"),
$caps
);
}
private function setCapabilities()
{
$this->LOCALCAPABILITIES = array(
"os" => "Windows",
"os_version" => "10",
"browser" => "Firefox",
"browser_version" => "79.0 beta",
"resolution" => "1920x1080",
"project" => env("PROJECT_NAME", "Not Set"),
"build" => env("BRANCH_NAME", "Not Set"),
"name" => env("COMMIT_NAME", "Not Set"),
"browserstack.local" => "true",
"browserstack.console" => "verbose",
"browserstack.networkLogs" => "true",
"browserstack.timezone" => "Europe/Berlin",
"browserstack.selenium_version" => "3.5.2",
);
$this->CAPABILITIES = array(
"os" => "Windows",
"os_version" => "10",
"browser" => "Firefox",
"browser_version" => "79.0 beta",
"resolution" => "1920x1080",
"project" => env("PROJECT_NAME", "Not Set"),
"build" => env("BRANCH_NAME", "Not Set"),
"name" => env("COMMIT_NAME", "Not Set"),
"browserstack.local" => "false",
"browserstack.console" => "verbose",
"browserstack.networkLogs" => "true",
"browserstack.timezone" => "Europe/Berlin",
"browserstack.selenium_version" => "3.5.2",
);
}
public function getWebdriver()
{
return $this->webdriver;
}
public function shutdown()
{
$this->webdriver->quit();
if ($this->bs_local != null) {
$this->bs_local->stop();
}
}
private function isLocal()
{
return env("APP_URL", "") === "http://nginx";
}
}
......@@ -68,3 +68,11 @@ services:
volumes:
- .:/html
command: "su -s /bin/sh -c 'php artisan requests:fetcher' nginx"
test:
depends_on:
- "phpfpm"
image: php:7.3-cli
working_dir: /html
volumes:
- .:/html
command: "./vendor/phpunit/phpunit/phpunit"
/bin/sh: 1: ps: not found
/bin/sh: 1: ps: not found
Thu Jul 09 2020 11:17:18 GMT+0000 (UTC) -- [INFO] Started the BrowserStack Binary server on 45691, PID: 22
Thu Jul 09 2020 11:17:19 GMT+0000 (UTC) -- [SUCCESS] You can now access your local server(s) in our remote browser
Thu Jul 09 2020 11:17:19 GMT+0000 (UTC) -- Press Ctrl-C to exit
......@@ -2,23 +2,27 @@
namespace Tests\Feature;
use Facebook\WebDriver\Remote\RemoteWebDriver;
use App\Browserstack;
use Facebook\WebDriver\WebDriverBy;
use Facebook\WebDriver\WebDriverExpectedCondition;
use Tests\TestCase;
class StaticPagesTest extends TestCase
{
private $caps = array(
"browser" => "Firefox",
"browser_version" => "67.0 beta",
"browserstack.local" => "true",
"os" => "Windows",
"os_version" => "10",
"resolution" => "1920x1080",
);
private $webdriver;
private $mgServer = "http://localhost:8005";
private $bs, $webdriver;
public function setUp(): void
{
parent::setUp();
$this->bs = new Browserstack();
$this->webdriver = $this->bs->getWebdriver();
}
public function tearDown(): void
{
parent::tearDown();
$this->bs->shutdown();
}
/**
* A basic feature test example.
*
......@@ -26,29 +30,16 @@ class StaticPagesTest extends TestCase
*/
public function testExample()
{
try {
$this->webdriver = RemoteWebDriver::create(
getenv("WEBDRIVER_URL"),
$this->caps
);
$this->startPageTest();
$this->navigationMenuTest();
} finally {
$this->webdriver->quit();
}
$this->startPageTest();
#$this->navigationMenuTest();
}
private function startPageTest()
{
$this->webdriver->get($this->mgServer);
$this->webdriver->get(env("APP_URL", ""));
# Test for Page Title
$this->assertEquals($this->webdriver->getTitle(), "MetaGer - Mehr als eine Suchmaschine");
# Test for Partner Links
$elements = $this->webdriver->findElements(WebDriverBy::cssSelector("#s .sr > a"));
$this->assertCount(2, $elements);
}
/**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment