Support the ongoing development of Laravel.io →
posted 10 years ago
Testing
Last updated 2 years ago.
0

Yes and no.

Using the construct 'use' only aliases a class to work in the current class. This has nothing to do with how it is used. It might be aliased to shorten type hinting or it might be extended. Neither of which are dependencies. If a class is used within an object itself then it is a dependency.

Any Laravel facade used is essentially a dependency. It just hasn't been injected through the controller. Its just a nicer syntax than injecting through the controller, however I find it harder to see the purpose of the class when not using dependency injection.

Last updated 2 years ago.
0

I would agree. Its the ease mostly when using facades. Since all laravel facades are mockable by implementation , will it implicate the ability to unit test my code.

Ref : Illuminate\Support\Facades\Facade class

Ref : http://laravel.com/docs/testing#mocking-facades

damienadermann said:

Yes and no.

Using the construct 'use' only aliases a class to work in the current class. This has nothing to do with how it is used. It might be aliased to shorten type hinting or it might be extended. Neither of which are dependencies. If a class is used within an object itself then it is a dependency. Wt just hasn't been injected through the controller. Its just a nicer syntax than injecting through the controller, however I find it harder to see the purpose of the class when not using dependency injection.

Last updated 2 years ago.
0

gayanhewa said: will it implicate the ability to unit test my code.

No it won't. It will just be tested slightly differently.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

gayanhewa gayanhewa Joined 26 Feb 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.