PHP code example of ta-tikoma / phpunit-architecture-test

1. Go to this page and download the library: Download ta-tikoma/phpunit-architecture-test library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ta-tikoma / phpunit-architecture-test example snippets


$controllers  = $this->layer()->leaveByNameStart('App\\Controllers');
$services     = $this->layer()->leaveByNameStart('App\\Services');
$repositories = $this->layer()->leaveByNameStart('App\\Repositories');

$this->assertDoesNotDependOn($controllers, $repositories);
$this->assertDependOn($controllers, $services);
$this->assertDependOn($services, $repositories);

abstract class TestCase extends BaseTestCase
{
    use ArchitectureAsserts;
}

    public function test_make_layer_from_namespace()
    {
        $app = $this->layer()->leaveByNameStart('PHPUnit\\Architecture');
        $tests = $this->layer()->leaveByNameStart('tests');

        $this->assertDoesNotDependOn($app, $tests);
        $this->assertDependOn($tests, $app);
    }