RFCs/Ticket929

RFC: Refactor AgaviConfigCache::callHandler() to be more modular and testable (#929)

General Information

  • Initial date: 2008-11-24 15:48:00 UTC
  • Status: implemented
  • Scheduled for: Agavi 1.0

Motivation

The current AgaviConfigCache::callHandlers() method is pretty much impossible to test as it's monolithic and long

Goals

  • make it possible to test the config cache.

Proposal

Split AgaviConfigCache::callHandler() into three seperate methods:

  • setupHandlers() containing all the code to check if the handler config buffer is dirty
  • getHandlerInfo() containing the code to load the handler information from the config
  • executeHandler() doing the real work

Add a new argument $handlerInfo with default value null to callHandler(). If any information is passed, the config file will be parsed with the given handler and the setupHandlers() and getHandlerInfo() methods will be skipped.

Make the methods protected and the class non-final to allow a testing stub to overwrite each function and make it public for testing purposes.

Resources

  • #929 is the associated ticket