Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6926899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:58:40+00:00 2026-05-27T10:58:40+00:00

90% of our code is linear in nature. We have functions spread around in

  • 0

90% of our code is linear in nature. We have functions spread around in some places, but our code generally looks like this:

<?php

// gather some data
// do something with that data
// instantiate a bunch of globals

// output a bunch of stuff to the browser

include_once "file.php";

// output some more stuff
include_once "file2.php";

// ad nauseum

then in file.php

<?php

// do something with the globals from above
// gather some more data
// do something with this newfound data
// output more stuff to the browser

As part of moving to a cleaner code base, I want to begin testing this, but I’m unsure as to the proper way to do that. Any suggestions? I’m at a loss as to the proper method.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T10:58:41+00:00Added an answer on May 27, 2026 at 10:58 am

    As others have commented, you’ve essentially written procedural code. That type of code is typically not very conducive to Unit Testing or Test Driven Development. To begin with, you should probably become familiar with Object Oriented Programming and start grouping related pieces of functionality into appropriate abstractions.

    You could try looking for Link Seams and other such tricks, but you’re likely in for a world of hurt unless you start changing the paradigm. Unless you can break your procedural PHP into enough tiny files with set input and output points that you can test each in isolation. But that will definitely require creating methods and eliminating as many of the GLOBALS as possible.

    The first thing you need to do is probably read Chapter 19 of Michael Feathers’ Working Effectively with Legacy Code. In fact, read the whole book. Because the “seemingly simple bit” of adding tests is going to require a paradigm shift.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In our code we used to have something like this: *(controller->bigstruct) = ( struct
Bumped into some code like this in our code base... which made me worried.
In our code we have quite a few cases of this pattern: class outerClass
In many places in our code we have collections of objects, from which we
So currently in our code, we have a bunch of classes around accessing roles
Our code has something like this: @Resource(name = java:comp/resource/foo/bar/ONE_QUEUE) private Queue queue; However, in
I have code like this: try: request=parse_request except: print cannot parse your malformed request
In our code I have the following, for now please ignore the //* bits;
I just saw some code in our code base (and it's OLD code, as
We are trying to port our code from HPX to AIX but getting core

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.