An open API service indexing awesome lists of open source software.

https://github.com/damianlewis/oc-octobertesting-plugin

Enables OctoberCMS to use Laravel's testing frameworks
https://github.com/damianlewis/oc-octobertesting-plugin

octobercms octobercms-plugin testing

Last synced: 6 months ago
JSON representation

Enables OctoberCMS to use Laravel's testing frameworks

Awesome Lists containing this project

README

          

# October Testing
Enables the use of the Laravel testing frameworks within October CMS.

## Usage

### Installation
Install via Composer:
```bash
composer require damianlewis/oc-octobertesting-plugin --dev
```

### Plugin Feature & Unit Tests
To test plugins, create a `tests` folder within the plugin base folder and copy the `phpunit.xml` file to this location, for example, `/plugins/acme/blog/tests/phpunit.xml`. Create sub folders for feature and unit tests, for example, `/plugins/acme/blog/tests/feature/` and `/plugins/acme/blog/tests/unit/`. Then in the tests folders, create tests following the principles used for [Laravel testing](https://laravel.com/docs/5.5/testing). Test suites have been configured within the `phpunit.xml` file for feature and unit tests.

When creating tests, use the alternative `Tests\PluginTestCase` class. This alternative class doesn't make use of an in memory database, allowing you to choose what database you wish to use for testing. See example below.
```php
get('/');

$response->assertStatus(200);
}
}
```

### Laravel Dusk
To make use of Laravel Dusk with OctoberCMS, run the `dusk:install` Artisan command:
```bash
php artisan dusk:install
```

Then use Dusk as you would with Laravel, see [Laravel Dusk](https://laravel.com/docs/5.5/dusk#installation). For example, to run tests from the CLI use the `dusk` Artisan command:
```bash
php artisan dusk
```

#### Authentication
To make use of the `login` and `loginAs` authentication methods, an object containing the `login` and `password` for the user is expected. To provide the default/admin user account, you can override the `user` method in the `Tests\DuskTestCase` class as follows:
```php
'admin',
'password' => 'admin'
];
}
}
```

#### Screenshots
To create browser screenshots add the `--window-size` argument to the `ChromeOptions->addArguments` method as shown below:
```php
$options = (new ChromeOptions)->addArguments([
'--disable-gpu',
'--window-size=1280,1024',
'--headless'
]);
```