Skip to content

Unable to make spy of the "Schema" facade #37983

@awjudd

Description

@awjudd
  • Laravel Version: 8.49.2
  • PHP Version: 8.0.7
  • Database Driver & Version: N/A

Description:

When testing and trying set up the spy on the Schema object (i.e. Schema::spy()), you receive an exception.

Steps To Reproduce:

1 - Create a test case
2 - Call the following:

Schema::spy();

3 - When you run the test case, you will receive the following error:

TypeError: Illegal offset type in isset or empty

/Users/judda/code/schema-facade/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:128
/Users/judda/code/schema-facade/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:52
/Users/judda/code/schema-facade/tests/Feature/ExampleTest.php:18

Commit with the issue:
https://github.com/awjudd/laravel-schema-issue/commit/9040182ce26fc4572c6c79f6200d13d12ddc8042

Extra Information

When digging a little deeper, it looks like there are at least 2 spots that have the same issue. In src/Illuminate/Support/Facades/Schema.php the following methods:

  • swap
  • isMock

I believe that it has to do with the following change:
63d87d7

The reason being, at this point in time the method no longer could be trusted to only return a string, so doing the dictionary lookup was ignored in one spot (63d87d7#diff-85c2ee3096a7c4457f3abe3785b2584af93e1672402207cee10195543acbba49R167)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions