PHPackages                             inquid/luya-testsuite - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. inquid/luya-testsuite

ActiveLuya-core[Testing &amp; Quality](/categories/testing)

inquid/luya-testsuite
=====================

TestCases and Data for LUYA Modules and Components. Makes testing less pain.

2.0.3(4y ago)0134MITPHP

Since May 4Pushed 4y agoCompare

[ Source](https://github.com/inquid/luya-testsuite)[ Packagist](https://packagist.org/packages/inquid/luya-testsuite)[ Docs](http://luya.io)[ RSS](/packages/inquid-luya-testsuite/feed)WikiDiscussions master Synced today

READMEChangelog (3)Dependencies (7)Versions (50)Used By (0)

LUYA Test Suite
===============

[](#luya-test-suite)

[![Build Status](https://camo.githubusercontent.com/5c5f9693a58f712048968dee814fe37d9786b5bcf32d5d31038b2b39a205004c/68747470733a2f2f7472617669732d63692e6f72672f6c7579616465762f6c7579612d7465737473756974652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/luyadev/luya-testsuite)[![Test Coverage](https://camo.githubusercontent.com/936de923252d377859842045909b4c92516826ffd0b50fc9b3836647ce3dc839/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f34343935343631636135666638343865373961392f746573745f636f766572616765)](https://codeclimate.com/github/luyadev/luya-testsuite/test_coverage)[![Total Downloads](https://camo.githubusercontent.com/3aaca200b28c43fd0edd08026e2c72bd1bce4b80c7e1034b83ea8e247ac6e8dc/68747470733a2f2f706f7365722e707567782e6f72672f6c7579616465762f6c7579612d7465737473756974652f646f776e6c6f616473)](https://packagist.org/packages/luyadev/luya-testsuite)[![Latest Stable Version](https://camo.githubusercontent.com/67e8f79a0ebc73d52aaed9dfebaa6609c07b71419065a3aa5f3ba1a64edaf141/68747470733a2f2f706f7365722e707567782e6f72672f6c7579616465762f6c7579612d7465737473756974652f762f737461626c65)](https://packagist.org/packages/luyadev/luya-testsuite)[![Join the chat at https://gitter.im/luyadev/luya](https://camo.githubusercontent.com/abe08b740a4156153736f791393ec4da6619c4be73212e75769f52edacc0e2b5/68747470733a2f2f6261646765732e6769747465722e696d2f4a6f696e253230436861742e737667)](https://gitter.im/luyadev/luya)

Providing PHPUnit Testcases and a built in Webserver to test your Application, Modules, Components, APIs or Classes.

Whats included?

Test Cases

- Web application test case
- Console application test case
- Server (for APIs) test case
- CMS Block test case
- NgRest test case (for model, controller and API)

Traits

- Message file compare trait
- Migration file check trait

Fixtures

- ActiveRecord fixture creates the table on loading based from array or rule definition.

See the [full Documentation](guide/README.md)

Install
-------

[](#install)

Add the `luyadev/luya-testsuite` package to the require-dev section of your composer.json file:

```
composer require luyadev/luya-testsuite:^2.0 --dev

```

Create a new folder `tests` inside your appliation folder and create a test classes:

```
namespace app\tests;

use Yii;

class MyTest extends \luya\testsuite\cases\WebApplicationTestCase
{
    public function getConfigArray()
    {
        return [
            'id' => 'mytestapp',
            'basePath' => dirname(__DIR__),
        ];
    }

    public function testInstance()
    {
        // add your phpunit tests here, like:
        $this->assertInstanceOf('luya\web\Application', Yii::$app);
        $this->assertInstanceOf('luya\base\Boot', $this->boot);
        $this->assertInstanceOf('luya\web\Application', $this->app);
    }
}
```

To run the unit tests while (assuming your tests are in directory `tests/`) run in your terminal:

```
./vendor/bin/phpunit tests/
```

In order to support sqlite fixtures install:

```
sudo apt-get install php-sqlite3
```

Example Test Cases
------------------

[](#example-test-cases)

Some example in how to use the LUYA Testsuite for different scenarios.

### Testing API and Application

[](#testing-api-and-application)

When working with APIs or Customer Websites somtimes you just want to test the Website itself, what is the response, does all the pages still work after my update? Therefore we have `luya\testsuite\cases\ServerTestCase`.

This example will run your LUYA application within a PHP Webserver and test the response status codes or contents for a set of given pages. In order to run this example create a `MyWebsiteTest.php` file inside the `tests` folder.

```
namespace app\tests;

class MyWebsiteTest extends ServerTestCase
{
   public function getConfigArray()
   {
      return [
          'id' => 'mytestapp',
          'basePath' => dirname(__DIR__),
      ];
  }

  public function testSites()
  {
      $this->assertUrlHomepageIsOk(); // checks the root url like: http://localhost/mywebsite.com
      $this->assertUrlIsOk('about'); // checks: http://localhost/mywebsite.com/about
      $this->assertUrlGetResponseContains('about/me', 'Hello World'); // checks: http://localhost/mywebsite.com/about/me
      $this->assertUrlIsError('errorpage'); // checks: http://localhost/mywebsite.com/errorpage
  }
}
```

> As the Webserver process may run from a different permission level you have to ensure the assets/runtime folder has the required permissions.

### Controller Function Test

[](#controller-function-test)

We're using `getMockBuilder()` as shown in the multiple examples in the [PHPUnit](https://phpunit.de/manual/current/en/test-doubles.html) to setup the DefaultController and assert the registered module `addressbook`. To test the the runtime exception (caused by a database error), we use the mock `method` function:

```
public function testActionIndex()
{
    $module = Yii::$app->getModule('addressbook');

    $this->assertInstanceOf('luya\addressbook\frontend\Module', $module);
    $mock = $this->getMockBuilder(DefaultController::class)
        ->setConstructorArgs(["id" => "default", "module" => $module])
        ->getMock();

    $mock->method("actionIndex");
}
```

###  Health Score

33

—

LowBetter than 74% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity76

Established project with proven stability

 Bus Factor1

Top contributor holds 92.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~31 days

Recently: every ~45 days

Total

49

Last Release

1804d ago

Major Versions

1.0.x-dev → 2.0.02020-12-02

### Community

Maintainers

![](https://www.gravatar.com/avatar/3604b7574d7b9413dc9a590f96805a721902dc865b3ed0accc569259f53740bf?d=identicon)[gogl92](/maintainers/gogl92)

---

Top Contributors

[![nadar](https://avatars.githubusercontent.com/u/3417221?v=4)](https://github.com/nadar "nadar (238 commits)")[![gogl92](https://avatars.githubusercontent.com/u/1505641?v=4)](https://github.com/gogl92 "gogl92 (6 commits)")[![JohnnyMcWeed](https://avatars.githubusercontent.com/u/9844452?v=4)](https://github.com/JohnnyMcWeed "JohnnyMcWeed (5 commits)")[![denyadzi](https://avatars.githubusercontent.com/u/5346829?v=4)](https://github.com/denyadzi "denyadzi (3 commits)")[![martinpetrasch](https://avatars.githubusercontent.com/u/6354795?v=4)](https://github.com/martinpetrasch "martinpetrasch (2 commits)")[![CoolLamer](https://avatars.githubusercontent.com/u/380215?v=4)](https://github.com/CoolLamer "CoolLamer (2 commits)")[![dev7ch](https://avatars.githubusercontent.com/u/15183757?v=4)](https://github.com/dev7ch "dev7ch (1 commits)")[![boehsermoe](https://avatars.githubusercontent.com/u/2466744?v=4)](https://github.com/boehsermoe "boehsermoe (1 commits)")

---

Tags

phpmoduleluya

### Embed Badge

![Health badge](/badges/inquid-luya-testsuite/health.svg)

```
[![Health](https://phpackages.com/badges/inquid-luya-testsuite/health.svg)](https://phpackages.com/packages/inquid-luya-testsuite)
```

###  Alternatives

[luyadev/luya-module-admin

Administration core module for all LUYA admin modules

48179.0k24](/packages/luyadev-luya-module-admin)[luyadev/luya-module-cms

The LUYA CMS module provides a full functional Content Management System for adding contents based on blocks.

32176.1k18](/packages/luyadev-luya-module-cms)[luyadev/luya-bootstrap4

Bootstrap4 Assets and Helper classes like ActiveForm for LUYA and Yii2.

1843.9k3](/packages/luyadev-luya-bootstrap4)[luyadev/luya-module-payment

LUYA Payment allows you to integrate payments in a safe and fast way. The module take care of all the provider required steps (call, create, success, abort, etc.) and provides all the informations for your store.

1012.1k](/packages/luyadev-luya-module-payment)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
