<commit_before># Webino developer's module <br /> for Zend Framework 2

Module to ease development of the Webino modules.

## Features

- Utility functions
- Smart dependency injection definition generator
- Base classes for Selenium WebDriver tests

## Requirements

- PHP 5.4
- ZendFramework 2

## Setup

Open terminal and go to your application directory

1. Use this module only in your development environment
- Run `php composer.phar require webino/webino-dev:dev-develop`
- Add `WebinoDev` to the enabled modules list

  *NOTE: Considering a zf2-skeleton or very similar application.*

## QuickStart

### Utility functions

```php
d();  // var_dump();
dd(); // var_dump();exit;
p();  // print_r();
pd(); // print_r();exit;
pr(); // return print_r();
e();  // throw new \WebinoDev\Exception\DevelopmentException;
```

### Dependency injection definition generator

Create file `bin/definition_generator` in your module, with following code:

```php
#!/usr/bin/env php
<?php

namespace WebinoExample;

use WebinoDev\Di\Definition\Generator;

// Autoloader
$loader = require __DIR__ . '/../vendor/autoload.php';
$loader->add(__NAMESPACE__, __DIR__ . '/../src');

// Dump DI definition
(new Generator(__DIR__))->compile()->dump();
```

*NOTE: Assuming `WebinoExample/bin/` and `WebinoExample/vendor/` directories.* <br />
*NOTE: Use your namespace instead of WebinoExample.*

With custom paths, relative to vendor directory:

```php
(new Generator(__DIR__))->compile(['custom/path/1', 'custom/path/2'])->dump();
```

With ignored paths:

```php
(new Generator(__DIR__))->setIgnore(['regex1', 'regex2', 'etc.'])->compile()->dump();
```

### Selenium WebDriver tests

```php
use WebinoDev\Test\Selenium\AbstractTestCase;

class HomeTest extends AbstractTestCase
{
    public function testHome()
    {
        $this->session->open($this->uri);
        $this->assertNotError();
    }
}
```

With authentication:

```php
use WebinoDev\Test\Selenium\AbstractAuthenticationTestCase;

class AuthenticationTest extends AbstractAuthenticationTestCase
{
    public function testAuthentication()
    {
        $this->session->open($this->uri);
        $this->assertNotError();
        $this->setAuthenticatedCssSelector('.authentication-success');
        $this->authenticate();
    }
}
```

or use trait:

```php
use WebinoDev\Test\Selenium\AbstractTestCase;

class AuthenticationTest extends AbstractTestCase
{
    use AuthenticationTrait;
}
```

## Development

We will appreciate any contributions on development of this module.

Learn [How to develop Webino modules](https://github.com/webino/Webino/wiki/How-to-develop-Webino-modules)

## Addendum

Please, if you are interested in this Zend Framework module report any issues and don't hesitate to contribute.
<commit_msg>Updated README, better how to<commit_after># Webino developer's module <br /> for Zend Framework 2

Module to ease development of the Webino modules.

## Features

- Utility functions
- Smart dependency injection definition generator
- Base classes for Selenium WebDriver tests

## Requirements

- PHP 5.4
- ZendFramework 2

## Setup

Open terminal and go to your application directory

1. Use this module only in your development environment
- Run `php composer.phar require webino/webino-dev:dev-develop`
- Add `WebinoDev` to the enabled modules list

  *NOTE: Considering a zf2-skeleton or very similar application.*

## QuickStart

### Utility functions

```php
d();  // var_dump();
dd(); // var_dump();exit;
p();  // print_r();
pd(); // print_r();exit;
pr(); // return print_r();
e();  // throw new \WebinoDev\Exception\DevelopmentException;
```

### Dependency injection definition generator

Create file `bin/definition_generator` in your module, with following code:

```php
#!/usr/bin/env php
<?php

namespace WebinoExample;

use WebinoDev\Di\Definition\Generator;

// Autoloader
$loader = require __DIR__ . '/../vendor/autoload.php';
$loader->add(__NAMESPACE__, __DIR__ . '/../src');

// Dump DI definition
(new Generator(__DIR__))->compile()->dump();
```

*NOTE: Assuming `WebinoExample/bin/` and `WebinoExample/vendor/` directories.* <br />
*NOTE: Use your namespace instead of WebinoExample.*

With custom paths, relative to vendor directory:

```php
(new Generator(__DIR__))->compile(['custom/path/1', 'custom/path/2'])->dump();
```

With ignored paths:

```php
(new Generator(__DIR__))->setIgnore(['regex1', 'regex2', 'etc.'])->compile()->dump();
```

### Selenium WebDriver tests

```php
use WebinoDev\Test\Selenium\AbstractTestCase;

class HomeTest extends AbstractTestCase
{
    public function testHome()
    {
        $this->session->open($this->uri);
        $this->assertNotError();
    }
}
```

#### Testing authentication

```php
use WebinoDev\Test\Selenium\AbstractAuthenticationTestCase;

class AuthenticationTest extends AbstractAuthenticationTestCase
{
    public function testAuthentication()
    {
        $this->session->open($this->uri);
        $this->assertNotError();
        $this->setAuthenticatedCssSelector('.authentication-success');
        $this->authenticate();
    }
}
```

**or use trait**

```php
use WebinoDev\Test\Selenium\AbstractTestCase;

class AuthenticationTest extends AbstractTestCase
{
    use AuthenticationTrait;
}
```

#### Testing forms

```php
use PHPWebDriver_WebDriverBy as By;
use WebinoDev\Test\Selenium\AbstractTestCase;

class HomeTest extends AbstractTestCase
{
    public function testHome()
    {
        $this->enterInput(
            'email',
            '<EMAIL>',
            function ($elm) {
                $elm->submit();
            }
        );

        $this->waitFor(
            function () {
                return $this->session->element(By::CLASS_NAME, '.example-success');
            },
            function ($elm) {
                $this->assertSame('example', $elm->text());
            }
        );
    }
}
```

#### Testing AJAX

```php
use PHPWebDriver_WebDriverBy as By;
use WebinoDev\Test\Selenium\AbstractTestCase;

class HomeTest extends AbstractTestCase
{
    public function testHome()
    {
        $this->element(By::CLASS_NAME, 'ajax-btn')->click();
        $this->waitForAjax();
        $result = $this->element(By::CLASS_NAME, 'ajax-result')->text();
        $this->assertSame('expected ajax result', $result);
    }
}

```

## Development

We will appreciate any contributions on development of this module.

Learn [How to develop Webino modules](https://github.com/webino/Webino/wiki/How-to-develop-Webino-modules)

## Addendum

Please, if you are interested in this Zend Framework module report any issues and don't hesitate to contribute.

{'fraction_non_alphanumeric': 0.14009369805047606, 'fraction_numerical': 0.003022517757291824, 'mean_word_length': 3.816593886462882, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 57, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1608964', 'n_tokens_mistral': 2013, 'n_tokens_neox': 1911, 'n_words': 539}