Posts

  • Laravel Testing Redirect::back()

    Hello guys, sometimes in your functional test you need to test a redirect, this is pretty easy to test except for the Laravel Redirect::back() method. I’ve found out that this is hard to test and the only solution to solve the problem is to fake a HTTP_REFERRER value. But keep in mind that in general the best approach is to don’t use many Redirect::back() and instead use the redirect to a certain route, in fact is much more clearer from the test perspective to assert a redirect to a given route instead of a fake one. Anyways here’s the solution:

  • PHP Value Object

    Let’s talk about, Value objects. The first thing to undersdand is why and when they are needed. Generally when you save some data you pair with a variable/attribute a value. In every programming language there are many type of values, for example strings,numbers and so on; imagine now that you need to save the number of apples and user have bought:

  • Testing in Laravel framework: step2 TDD calculator

    Hello again, in the previous article i’ve explained how to run your first test. Now we go a little more in detail and we tackle a real example.What we are going to do is write the calculator in TDD (test first). We incrementally build the calculator step after step. The step will be the following:

  • Introduction to Unit testing with Laravel framework: step1

    When i first came into programming i didn’t even know what self tested code was and how much it’s important for a developer. This article is for developers that want to start unit testing with laravel framework or php in general. Before going into details i’d like to explain you briefly what is unit testing and automated code tests. Automated code tests are programs that verify automatically that your application works as expected. Why self tested code is important? For multiple reasons, the most important is that removes the “fear of change” and for this reason help you refactoring your code and improving it. There are various kind of automated tests:

  • Integrate Laravel And Session in external php application

    Hello foks, it’s been a while since i didn’t write an article. Today i’ll explain you how you can integrate Laravel framework 4 (and his session driver) in any other php application. I’m writing this because i had to solve this problem in one of my works and i want to share this with you. You may say, why i should do that? Well, for multiple reasons, the first one i can find is if you want to use your laravel app authentication in an external php file or application (in orded to do that you need to use the laravel app session driver).

subscribe via RSS