Skip to content

Documentation needed: phpspec.yml does not support different PSRs in different suites #1468

@ash-m

Description

@ash-m

So, I just started throwing some misc classes in my fake/ directory. They are just minimal interface implementations so I didn't care to reflect where they might go in the src/ directory if they were real classes. But adding "Fake\\": "fake/" to composer.json would mean that the specs for these classes would be in spec/, which I felt would be confusing. Solution? PSR-0. Now they get their own directory, spec/Fake. But if you have a psr4_prefix mapping in your phpspec.yml configuration, then phpspec won't be able to find the class, claiming it must be in "the base spec namespace spec\App\".

Here' s part of my composer.json:

  "autoload": {
    "psr-4": {
      "App\\": "src/"
    },
    "psr-0": {
      "Fake\\": "fake/"
    }
  }

Here's my phpspec.yml:

suites:
  fake: 
    namespace: Fake
    src_path: fake
  default:
    namespace: App
    psr4_prefix: App
    src_path: src

Here's what I ran:

0d209c8f2ff3:/app# php vendor/bin/phpspec desc Fake/Foo
Specification for Fake\Foo created in /app/spec/Fake/FooSpec.php.

0d209c8f2ff3:/app# php vendor/bin/phpspec run Fake/Foo
                                                                                 0
0 specs
0 examples
0ms

0d209c8f2ff3:/app# php vendor/bin/phpspec run spec/Fake/FooSpec.php

In PSR0Locator.php line 300:

  Spec class `spec\Fake\FooSpec` must be in the base spec namespace `spec\App\`.


run [-f|--format FORMAT] [--stop-on-failure] [--no-code-generation] [--no-rerun] [--fake] [-b|--bootstrap BOOTSTRAP] [--] [<spec>]

0d209c8f2ff3:/app#

Although this does sort of make it seem like the concept of a suite is not isolated, this isn't a huge problem. I don't really need to do this, but it would've been nice to have it documented.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions