Skip to content
Snippets Groups Projects
Commit 769a1a11 authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

Resolve "Integrate automated testing"

parent 9795ccc1
No related branches found
No related tags found
1 merge request!1627Development
...@@ -3,7 +3,7 @@ APP_DEBUG=true ...@@ -3,7 +3,7 @@ APP_DEBUG=true
APP_LOG_LEVEL=debug APP_LOG_LEVEL=debug
LOG_CHANNEL=stderr LOG_CHANNEL=stderr
APP_KEY= APP_KEY=
APP_URL=http://localhost APP_URL=http://nginx
BOT_PROTECTION=true BOT_PROTECTION=true
...@@ -37,3 +37,7 @@ MAIL_ENCRYPTION=null ...@@ -37,3 +37,7 @@ MAIL_ENCRYPTION=null
PUSHER_APP_ID= PUSHER_APP_ID=
PUSHER_KEY= PUSHER_KEY=
PUSHER_SECRET= PUSHER_SECRET=
PROJECT_NAME=MetaGer
BRANCH_NAME=Local
COMMIT_NAME=Testing
\ No newline at end of file
...@@ -30,6 +30,7 @@ stages: ...@@ -30,6 +30,7 @@ stages:
- incremental rollout 50% - incremental rollout 50%
- incremental rollout 100% - incremental rollout 100%
- performance - performance
- integrationtest
- cleanup - cleanup
...@@ -129,7 +130,7 @@ prepare_composer: ...@@ -129,7 +130,7 @@ prepare_composer:
stage: prepare stage: prepare
image: prooph/composer:7.3 image: prooph/composer:7.3
script: script:
- composer install - composer install --no-dev
artifacts: artifacts:
paths: paths:
- vendor - vendor
...@@ -201,3 +202,18 @@ production: ...@@ -201,3 +202,18 @@ production:
ROLLOUT_RESOURCE_TYPE: deployment ROLLOUT_RESOURCE_TYPE: deployment
environment: environment:
url: https://metager.de 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";
}
}
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
"php": "^7.1.3", "php": "^7.1.3",
"fideloper/proxy": "^4.0", "fideloper/proxy": "^4.0",
"laravel/tinker": "^1.0", "laravel/tinker": "^1.0",
"facebook/webdriver": "^1.6",
"globalcitizen/php-iban": "^2.6", "globalcitizen/php-iban": "^2.6",
"jenssegers/agent": "^2.6", "jenssegers/agent": "^2.6",
"mcamara/laravel-localization": "^1.3", "mcamara/laravel-localization": "^1.3",
...@@ -24,6 +23,8 @@ ...@@ -24,6 +23,8 @@
}, },
"require-dev": { "require-dev": {
"beyondcode/laravel-dump-server": "^1.0", "beyondcode/laravel-dump-server": "^1.0",
"php-webdriver/webdriver": "^1.6",
"browserstack/browserstack-local": "^1.1",
"filp/whoops": "^2.0", "filp/whoops": "^2.0",
"fzaninotto/faker": "^1.4", "fzaninotto/faker": "^1.4",
"mockery/mockery": "^1.0", "mockery/mockery": "^1.0",
......
...@@ -68,3 +68,11 @@ services: ...@@ -68,3 +68,11 @@ services:
volumes: volumes:
- .:/html - .:/html
command: "su -s /bin/sh -c 'php artisan requests:fetcher' nginx" 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 @@ ...@@ -2,23 +2,27 @@
namespace Tests\Feature; namespace Tests\Feature;
use Facebook\WebDriver\Remote\RemoteWebDriver; use App\Browserstack;
use Facebook\WebDriver\WebDriverBy; use Facebook\WebDriver\WebDriverBy;
use Facebook\WebDriver\WebDriverExpectedCondition; use Facebook\WebDriver\WebDriverExpectedCondition;
use Tests\TestCase; use Tests\TestCase;
class StaticPagesTest extends TestCase class StaticPagesTest extends TestCase
{ {
private $caps = array( private $bs, $webdriver;
"browser" => "Firefox",
"browser_version" => "67.0 beta", public function setUp(): void
"browserstack.local" => "true", {
"os" => "Windows", parent::setUp();
"os_version" => "10", $this->bs = new Browserstack();
"resolution" => "1920x1080", $this->webdriver = $this->bs->getWebdriver();
); }
private $webdriver;
private $mgServer = "http://localhost:8005"; public function tearDown(): void
{
parent::tearDown();
$this->bs->shutdown();
}
/** /**
* A basic feature test example. * A basic feature test example.
* *
...@@ -26,29 +30,16 @@ class StaticPagesTest extends TestCase ...@@ -26,29 +30,16 @@ class StaticPagesTest extends TestCase
*/ */
public function testExample() public function testExample()
{ {
try { $this->startPageTest();
$this->webdriver = RemoteWebDriver::create( #$this->navigationMenuTest();
getenv("WEBDRIVER_URL"),
$this->caps
);
$this->startPageTest();
$this->navigationMenuTest();
} finally {
$this->webdriver->quit();
}
} }
private function startPageTest() private function startPageTest()
{ {
$this->webdriver->get($this->mgServer); $this->webdriver->get(env("APP_URL", ""));
# Test for Page Title # Test for Page Title
$this->assertEquals($this->webdriver->getTitle(), "MetaGer - Mehr als eine Suchmaschine"); $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);
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment