title: CakePHP running in subdirectory creates problems with URLs in shell, web and unit-tests?
body: <p>I am using CakePHP 2.9.7 and am trying to write a shell which is supposed to send mails with links (<code>Router::url()</code>) in them. The link will point to a page in my CakePHP application which will send another mail with another link. So we have one mail sent from the shell and one mail sent from within the application.</p>
  
  <p>The documentation thaught me to set <code>App.fullBaseUrl</code> if I want to use routing in shells: <a href="https://book.cakephp.org/2.0/en/console-and-shells.html#routing-in-shells-cli" rel="nofollow noreferrer">https://book.cakephp.org/2.0/en/console-and-shells.html#routing-in-shells-cli</a>. Since I wasn't sure if this includes the full base path, I just asked and learned that it indeed does. So I did set <code>App.fullBaseUrl</code> to something like <code>http://example.com/my_app</code>. The mail sent in the shell works like a charm now! 
  However, some other links, e.g. the ones in mails sent from within the application are now broken because they point to <code>http://example.com/my_app/my_app</code>. I think it has something to do with me wanting the full URL for those links. Most other links work fine, because I don't ask for the full URL. However, if I pass along the <code>'full_base' =&gt; true</code> option in the HtmlLinkHelper, the same issue occurs.</p>
  
  <p>I found this: <a href="https://github.com/cakephp/cakephp/pull/1718" rel="nofollow noreferrer">https://github.com/cakephp/cakephp/pull/1718</a> so I guessed this would solve my pain and I just set <code>App.fullBaseUrl</code> to <code>http://example.com</code> and App.base to <code>/myapp</code>. This works great in both usages. 'Yay' I thought and ran all the unit tests. They don't work anymore.</p>
  
  <p>My unit tests make extensive use of <code>$this-&gt;testAction()</code> (in ControllerTests) and all the $this->testAction calls are now broken. 
  For example: I have an index action in my CartController which can only be called through GET so we wrote a test to call it through POST. This worked until I set 'App.base'.</p>
  
  <pre><code>public function testIndexPost() {
      $this-&gt;testAction(
          array(
              'controller' =&gt; 'Cart',
              'action' =&gt; 'index',
          ),
          array(
              'method' =&gt; 'POST',
              'return' =&gt; 'vars',
          )
      );
  }
  </code></pre>
  
  <p>Now I get an Error: </p>
  
  <blockquote>
    <p>Failed asserting that exception of type "MissingActionException" matches expected exception "MethodNotAllowedException". Message was: "Action CartController::Cart() could not be found.".</p>
  </blockquote>
  
  <p>Stack trace:</p>
  
  <pre><code>Action CartController::Cart() could not be found.
  Test case: CartControllerTest(testIndexPost)
  
  Stack trace:
  F:\dev\xampp\htdocs\my_app\vendor\cakephp\cakephp\lib\Cake\Routing\Dispatcher.php : 193
  F:\dev\xampp\htdocs\my_app\vendor\cakephp\cakephp\lib\Cake\Routing\Dispatcher.php : 167
  F:\dev\xampp\htdocs\my_app\vendor\cakephp\cakephp\lib\Cake\TestSuite\ControllerTestCase.php : 287
  ControllerTestCase::_testAction
  F:\dev\xampp\htdocs\my_app\vendor\cakephp\cakephp\lib\Cake\TestSuite\ControllerTestCase.php : 199
  F:\dev\xampp\htdocs\my_app\app\Test\Case\Controller\CartControllerTest.php : 83
  F:\dev\xampp\htdocs\my_app\app\Test\Case\Controller\CartControllerTest.php : 83
  CartControllerTest::testIndexPost
  F:\dev\xampp\htdocs\my_app\vendor\phpunit\phpunit\PHPUnit\Framework\TestCase.php : 988
  F:\dev\xampp\htdocs\my_app\vendor\phpunit\phpunit\PHPUnit\Framework\TestCase.php : 838
  F:\dev\xampp\htdocs\my_app\vendor\phpunit\phpunit\PHPUnit\Framework\TestResult.php : 648
  F:\dev\xampp\htdocs\my_app\vendor\phpunit\phpunit\PHPUnit\Framework\TestCase.php : 783
  F:\dev\xampp\htdocs\my_app\vendor\cakephp\cakephp\lib\Cake\TestSuite\CakeTestCase.php : 82
  F:\dev\xampp\htdocs\my_app\vendor\phpunit\phpunit\PHPUnit\Framework\TestSuite.php : 779
  F:\dev\xampp\htdocs\my_app\vendor\phpunit\phpunit\PHPUnit\Framework\TestSuite.php : 749
  F:\dev\xampp\htdocs\my_app\vendor\phpunit\phpunit\PHPUnit\TextUI\TestRunner.php : 350
  F:\dev\xampp\htdocs\my_app\vendor\cakephp\cakephp\lib\Cake\TestSuite\CakeTestRunner.php : 62
  F:\dev\xampp\htdocs\my_app\vendor\cakephp\cakephp\lib\Cake\TestSuite\CakeTestSuiteCommand.php : 98
  F:\dev\xampp\htdocs\my_app\vendor\cakephp\cakephp\lib\Cake\TestSuite\CakeTestSuiteDispatcher.php : 259
  F:\dev\xampp\htdocs\my_app\vendor\cakephp\cakephp\lib\Cake\TestSuite\CakeTestSuiteDispatcher.php : 96
  F:\dev\xampp\htdocs\my_app\vendor\cakephp\cakephp\lib\Cake\TestSuite\CakeTestSuiteDispatcher.php : 113
  F:\dev\xampp\htdocs\my_app\webroot\test.php : 104
  </code></pre>
  
  <p>I could of course set <code>'base' =&gt; false</code> (which makes it work again) but that just doesn't feel right. I shouldn't have to change all my tests just because I set <code>App.base</code> in my application, right?</p>
  
  <p>So whatever I do, I can't get this routing to work with all of CLI, web and unit-tests. One of them always gets messed up.</p>
  
  <p>Am I doing something wrong?<br>
  Is there a better way to deal with these things?<br>
  Is this a bug?</p>