ExpandPath and Mod Rewrite Issue (problems with unit testing in ColdBox)

I wanted to share an issue we had with mod_rewrite, expandpath and
unit testing in ColdBox, and how we fixed it. If someone else posted
information about this issue, please feel free to delete, and sorry
it's so long.

Let me start with details of my platform:

ColdBox 3.1
MXUnit 2.1.1
ColdFusion Builder 2
ColdFusion 9
Apache 2.2.16
Windows 7

Our project is located at the root of the web site. Most of the
examples of setting up unit testing I saw had the coldbox app in a sub-
folder.

For a project I'm working on we decided to use SES/Pretty URL for the
url routes.

We started using the standard .htaccess file which comes with the
Advanced project template and had no problems with invoking events
with the new url patterns.

However, the problem occurred when we started building unit tests.

Here was the primary error from the mxunit plugin in CFBuilder:

     XMLApplicationLoader.ConfigXMLFileNotFoundException: The Config
File: [Bad Path here] can't be found.

Note: we don't use the xml config.

Now in running the test/TestSuite.cfm, we receive a different error:

     The .integration.GeneralTest name is not a valid component or
interface name.
      Component and interface names cannot be empty and cannot start
or end with a period.

After reading all the posts here and other sites, it didn't seem to be
a problem with ColdBox or the mxunit setup.

It's an issue with how the expandPath calculates the directory and the
particular set up of the .htaccess file.

For example, in the GeneralTest.cfc, the appMapping is set to "/" (I
think I don't need that even).

<cfcomponent extends="coldbox.system.testing.BaseTestCase"
appMapping="/">

After looking at the coldbox/system/testing/BaseTestCase.cfc, I notice
the expandPath on line 96.
appRootPath = expandPath(instance.appMapping);

I did some experimenting with expandPath function:

#expandPath("/")# result: redirect:\index.cfm\\
OR
#expandPath("\")# result: redirect:\index.cfm\\

Of course, those results were causing the problem.

Luckily, I found this: http://old.nabble.com/Re%3A-expandPath()-and-mod_rewrite-td15057484.html

The current htaccess file has the following syntax:
RewriteRule ^(.*)$ index.cfm/%{REQUEST_URI} [QSA,L]

I modified to this:
RewriteRule ^(.*)$ index.cfm/%{REQUEST_URI} [NS,QSA,L]

After making that small change, expandPath worked correctly and both
the mxunit plugin and testsuite.cfm worked!

Ok, back to coding. I hope this helps someone.

Thanks,

Richard