Configuring phpspec and laravel

I am creating a new Laravel project and integrating PHPSpec. I'm having trouble finding a good working example phpspec.yml file that works neatly with Laravel. Similar to RSpec in Rails.

My desired folder structure would look like this

spec/
    models/
    controllers/
app/
    models/
    controllers/

Now my phpspec.yml looks like this:

suites:
controller_suite:
    namespace: Controller
    spec_path: 'spec/controllers'
    src_path: 'app/controllers'

model_suite:
    namespace: Model
    spec_path: 'spec/models'
    src_path: 'app/models'  

I copied my Model-related tests in the spec / models folder, but when I run phpspec it does not run any of them. I also understand that the namespace is not “Model” and “Controller” in Laravel, perhaps more like Eloquent and BaseController ..

I also use this extension: https://github.com/BenConstable/phpspec-laravel

I am not sure how to install this and cannot find any working examples. Thanks in advance!

EDIT: founbd :

Behat. PHPSpec ( ).

UPDATE:

Codeception , , , Laravel .

+4
2

, Ben Constable:

PHPSpec Laravel , , . , , :

- app
    - Controllers
        - MyController.php
    - Models
        - MyModel.php
- spec
    - Controllers
        - MyControllerSpec.php
    - Models
        - MyModelSpec.php

phpspec.yml youd :

extensions:
    - PhpSpec\Laravel\Extension\LaravelExtension

suites:
    laravel_controller_suite:
        namespace: Controllers
        src_path: app
    laravel_model_suite:
        namespace: Models
        src_path: app

laravel_extension:
    testing_environment: 'testing'

, , composer.json, app/ . , , , :

<?php namespace Controllers;

use Controller;

class MyController extends Controller {}

. , , Ive Laravel, Ive app/src/MyVendor/MyNamespace/Controllers .., ( Laravel Packages).

, PHPSpec Laravel - GitHub, / .

+5

, Laravel 5.x PhpSpec 4.x, PSR4, PhpSpec Laravel.

:

suites:
    app:
        namespace: App
        src_path: app
        psr4_prefix: App
        spec_prefix: classes
        spec_path: specs
0

Source: https://habr.com/ru/post/1531144/


All Articles