Basic ProcessWire website workflow - Part Two


Following the Part One.

In the previous article we have set the foundations, now it’s time to actually code the pages our basic website.

Template Inheritance

Let’s start by explaining the concept of template inheritance. The Smarty documentation provides a nice explanation of this approach, which allows the developer/designer to compose each page by writing only the necessary code and inheriting or including the common parts that are shared.

“Template …

Read More
Test Laravel filesystem storage with Virtual File System


Since Laravel 5, the filesystem operations are abstracted thanks to the Flysystem PHP package by Frank de Jonge. This integration provides simple drivers for working with local filesystems, Amazon S3, and other Cloud Storage. The API remains the same for each system therefore is really simple to swap between each storage option.

Testing the filesystem is not an easy task. I covered some of the challenges in a previous blog post, but luckily we have a couple of tools at our …

Read More
SQLite In-Memory Database for Unit Tests in Laravel


When testing your code (and this is particularly true for functional tests), even if you mock most of the database iteractions, at some point you need to hit the persistent layer of your application in order to ensure that everything works correctly. In these cases you obviously are not willing to make definitive changes to your development database each time you run a test.

Luckily for us Laravel 5 provides two useful methods to solve this problem:

  • Database Transactions …
Read More
How to test the File System using vfsStream


Let’s face it! In some situations, no matter how hard you try to mock everything, you have to unit test the file system in order to ensure that your application works correctly.

Testing directly the file system is a pain in the ass due to the many possible things that can go wrong. Remember: unit tests must be performed in isolation, therefore we need to make sure that each test case doesn’t affect the outcome of the others.

The old-fashioned way to avoid possible …

Read More
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


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