2017 © Pedro Peláez
 

library test-suite

image

uwdoem/test-suite

  • Thursday, November 3, 2016
  • by JASchilz
  • Repository
  • 2 Watchers
  • 0 Stars
  • 56 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 2 % Grown

The README.md

Build Status Code Climate Test Coverage Latest Stable Version, (*1)

TestSuite

PHPUnit web test case class for UWDOEM projects using the Athens web framework., (*2)

Use

This library is published on packagist. To install using Composer, add the "uwdoem/test-suite": "0.*" line to your "require-dev" dependencies:, (*3)

{
    "require-dev": {
        ...
        "uwdoem/test-suite": "0.*",
        ...
    }
}

Example

Below is an example test file which makes use of the WebTestCase class:, (*4)

<?php

use UWDOEM\TestSuite\WebTestCase;

class WebTest extends WebTestCase
{

    /**
     * Initialize the browser window
     *
     * @return void
     */
    protected function setUp()
    {
        $this->setBrowser('firefox');
        $this->setBrowserUrl('http://localhost:8001/');
    }

    /**
     * A test class using WebTestCase shall be able to visit a page and retrieve
     * the title.
     *
     * @return void
     */
    public function testTitle()
    {
        $this->url('/form.php');
        $this->assertEquals('Form', $this->title());
    }

    /**
     * A test class using WebTestCase shall be able to fill a form with random
     * data, and submit.
     *
     * @return void
     */
    public function testFormFill()
    {
        $this->url('/form.php');
        $this->assertEquals('Form', $this->title());

        $values = $this->fillForm();

        $this->element($this->using('css selector')->value('input[type=submit]'))->click();

        $body = $this->element($this->using('css selector')->value('body'))->attribute('innerHTML');

        foreach ($values as $value) {
            $this->assertContains($value, $body);
        }
    }

}

The Versions