Inspect the response in Laravel PHPUnit tests

The Problem

Sometimes, when running integration tests using Laravel and PHPUnit, it’s useful to inspect the response when you can’t figure out why the test is failing. In Laravel 5 and later versions, testing has been highly improved with an API that allows nice and fluent interaction with your application.

Inspect the Response Object

In Laravel, each Test extends the default abstract TestCase class defined in Illuminate\Foundation\Testing. This class uses the CrawlerTrait to …

Read More
Basic ProcessWire website workflow - Part One

Introduction

For those of you who don’t know what ProcessWire is (shame on you!), here the introduction statement of the official website:

“ProcessWire is a free PHP content management system and framework (open source CMS/CMF) built to save you time and work the way you do. ProcessWire provides simpler and stronger control over your pages, fields, templates and markup at any scale.”

ProcessWire Logo

In my opinion, …

Read More
First steps with GraphQL in Laravel Framework - Part One

Introduction

GraphQL1 is one of the recent major technologies introduced by Facebook in the React ecosystem. Essentially it is a declarative approach for querying data from a backend.

“React is changing the way we build complex client-side UI applications. Flux rethinks the flow of data through applications. GraphQL is changing the way we fetch our data from the server.”

In a nutshell, GraphQL is challenging REST. The key concept is that the client is the only component of an …

Read More
JavaScript Quiz Answers Explained

Introduction

JavaScript is notoriously a simple programming language, but let’s be honest: it sucks!

Don’t get me wrong! I love programming in JavaScript, it gives extraordinary freedom in building things that runs everywhere, but at the cost that is so easy to write bad code. The reason falls back to its winding history, starting from its creation in 10 days by Brendan Eich. Wikipedia has an exhaustive entry on the subject, so I suggest you to check it.

Nevertheless after 20 …

Read More
Laravel 5 Cron Jobs on shared hosting

Introduction

The Laravel documentation covers all the information you need to configure Cron Jobs on your hosting machine. Some years ago we were required to define an entry on the server for each task we needed to schedule. Now with Laravel we can simply define a single entry that interacts with the Schedule object, which will take care to run the tasks that are due.

The only Cron entry needed on the server, is the following

* * * * * php /path/to/artisan schedule:run >> /dev/null 2 …
Read More
Five Programming Problems

Introduction

Recently I stumbled upon this blog post on ShiftedUp. The writer briefly explains that he encountered many cases of job applications for Software Engineer positions, made by people who actually have no idea of what programming means.

Then he proposes 5 coding problems to solve in less than one hour, using whatever programming language you are comfortable with. So I decided to take the challenge! The language used is JavaScript, but the examples can be written easily in any other …

Read More