AthenaeumAthenaeum
Packages
  • next
  • current
  • v9.x
  • v8.x
  • v7.x
  • v6.x
  • v5.x
  • v4.x
  • v3.x
  • v2.x
  • v1.x
Changelog
GitHub
Packages
  • next
  • current
  • v9.x
  • v8.x
  • v7.x
  • v6.x
  • v5.x
  • v4.x
  • v3.x
  • v2.x
  • v1.x
Changelog
GitHub
  • Version 1.x

    • How to install
  • Config

    • Configuration Loader
  • Container

    • IoC Service Container
  • Dto

    • Data Transfer Object (DTO)
    • Create Interface
    • Implement DTO
    • Property overloading
    • Populate
    • Json
    • Nested DTOs
    • Array DTO
  • Properties

    • Properties Overload
  • Support

    • Support Introduction
    • Laravel Aware Of Helpers
    • Aware Of Properties
    • Aware-Of Component Generator
  • Testing

    • Testing Introduction
    • Laravel
    • Test Cases
    • Traits
  • Utils

    • Populate
    • Json
You are viewing documentation for an outdated version. It is no longer supported!

Laravel

The LaravelTestHelper is a wrapper for Orchestral Testbench. It allows you to test laravel components using various testing-frameworks, like Codeception.

Prerequisite

To use this component, you must install Orchestral Testbench:

composer require --dev "orchestra/testbench=~3.0"

How to Use

In the below stated example, a codeception's unit test (extends PHP Unit) is being used.

use Codeception\TestCase\Test;
use Aedart\Testing\Laravel\LaravelTestHelper;

class MyUnitTest extends Test
{
    use LaravelTestHelper;

    protected function _before(){
        // Start the Laravel application
        $this->startApplication();
    }

    protected function _after(){
        // Stop the Laravel application
        $this->stopApplication();
    }
    
    /**
     * @test
     */
    public function readSomethingFromConfig(){
        // Calling config, using Laravel defined helper method
        $defaultDbDriver = config('database.default');

        $this->assertSame('mysql', $defaultDbDriver);
    }

    /**
     * @test
     */
    public function readSomethingElseFromConfig(){
        // Get the application instance
        $app = $this->getApplication();
        
        $queueDriver = $app['config']['queue.default'];
        
        $this->assertSame('sync', $queueDriver);
    }
    
    // ... Remaining not shown ... //
}

Onward

For more information, please review Orchestral's documentation and review the source code of LaravelTestHelper.

Edit page
Last Updated: 12/04/2020, 17:27
Contributors: Alin Eugen Deac
Prev
Testing Introduction
Next
Test Cases