#!/bin/bash

DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

# Installed as a dependency
if [ -f "$DIR/../autoload.php" ]; then
    php -S 127.0.0.1:10000 -t "$DIR/../php-http/client-integration-tests/fixture"
# Development
elif [ -f "$DIR/../vendor/autoload.php" ]; then
    php -S 127.0.0.1:10000 -t "$DIR/../fixture"
# Installed as a dependency, but not accessed using the symlink (e.g. Windows)
elif [ -f "$DIR/../composer.json" -a -f "$DIR/../fixture/server.php" ] && grep -q php-http/client-integration-tests "$DIR/../composer.json"; then
    php -S 127.0.0.1:10000 -t "$DIR/../fixture"
# Not working
else
    echo "*** Can't find the fixture folder ***" >&2
    echo "Please write your own way to start a PHP web server on port 10000 for the 'fixture' directory." >&2
    exit 1
fi
