Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Laravel News:
Testing Length Validation in Laravel
Feb 21, 2018 @ 15:54:40

On the Laravel News site there's a new post that gets into detail about length testing in Laravel. This testing evaluates the length of the text data taken in as input from some outside source (usually user input).

I thought it might help people new to the Laravel framework and testing, to walk through how to test length validation. When I say length validation, I mean the constraints of length that you might want to put on a string field.

[...] When testing lengths, there are a couple of techniques I think can be helpful that I use with HTTP tests to verify that my validation is working as expected. Let’s walk through some hands-on examples of the validation portion of a controller request; we will also need a test database to demonstrate a test that interacts with a database.

They start by creating a new Laravel project and adding in some basic "user" functionality to store them in a local SQLite database. It then shows the code required to validate the incoming data on the "store" method including the "max" validation handling on the email address. It then shifts over to the actual testing of the validation, writing checks to ensure the maximum length is enforced with a random string, doing the same with an email address and handling cases of multiple validation tests.

tagged: validation testing laravel tutorial maximum length

Link: https://laravel-news.com/testing-length-validation-laravel

Joshua Thjissen:
Symfony, Xdebug, and maximum nesting level issues
Nov 18, 2015 @ 16:53:45

In this new post to his site Joshua Thjissen has shared some of his discoveries with Xdebug, Symfony 2 and problems with maximum nesting levels of objects in his testing.

Here you are, developing your code based on the Symfony2 framework. Creating a form here, add a Twig template there, until suddenly, boom! Your site doesn’t work anymore, and all the info you can find in your PHP logs is [an error about the maximum function nesting level being reached.

[...] What just happened? Did I create some kind of recursive function I wasn’t aware of, did somebody commit code that I accidentally pulled? Fortunately for us developers, there is a quick way to deal with this: google it...

According to the information he found via his search it's a common issue and can be "fixed" by bumping up the max_nesting_level to a higher value. He could have stopped there but he wanted to explain why this problem happened, what the nesting is all about, how it relates to the limitations of XDebug and why Twig could cause problems with it.

tagged: symfony2 xdebug maximum nesting level issue stack trace twig

Link: https://www.adayinthelifeof.nl/2015/11/17/symfony-xdebug-and-maximum-nesting-level-issues/


Trending Topics: