From fe84dfa4fe3a6d146ff8aafc8a8bb7275b8c8070 Mon Sep 17 00:00:00 2001
From: mattab <matthieu.aubry@gmail.com>
Date: Mon, 30 Sep 2013 12:07:13 +1300
Subject: [PATCH] Updating readme with instructions to chmod 777 the tmp/
 directories when running phpunit tests suite on dev + adding tmp/logs to
 directories that are automatically created

---
 core/FrontController.php            |  7 ++++---
 plugins/Installation/Controller.php |  7 ++++---
 tests/README.md                     | 25 ++++++++++++++++++++++++-
 3 files changed, 32 insertions(+), 7 deletions(-)

diff --git a/core/FrontController.php b/core/FrontController.php
index a97337e97d..77e1f73714 100644
--- a/core/FrontController.php
+++ b/core/FrontController.php
@@ -228,10 +228,11 @@ class FrontController
 
             $directoriesToCheck = array(
                 '/tmp/',
-                '/tmp/templates_c/',
-                '/tmp/cache/',
                 '/tmp/assets/',
-                '/tmp/tcpdf/'
+                '/tmp/cache/',
+                '/tmp/logs/',
+                '/tmp/tcpdf/',
+                '/tmp/templates_c/',
             );
 
             Filechecks::dieIfDirectoriesNotWritable($directoriesToCheck);
diff --git a/plugins/Installation/Controller.php b/plugins/Installation/Controller.php
index 234467f0e0..3c66647838 100644
--- a/plugins/Installation/Controller.php
+++ b/plugins/Installation/Controller.php
@@ -721,12 +721,13 @@ class Controller extends \Piwik\Controller\Admin
 
         $directoriesToCheck = array_merge($directoriesToCheck, array(
                                                                     '/tmp/',
-                                                                    '/tmp/templates_c/',
-                                                                    '/tmp/cache/',
                                                                     '/tmp/assets/',
+                                                                    '/tmp/cache/',
                                                                     '/tmp/latest/',
-                                                                    '/tmp/tcpdf/',
+                                                                    '/tmp/logs/',
                                                                     '/tmp/sessions/',
+                                                                    '/tmp/tcpdf/',
+                                                                    '/tmp/templates_c/',
                                                                ));
 
         $infos['directories'] = Filechecks::checkDirectoriesWritable($directoriesToCheck);
diff --git a/tests/README.md b/tests/README.md
index f09999d9a3..0ddf056077 100644
--- a/tests/README.md
+++ b/tests/README.md
@@ -4,6 +4,7 @@ This document briefly describes how to use and modify Piwik tests.
 ## How To Run Piwik Tests
 
 To run tests, you must use the Git master. Tests files are not in the Piwik zip archive.
+
 You can get the latest Git revision at: http://github.com/piwik/piwik
 
 ```
@@ -15,7 +16,10 @@ To execute the tests:
  * In your php.ini make sure you have the setting to show all errors:
  `error_reporting = E_ALL | E_STRICT`
 
- * Go to tests/index.php to see the tests homepage and run the Integration tests via a visual UI, or run JS Tests
+ * Go to tests/index.php to see the tests homepage
+   and run the Integration tests via a visual UI, or run JS Tests
+
+ * Next you will need to install PHPUnit
 
 ## Integration Tests
 
@@ -75,6 +79,24 @@ Otherwise, if you didn't expect to modify the API outputs, it might be that your
 5.	Write more tests :)
 	See ["Writing Unit tests with PHPUnit"](http://www.phpunit.de/manual/current/en/writing-tests-for-phpunit.html)
 
+### PHP 5.5: also update PHPUnit to latest
+
+See http://phpunit.de/manual/current/en/installation.html
+or try:
+    $ sudo pear install -a phpunit/PHPUnit
+
+### Troubleshooting
+
+If you get any of these errors:
+ * `RuntimeException: Unable to create the cache directory ( piwik/tmp/templates_c/66/77).`
+ * or `fopen( piwik/tmp/latest/testgz.txt): failed to open stream: No such file or directory`
+ * or `Exception: Error while creating the file: piwik/tmp/latest/LATEST`
+ * or `PHP Warning:  file_put_contents( piwik/tmp/logs/piwik.test.log): failed to open stream: Permission denied in [..]`
+
+On your dev server, give your user permissions to write to the directory:
+
+    $ sudo chmod 777 -R piwik/tmp/templates_c/
+
 ## JavaScript Tests
 
 piwik.js is unit tested and you can run tests via piwik/tests/javascript/
@@ -101,6 +123,7 @@ You should now have some interesting data to test with in November 2012!
 ## Selenium Webdriver tests
 
 We would like to add Webdriver selenium testing for the following: installation, auto update from 1.0, initial user login.
+
 Task is tracked in: http://dev.piwik.org/trac/ticket/2935
 
 ## Scheduled Reports Tests
-- 
GitLab