dnoegel/php-xdg-base-dir — pull request #4 by nubs (2014-08-20 01:27:42+00:00)
Title: Add file lookup methods.  Fixes #3.

These convenience methods help make it easy to use this library without having to duplicate this lookup code everywhere.

Testing
-------
This does not add tests. I could see several different ways of doing tests, but they all have drawbacks.
* Use putenv() and set to temporary directories where we can create files. I really don't like tests that have write access to filesystem however. They feel fragile, may not work in certain environments, and can leave stuff around on the filesystem (especially if the test fails).
* Use a virtual filesystem like [php-vfs] or [vfsStream]. These are a bit funny as they don't support all filesystem features and you have to deal with "filenames" that begin with "vfs://".
* Use [isolator] to allow the global filesystem functions to be mocked in tests. This can be done without adding an actual dependency on `Isolator` in a manner similar to [here][which-isolator].

My personal favorite is the Isolator method. That allows truly anything to be done and the full defaults of the library to be tested (like the /etc/xdg path) without mucking with the actual filesystem.

[php-vfs]: https://packagist.org/packages/php-vfs/php-vfs
[vfsStream]: https://packagist.org/packages/mikey179/vfsStream
[isolator]: https://packagist.org/packages/icecave/isolator
[which-isolator]: https://github.com/nubs/which/blob/7fca24e5798405f5088e825d1c9296c867da7410/src/ExecutableTester.php