Some popular PHPUnit assertions analysed out from a small, medium, and large PHP project

PHPUnit has been blowing away its competition for more than 5 years now. With the use of the right PHPUnit assertions, you can get the most benefit out of PHPUnit.

In this post, we will look into some popular and very useful PHPUnit assertions you should be using day to day in your PHPUnit tests. Let’s get cracking!

PHPUnit Assertions to know about

Currently, PHPUnit is at version 9.5. As per the latest docs, there are 60 assert methods you can use in your PHPUnit tests.

These PHPUnit assertions range from checking if array has a key to the ever-popular assert equals to the not…


A hands-on guide to optimally configured crons

Image of clock
Image of clock

Kubernetes is super effective in running cron jobs — as well as other web application workloads. A Kubernetes cron job is a special kind of Kubernetes job that runs on a time-based schedule. In this post, we will focus on how to run optimally configured cron jobs on Kubernetes.

What Is Kubernetes?

Kubernetes has multiple definitions. We will first look at a couple of them and then try to simplify them. The official “What is Kubernetes?” page on Kubernetes.io:

“Kubernetes is a portable, extensible, open-source platform for managing containerized workloads and services, that facilitates both declarative configuration and automation.”

It further adds, “The…


Restart your web apps automatically and efficiently

Hand holding Pokeball
Hand holding Pokeball

If you are developing any Node.js application, nodemon is one of the necessary weapons in your arsenal. Learn how to install and effectively use nodemon to automatically restart your Node.js application on every relevant file change.

Do you want to restart your Node.js web server and save loads of development time? In this article, we are going to see how you can utilize nodemon with any Node.js application easily.

A Quick Intro

Having nodemon to watch your file changes is like having an eagle watching over its prey. On every file save, your Node.js server is automatically restarted for you.

Even nodemon’s slogan…


Transactions are one of the important features of a relational database. In this Node.js MySQL transaction walkthrough, we will look into how it can help you achieve data consistency pushing the difficult stuff to the database level. Let’s get started!

What is a database transaction?

The simplest way to define a relational database transaction is “all or nothing”. You can run a sequence of SQL queries, for example, you can run 4 SQL queries. If there is an issue in the third one the whole thing can be rolled back reverting the state of the data to before any queries were run.

Wikipedia says:

A…


A practical example for better HTTP performance

time-lapse photo of headlights and taillights on a highway at night
time-lapse photo of headlights and taillights on a highway at night

Memoization is simply caching the output of a function so that the consequent calls just use the cached result, eliminating any heavy computation. Memoization in JavaScript can also yield amazing performance benefits, given that it is implemented properly.

Do you want to make your JavaScript code run much faster? In this article, we will have a look at a practical example of JavaScript memoization.

Spoiler alert: You will not see a Fibonacci or factorial mentioned below.

What Is Memoization?

An oversimplified definition of memoization is that when you run an expensive function with parameters a and b, you will cache the result of…


Picking the right library for the job is crucial

Wood logs
Wood logs

Using the right Node.js logging library can give you unprecedented insight into how your application is working. Having proper logging is equivalent to having a powerful telescope in a space with all your applications.

Do you want to be able to see how your application behaves under load in production? In this article, we are going to analyze five popular Node.js logging libraries that can easily do the job for you. All of them are available on NPM and are downloaded more than 1 million times each week, so they are pretty darn popular.

Let’s get started!

Assumptions

  1. You are familiar…


(with step-by-step deployment examples for all 3 of them)

Hosting Node.js applications is easy, finding a completely free Node.js hosting service that is reliable is not. In this post, we will discuss 3 hosting services where you can host your Node.js applications or API for free which you should start using now.

We will also deploy a demo app step-by-step on each of these 3 platforms. I wished to have found more than 3 but finding even 3 was not very easy.

Table of contents

· Table of contents
· Free Node.js Hosting options
· Prerequisites
· Free Node.js hosting services
· Issues with these services
· Free Node.js hosting platforms to deploy your app
· Heroku
∘…


Let’s use Helmet, the must-have tool to safeguard your Express.js apps

Toy robot
Toy robot

Security is everyone’s responsibility. Helmet protects your Node.js application from some obvious threats. While writing a Node.js + Express.js application, always use Helmet to safeguard your application or API from the usual security risks like XSS, Content Security Policy, and others.

In this article, we will see how we can add Helmet to an existing API and how it bolsters the security of the application. Let’s get started!

Table of Contents

· Web application security
· Handy OWASP cheat sheets
· Node.js Web application security
· Example Express Js application
· Express without Helmet Js
· Express Helmet to the rescue
· Helmet js with sane defaults
· Response headers…


The optimally correct logging Node.js logging library can give you unprecedented insights into how your application is working. Having proper logging is equivalent to having a powerful telescope in a space with all your applications.

Do you want to be able to see how your application behaves under load in production? In this post, we are going to analyze 5 popular Node.js logging libraries that can easily do the job for you.

Table of contents

· Assumptions
· Node.js logging libraries to evaluate
Winston
Bunyan for Node.js logging
Pino
Loglevel
Npmlog
· A quick comparison of Node.js …


PHPUnit has been blowing away its competition for more than 5 years now. With the use of the right PHPUnit assertions, you can get the most benefit out of PHPUnit. In this post, we will look into some popular and very useful PHPUnit assertions you should be using day to day in your PHPUnit tests. Let’s get cracking!

PHPUnit Assertions to know about

Currently, PHPUnit is at version 9.5. As per the latest docs, there are 60 assert methods you can use in your PHPUnit tests.

These PHPUnit assertions range from checking if array has a key to the ever-popular assert equals to the not…

Geshan Manandhar

Lead Software Engineer, Agile follower. Technologist, Google Developer Expert. Blogging at geshan.com.np

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store