├── bash ├── just-run-phpunit └── README.md ├── LICENSE └── README.md /bash/just-run-phpunit: -------------------------------------------------------------------------------- 1 | # Default locations we expect PHPUnit may live 2 | # 3 | # It is safe to extend this by exporting a new copy of PHPUNIT_PATH with 4 | # additional locations. Just make sure that happens after this section of code 5 | # is run. 6 | PHPUNIT_PATH=vendor/bin:bin 7 | 8 | function phpunit { 9 | IFS=":" 10 | TEST_PATHS=($PHPUNIT_PATH) 11 | for TEST_PATH in "${TEST_PATHS[@]}" 12 | do 13 | if [ -x "${TEST_PATH}/phpunit" ] 14 | then 15 | "${TEST_PATH}/phpunit" "$@" 16 | return $? 17 | fi 18 | done 19 | 20 | PHPUNIT_ON_PATH="$(type -P phpunit )" 21 | if [ -n "${PHPUNIT_ON_PATH}" ]; then 22 | "${PHPUNIT_ON_PATH}" "$@" 23 | return $? 24 | else 25 | echo "phpunit not found in any location we expect it to be found" 26 | return 127 27 | fi 28 | } -------------------------------------------------------------------------------- /bash/README.md: -------------------------------------------------------------------------------- 1 | Just Run PHPUnit for Bash 2 | ========================= 3 | 4 | The goal is literally to allow developers to "just run phpunit." No more having 5 | to decided if you need to run `vendor/bin/phpunit`, `bin/phpunit`, or `phpunit`, 6 | just run `phpunit` and this utility takes care of the rest. 7 | 8 | 9 | Installation 10 | ------------ 11 | 12 | The `just-run-phpunit` file in this directory must be sourced in some way. This 13 | can be done manually during an interactive session or it can be done by sourcing 14 | it in `.profile`, `.bash_profile`, `.bashrc`, or some other means. This seems to 15 | vary greatly depending on the distro so this exercise is left up to the user to 16 | decide the best way to get this accomplished. 17 | 18 | Assuming that `.bashrc` is processed on every login, you would add the following 19 | to `.bashrc`: 20 | 21 | # Source the Bash specific instance of just-run-phpunit 22 | . ~/workspaces/just-run-phpunit/bash/just-run-phpunit 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 Dragonfly Development Inc. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is furnished 8 | to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Just Run PHPUnit 2 | ================ 3 | 4 | The goal of this project is to allow PHP developers to just type naked `phpunit` 5 | wherever they are but actually executing `vendor/bin/phpunit` for projects that 6 | have PHPUnit required via Composer and falling back to a globally installed 7 | version of PHPUnit if not. 8 | 9 | So the goal is literally to allow developers to "just run phpunit." No more 10 | having to decided if you need to run `vendor/bin/phpunit`, `bin/phpunit`, or 11 | `phpunit`, just run `phpunit` and this utility takes care of the rest. 12 | 13 | 14 | Usage 15 | ----- 16 | 17 | Include the appropriate `just-run-phpunit` script from one of the shell 18 | subdirectories. This file will likely need to be sourced in such a way that the 19 | functions or aliases become available when your user logs in. This differs from 20 | shell to shell. 21 | 22 | In all cases, this utility relies on the `PHPUNIT_PATH` environment variable. It 23 | contains a list of `:` separated paths similar to the `PATH` environment 24 | variable. Each path will be checked for an executable file called `phpunit`. The 25 | first time this file is found it will be executed and the return value of the 26 | execution is returned. 27 | 28 | The `PATH` is queried last to determine if a globaly installed version of 29 | PHPUnit is available. 30 | 31 | If you need to extend the search path (say you regularly have Composer's vendor 32 | bin redirected somewhere non-standard like `vendor-bins`) you can prepend or 33 | append it to `PHPUNIT_PATH`. For example: 34 | 35 | export PHPUNIT_PATH="${PHPUNIT_PATH}:vendor-bins" 36 | 37 | This will ensure that `vendor-bins` will be checked after the other default 38 | paths have been checked. 39 | --------------------------------------------------------------------------------