Skip to main content

Posts

Showing posts from July, 2016

Limiting how often you run seeds and migrations in Laravel 5.2 testing

Image: Pixabay If integration tests take too long to run then we stop running them because they're just an annoyance.  This is obviously not ideal and so getting my tests to run quickly is important. I'm busy writing a test suite for Laravel and wanted more flexibility than the built-in options that Laravel offers for working with databases between tests. Using the DataMigrations trait meant that my seed data would be lost after every test.  Migrating and seeding my entire database for every test in my suite is very time consuming. Even when using an in-memory sqlite database doing a complete migration and seed was taking several seconds on my dev box. If I used the DataTransactions trait then my migrations and seeds would never run and so my tests would fail because the fixture data is missing. My solution was to use a static variable in the base TestCase class that Laravel supplies.  It has to be static so that it retains its values between tests by the wa...

Implementing a very simple "all of the above" checkbox

Image: Pixabay Implementing a checkbox that lets the user "select all of the above" is trivial with jQuery. The idea is that when the user selects the "all" checkbox then all of the other checkboxes are set to the same value. Similarly if they deselect any of the other options we need to turn off the "all" checkbox.