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

  • SEARCH
  • Home
  • 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 7679205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:49:28+00:00 2026-05-31T17:49:28+00:00

I am trying to test our source tree using PHPUnit with old, web based

  • 0

I am trying to test our source tree using PHPUnit with old, web based legacy code, trying to make as few changes as possible to begin. Once testing is in place, I can then change the library functions for better use, and better unit testing. However, I need the tests done to allow me to change it.

Question: We share the library code across many projects of our application, but they all share a common directory structure. When the website runs, local directories are available when we require files in the library.

Consider this:

APP1
APP2
Library
Library/COMM
Library/UTIL
...

When you launch the application, you point to either APP1 or APP2 for the different applications. They have the common code (messaging, DB access, etc…). in Library. The problem is, that the functions in the library need special parameters to work, as they are coded today. These libraries simply require(‘Config.php’); since it will be found in either APP1 or APP2 (they both have one with application specific settings) and the web server is using the APP1 or APP2 as the directory when the Library files were require()’d.

While this works, it fails when attempting to run the code in PHPUnit. My question is how to include the Config.php file without having to change the legacy code too much before the testing is in place.

I know this is the wrong format, but this is what I inherited.

I can not simply require(‘../../APP1/Config.php’); since both applications share this library.

Any suggestions are greatly appreciated.

Note: We are trying to test the library and all projects as we begin writing tests, so not sure if the include_path will solve it. I am contemplating different PHPUnit.xml.dist files for each application, but trying to avoid this right now due to corporate influence of testing all applications right away.

  • 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-31T17:49:30+00:00Added an answer on May 31, 2026 at 5:49 pm

    From phpunit.xml (<phpunit bootstrap=”./bootstrap.php”>…) and from the cli (–bootstrap ./bootstrap.php) you can specify a bootstrap file. In that file you could do this inclusion you are looking to do.

    As word of advice, when stating to test a legacy code base don’t start with Unit test. Your first goal should be “get some kind of automated tests in place”. For most people, this will be system tests. That is testing the stack/site as a whole. A common tools for this is Selenium.

    This is still not small task. What you are going to have to do it work out “how do I put my system in to a consistent state”. The first thing you may need to do is automate importing and emptying test data in your database. Once you can do that you will be able to reliably run automated tests. You will need to get many other things to be consistent also, date and times being a good example.

    My point is that, from experience, starting with Unit tests will not give you the value you need to prove that automated testings is worth the effort.

    Good luck!

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

Sidebar

Related Questions

We are trying to test our mobile web site on various Android simulators as
I'm trying to create a http request to our web service, my test XML
I'm writing an auto testing framework using Selenium. I am trying to test our
I'm trying to use JMeter to test our web application and I'd like to
I am trying to test a function in company product. Our software will make
Using the following code I am trying to scrape a call log from our
I'm trying to A/B test our product drop view. below is the javascript code
I'm trying to test a proposition that one of our vendors presented to us
I'm trying to test out the GettingStarted sample site with our LE instance but
I am trying to create a test harness for our QA staff to test

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.