GithubHelp home page GithubHelp logo

olx-inc / plugin-php Goto Github PK

View Code? Open in Web Editor NEW

This project forked from athena-oss/plugin-php

0.0 3.0 0.0 5.49 MB

[DEPRECATED] Plugin for Test Automation using PHP as a development language.

Home Page: https://athena-oss.github.io/plugin-php/

License: Apache License 2.0

PHP 74.67% Shell 13.10% Gherkin 0.14% HTML 11.20% Dockerfile 0.89%
deprecated

plugin-php's Introduction

DEPRECATED No Maintenance Intended

This repository is now deprecated and it will be available until 01.06.2021.

Athena PHP Plugin Build Status

Athena PHP Plugin is a plugin for Athena, that provides a PHP environment for you to execute and create different types of tests, and provides a fluent interface to short-cut and ease test development for PHP.

For Tests that require Selenium and/or Proxy you also need to install the Athena Selenium Plugin and/or Athena Proxy Plugin.

Main Features

  • Supported Testing types :
    • API (using BDD or classic approach)
    • Browser (using BDD or classic approach)
    • Unit
    • Lint
    • Checkstyle
    • Complexity
  • Parallelism
  • Reports with Screenshots for when using Selenium driver (HTML)
  • Reports with HTTP transanctions exposed (HTML)
  • And many many more...

How to Install ?

On Linux

  • Using apt-get :
$ sudo add-apt-repository ppa:athena-oss/athena
$ sudo apt-get update
$ sudo apt-get install athena-plugin-php

On MAC OSX

$ brew tap athena-oss/tap
$ brew install plugin-php

Alternative

$ athena plugins install php https://github.com/athena-oss/plugin-php.git

Read the Documentation on using Athena Plugin PHP.

Examples

API Tests

namespace Tests;

use Athena\Athena;
use Athena\Test\AthenaAPITestCase;

class HttpBinTest extends AthenaAPITestCase
{
    public function testIpEndpoint_PerformGetRequest_ShouldContainOrigin()
    {
        $result = Athena::api()
                            ->get('http://httpbin.org/ip')
                            ->then()
                            ->assertThat()
                            ->responseIsJson()
                            ->statusCodeIs(200)
                            ->retrieve()
                            ->fromJson();

        $this->assertArrayHasKey('origin', $result);
    }
}

Browser Tests

...

 public function testGoogle_WaitForElementExistenceAndClick_ShouldShowResultsPage()
    {
        Athena::browser()->get("http://google.pt")
            ->getElement()
            ->withName('btnI')
            ->wait(1)
            ->toBePresent()
            ->thenFind()
            ->asHtmlElement()
            ->click();
    }

...

Browser Tests - BDD

Defining the feature scenario

Feature: Anonymous User performs a search

  As a Anonymous User
  I want to perform a search for a string
  So that I can get a list of results related with my search

  Scenario: Searched string returns results
    Given the current location is the home page
    When the Anonymous User writes "athena" in the search box
    And the Anonymous User performs a click in the search button
    Then the current location should be results page

Implementing

...

   /**
     * @Given /^the current location is the home page$/
     */
    public function theCurrentLocationIsTheHomePage()
    {
        $this->currentLocation = $this->browser->get('https://google.com/');
    }
    /**
     * @When /^the Anonymous User writes "([^"]*)" in the search box$/
     */
    public function theAnonymousUserWritesInTheSearchBox($arg1)
    {
        $this->currentLocation
            ->find()
            ->elementWithName('q')
            ->sendKeys($arg1);
    }
    /**
     * @Given /^the Anonymous User performs a click in the search button$/
     */
    public function theAnonymousUserPerformsAClickInTheSearchButton()
    {
        $this->currentLocation
            ->find()
            ->elementWithName('btnG')
            ->click();
    }
    /**
     * @Then /^the current location should be results page$/
     */
    public function theCurrentLocationShouldBeResultsPage()
    {
        PHPUnit_Framework_Assert::assertStringEndsWith("#q=athena", Athena::browser()->getCurrentURL());
    }

...

Using the plugin on the cli

$ athena php

...

usage: athena php <command> [<args...>]

These are the available commands for plugin [php]:
	api        Run api tests.
	bdd        Run behaviour driven tests.
	browser    Run browser tests.
	cleanup    Removes vendor related stuff.
	composer   Run Composer.
	lint       Check files for syntax errors.
	phpcs      Analyse code smells against a custom or existing rule-set.
	phpmd      Run mess detector tests
	self-test  Executes tests to the built-in functionalities.
	unit       Run unit tests.

Running Functional tests that require a Proxy and Selenium

  • Start the proxy
athena proxy start
  • Start the Selenium Hub
athena selenium start hub latest
  • Start the Selenium Browser
athena selenium start firefox latest

plugin-php's People

Contributors

pproenca avatar suciista09 avatar rafaelspinto avatar luisgros-fixeads avatar rleite-olx avatar

Watchers

James Cloos avatar Ezequiel Ola avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.