Skip to content

PHP upgrade without tests: how do you prove nothing has changed?

Your hosting provider is switching off your PHP version, whoever built the application is gone, and there are no automated tests. A blank white page the morning after the upgrade is the smaller risk, because everyone notices it right away. More dangerous is an invoice that rounds a few Rappen (Swiss cents) differently after the upgrade without anyone noticing. Here you’ll see how to prove that nothing has changed without existing tests, the way Unique-P does it in upgrade and takeover projects.

By Dimitri König5 min read

How a PHP upgrade works overall, how big the step from your PHP version is and when the framework has to move too is covered in the article PHP upgrade. Within that process, the before-and-after comparison provides the proof that your application calculates and works the same way after the PHP upgrade as it did before.

Why is a PHP upgrade without tests risky?

A PHP upgrade without tests is risky because new PHP versions change the behavior of individual functions without the application crashing. Which functions are affected is listed in the migration notes on php.net for every version, for example for the move to PHP 8.4.

Errors that show up right away are the smaller problem in a PHP upgrade: someone reports a page with an error message on the first morning. The tricky part is silent deviations in amounts, rounding, date calculations or character counts that only become visible in an invoice, a billing run or an export.

In upgrade projects at Unique-P, one principle therefore applies: an application that “runs” after the PHP upgrade doesn’t necessarily calculate the same way. Only a comparison can prove that it does.

What is a before-and-after comparison?

A before-and-after comparison, also called a golden master or characterization test, records how an application behaves today and checks whether it behaves the same way after a change. It doesn’t ask whether a result is correct, but whether it has stayed the same. In a pure PHP upgrade, that is exactly the question.

A before-and-after comparison needs neither existing tests nor documentation. That makes it especially suitable for applications whose developer is no longer available. How to take over such an application as a whole is covered in the article taking over a PHP application without documentation.

How does a before-and-after comparison work in a PHP upgrade?

  1. The live version as the baseline. The before-and-after comparison starts with the code that runs live today, not with the state in the repository. If the two differ, for example because of fixes made directly on the server, the live version counts.
  2. A copy of the data in a separate test environment. The old and new versions run on the same copy of the data, separate from live operations. Emails go to a test mailbox, payments and outgoing interfaces are blocked, and the data location and the client’s consent are settled beforehand.
  3. Old and new versions side by side. The old version runs on the previous PHP version, the new one on the target version. Everything else stays the same: libraries, configuration, time zone and data.
  4. Comparison on several levels. A script calls the same functions, pages and workflows in both versions and compares the results, from individual calculated values to the finished invoice as a PDF.
  5. Filter out the noise. Timestamps, sequential numbers and technical IDs differ on every run. So that they don’t hide real deviations, the comparison filters them out. Two runs of the old version show what normal noise looks like.
  6. Cross-check. A before-and-after comparison is only worth something if it can find errors. Without the code adjustments, it has to raise an alarm on the new PHP version. If it stays silent, it isn’t checking enough.
  7. Business sign-off. The business department checks what only it can judge: amounts against real documents, and workflows with external systems that are blocked in the test environment.

What belongs in a before-and-after comparison?

Level What is compared What to watch for
Calculations Amounts, VAT, rounding and discounts with many input values, including edge cases Rounding and floating-point numbers are the first to react to a new PHP version
Pages and downloads Every URL for every user role: status code and content Filter out timestamps and session data
Documents Invoices, quotes, PDF and Excel exports Filter out creation dates and technical IDs
Write operations Creating an order, generating an invoice, changing a status: the entries in the database Normalize timestamps and ordering
Emails Recipients, subject and body Send only to the test mailbox
Interfaces Requests to and responses from external systems Usually blocked in the test environment, so part of the business review

Pure PHP upgrade or modernize right away?

A pure PHP upgrade changes only what the new PHP version requires: all libraries keep their version, features stay the same, and known bugs are deliberately left in place. Every additional change brings another round of comparisons and business tests.

A pure PHP upgrade is especially worthwhile if the application will soon be replaced or keeps running as an archive. Improvements and bug fixes come afterward as a separate stage, with their own comparison. Which effort is still worth it before a replacement is covered in the article legacy system until replacement.

Which target version fits depends on the deadlines: according to php.net, PHP 8.2 gets security updates only until December 31, 2026, and PHP 8.4 until December 31, 2028. All dates are in the article PHP end of life.

How does the PHP upgrade go live without customers noticing?

  • New version next to the old one. The new version is ready on the server before the switch. The old version stays in place next to it, unchanged.
  • Fresh backup. The database is backed up right before switching to the new PHP version.
  • Switch in stages. First the PHP version and the code change, then every further change follows on its own, such as new restrictions in the server configuration. The same checks run after each stage.
  • A way back in minutes. If the database fits both versions, a prepared rollback returns to the old version within a few minutes. The way back stays open until the new version has had a few quiet days.

Where does the experience in this article come from?

The experience in this article comes from upgrade and takeover projects by Unique-P with PHP applications whose developer was no longer available. Names, figures and details of individual clients are deliberately left out: confidentiality is part of working on other people’s applications.

How big the PHP upgrade will be for your application and which checks it needs is clarified by the Takeover Assessment from Unique-P within 5 business days of full access.

Sources

  1. [1]Supported Versions · php.net
  2. [2]Migrating from PHP 8.3.x to PHP 8.4.x · php.net
  3. [3]Characterization test · Wikipedia

Frequently asked questions.

Do I need automated tests for a PHP upgrade?

You don’t need existing automated tests for a PHP upgrade if a before-and-after comparison sets the behavior of the old and new versions side by side on the same data. If there are no tests at all, this comparison is the fastest way to solid proof. Afterward, it’s worth keeping the most important workflows from the comparison as permanent tests.

Is a click-through test by the business department enough after the PHP upgrade?

A click-through test by the business department alone is rarely enough after a PHP upgrade, because silent deviations in amounts or rounding are hard to spot by eye. Such a test complements the before-and-after comparison where only the business department can judge: amounts checked against real documents, and workflows involving external systems.

Can I use real data for the comparison?

Real data for a before-and-after comparison needs clear rules: a test environment separate from live operations, blocked email sending, anonymized data where possible and a data location the client has agreed to. Many contracts, especially at certified companies, also regulate the use of cloud and AI tools. Clear this up before anyone first accesses the data.

How long does a PHP upgrade with a before-and-after comparison take?

How long a PHP upgrade with a before-and-after comparison takes depends mainly on the starting version, the framework and the number of workflows. A small step such as from PHP 8.1 to PHP 8.4 often takes only a few days of work for a well-maintained application. The pace is usually set by access, the test environment and sign-off, not by the code.

Effort by PHP version

What happens to known bugs during the PHP upgrade?

Known bugs are deliberately left unchanged in a pure PHP upgrade so that the before-and-after comparison stays unambiguous: every deviation is then a consequence of the new PHP version. Bug fixes follow as a separate stage, with their own comparison.