diff --git a/Dockerfile b/Dockerfile new file mode 100755 index 0000000..d59a1aa --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +FROM php:5.6-apache + +RUN apt-get update \ + && apt-get install -y git curl bzip2 vim libssl-dev zlib1g-dev libxrender1 libicu-dev g++ libjpeg-dev libjpeg62 libfontconfig-dev \ + && pecl install xdebug \ + && echo zend_extension=xdebug.so > /usr/local/etc/php/conf.d/xdebug.ini \ + && pecl install apcu-beta \ + && echo extension=apcu.so > /usr/local/etc/php/conf.d/apcu.ini \ + && docker-php-ext-install zip mbstring intl pdo_mysql \ + && apt-get -y install mysql-client php5-gd + +ADD docker/vhost.conf /etc/apache2/sites-enabled/000-default.conf +ADD docker/php.ini /usr/local/etc/php/php.ini + +RUN a2enmod rewrite + +RUN curl -sS https://getcomposer.org/installer | php \ + && mv composer.phar /usr/bin/composer + +EXPOSE 9000 + +WORKDIR /var/www/city-bike diff --git a/behat.yml.dist b/behat.yml.dist new file mode 100644 index 0000000..f8a965c --- /dev/null +++ b/behat.yml.dist @@ -0,0 +1,4 @@ +default: + extensions: + RMiller\BehatSpec\BehatExtension: + path: bin/phpspec diff --git a/composer.json b/composer.json new file mode 100755 index 0000000..976c397 --- /dev/null +++ b/composer.json @@ -0,0 +1,18 @@ +{ + "require": { + "php": ">=5.6" + }, + "autoload": { + "psr-4": { + "": "src/" + } + }, + "require-dev": { + "behat/behat": "~3.0", + "phpspec/phpspec": "~2.2", + "rmiller/behat-spec": "~0.2" + }, + "config": { + "bin-dir": "bin" + } +} diff --git a/composer.lock b/composer.lock new file mode 100755 index 0000000..1a093dc --- /dev/null +++ b/composer.lock @@ -0,0 +1,1512 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" + ], + "hash": "fd4a3f1e35583dd19b93a9f3aaf1134b", + "packages": [], + "packages-dev": [ + { + "name": "behat/behat", + "version": "v3.0.15", + "source": { + "type": "git", + "url": "https://github.com/Behat/Behat.git", + "reference": "b35ae3d45332d80c532af69cc36f780a9397a996" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Behat/Behat/zipball/b35ae3d45332d80c532af69cc36f780a9397a996", + "reference": "b35ae3d45332d80c532af69cc36f780a9397a996", + "shasum": "" + }, + "require": { + "behat/gherkin": "~4.3", + "behat/transliterator": "~1.0", + "ext-mbstring": "*", + "php": ">=5.3.3", + "symfony/class-loader": "~2.1", + "symfony/config": "~2.3", + "symfony/console": "~2.1", + "symfony/dependency-injection": "~2.1", + "symfony/event-dispatcher": "~2.1", + "symfony/translation": "~2.3", + "symfony/yaml": "~2.1" + }, + "require-dev": { + "phpspec/prophecy-phpunit": "~1.0", + "phpunit/phpunit": "~4.0", + "symfony/process": "~2.1" + }, + "suggest": { + "behat/mink-extension": "for integration with Mink testing framework", + "behat/symfony2-extension": "for integration with Symfony2 web framework", + "behat/yii-extension": "for integration with Yii web framework" + }, + "bin": [ + "bin/behat" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "Behat\\Behat": "src/", + "Behat\\Testwork": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Konstantin Kudryashov", + "email": "ever.zet@gmail.com", + "homepage": "http://everzet.com" + } + ], + "description": "Scenario-oriented BDD framework for PHP 5.3", + "homepage": "http://behat.org/", + "keywords": [ + "Agile", + "BDD", + "ScenarioBDD", + "Scrum", + "StoryBDD", + "User story", + "business", + "development", + "documentation", + "examples", + "symfony", + "testing" + ], + "time": "2015-02-22 14:10:33" + }, + { + "name": "behat/gherkin", + "version": "v4.3.0", + "source": { + "type": "git", + "url": "https://github.com/Behat/Gherkin.git", + "reference": "43777c51058b77bcd84a8775b7a6ad05e986b5db" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Behat/Gherkin/zipball/43777c51058b77bcd84a8775b7a6ad05e986b5db", + "reference": "43777c51058b77bcd84a8775b7a6ad05e986b5db", + "shasum": "" + }, + "require": { + "php": ">=5.3.1" + }, + "require-dev": { + "phpunit/phpunit": "~4.0", + "symfony/yaml": "~2.1" + }, + "suggest": { + "symfony/yaml": "If you want to parse features, represented in YAML files" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.2-dev" + } + }, + "autoload": { + "psr-0": { + "Behat\\Gherkin": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Konstantin Kudryashov", + "email": "ever.zet@gmail.com", + "homepage": "http://everzet.com" + } + ], + "description": "Gherkin DSL parser for PHP 5.3", + "homepage": "http://behat.org/", + "keywords": [ + "BDD", + "Behat", + "Cucumber", + "DSL", + "gherkin", + "parser" + ], + "time": "2014-06-06 01:24:32" + }, + { + "name": "behat/transliterator", + "version": "v1.0.1", + "source": { + "type": "git", + "url": "https://github.com/Behat/Transliterator.git", + "reference": "c93521d3462a554332d1ef5bb0e9b5b8ca4106c4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Behat/Transliterator/zipball/c93521d3462a554332d1ef5bb0e9b5b8ca4106c4", + "reference": "c93521d3462a554332d1ef5bb0e9b5b8ca4106c4", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-0": { + "Behat\\Transliterator": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Artistic-1.0" + ], + "description": "String transliterator", + "keywords": [ + "i18n", + "slug", + "transliterator" + ], + "time": "2014-05-15 22:08:22" + }, + { + "name": "doctrine/instantiator", + "version": "1.0.5", + "source": { + "type": "git", + "url": "https://github.com/doctrine/instantiator.git", + "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d", + "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d", + "shasum": "" + }, + "require": { + "php": ">=5.3,<8.0-DEV" + }, + "require-dev": { + "athletic/athletic": "~0.1.8", + "ext-pdo": "*", + "ext-phar": "*", + "phpunit/phpunit": "~4.0", + "squizlabs/php_codesniffer": "~2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "http://ocramius.github.com/" + } + ], + "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", + "homepage": "https://github.com/doctrine/instantiator", + "keywords": [ + "constructor", + "instantiate" + ], + "time": "2015-06-14 21:17:01" + }, + { + "name": "phpdocumentor/reflection-docblock", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", + "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/d68dbdc53dc358a816f00b300704702b2eaff7b8", + "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "suggest": { + "dflydev/markdown": "~1.0", + "erusev/parsedown": "~1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "phpDocumentor": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "mike.vanriel@naenius.com" + } + ], + "time": "2015-02-03 12:10:50" + }, + { + "name": "phpspec/php-diff", + "version": "v1.0.2", + "source": { + "type": "git", + "url": "https://github.com/phpspec/php-diff.git", + "reference": "30e103d19519fe678ae64a60d77884ef3d71b28a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpspec/php-diff/zipball/30e103d19519fe678ae64a60d77884ef3d71b28a", + "reference": "30e103d19519fe678ae64a60d77884ef3d71b28a", + "shasum": "" + }, + "type": "library", + "autoload": { + "psr-0": { + "Diff": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Chris Boulton", + "homepage": "http://github.com/chrisboulton", + "role": "Original developer" + } + ], + "description": "A comprehensive library for generating differences between two hashable objects (strings or arrays).", + "time": "2013-11-01 13:02:21" + }, + { + "name": "phpspec/phpspec", + "version": "2.2.1", + "source": { + "type": "git", + "url": "https://github.com/phpspec/phpspec.git", + "reference": "e9a40577323e67f1de2e214abf32976a0352d8f8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpspec/phpspec/zipball/e9a40577323e67f1de2e214abf32976a0352d8f8", + "reference": "e9a40577323e67f1de2e214abf32976a0352d8f8", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.0.1", + "php": ">=5.3.3", + "phpspec/php-diff": "~1.0.0", + "phpspec/prophecy": "~1.4", + "sebastian/exporter": "~1.0", + "symfony/console": "~2.3", + "symfony/event-dispatcher": "~2.1", + "symfony/finder": "~2.1", + "symfony/process": "~2.1", + "symfony/yaml": "~2.1" + }, + "require-dev": { + "behat/behat": "^3.0.11", + "bossa/phpspec2-expect": "~1.0", + "phpunit/phpunit": "~4.4", + "symfony/filesystem": "~2.1", + "symfony/process": "~2.1" + }, + "suggest": { + "phpspec/nyan-formatters": "~1.0 – Adds Nyan formatters" + }, + "bin": [ + "bin/phpspec" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2.x-dev" + } + }, + "autoload": { + "psr-0": { + "PhpSpec": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Konstantin Kudryashov", + "email": "ever.zet@gmail.com", + "homepage": "http://everzet.com" + }, + { + "name": "Marcello Duarte", + "homepage": "http://marcelloduarte.net/" + } + ], + "description": "Specification-oriented BDD framework for PHP 5.3+", + "homepage": "http://phpspec.net/", + "keywords": [ + "BDD", + "SpecBDD", + "TDD", + "spec", + "specification", + "testing", + "tests" + ], + "time": "2015-05-30 15:21:40" + }, + { + "name": "phpspec/prophecy", + "version": "v1.4.1", + "source": { + "type": "git", + "url": "https://github.com/phpspec/prophecy.git", + "reference": "3132b1f44c7bf2ec4c7eb2d3cb78fdeca760d373" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/3132b1f44c7bf2ec4c7eb2d3cb78fdeca760d373", + "reference": "3132b1f44c7bf2ec4c7eb2d3cb78fdeca760d373", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.0.2", + "phpdocumentor/reflection-docblock": "~2.0", + "sebastian/comparator": "~1.1" + }, + "require-dev": { + "phpspec/phpspec": "~2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4.x-dev" + } + }, + "autoload": { + "psr-0": { + "Prophecy\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Konstantin Kudryashov", + "email": "ever.zet@gmail.com", + "homepage": "http://everzet.com" + }, + { + "name": "Marcello Duarte", + "email": "marcello.duarte@gmail.com" + } + ], + "description": "Highly opinionated mocking framework for PHP 5.3+", + "homepage": "https://github.com/phpspec/prophecy", + "keywords": [ + "Double", + "Dummy", + "fake", + "mock", + "spy", + "stub" + ], + "time": "2015-04-27 22:15:08" + }, + { + "name": "rmiller/behat-spec", + "version": "0.2.0", + "source": { + "type": "git", + "url": "https://github.com/richardmiller/BehatSpec.git", + "reference": "9f36516185707d0bea384ff4285f5c36a6650442" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/richardmiller/BehatSpec/zipball/9f36516185707d0bea384ff4285f5c36a6650442", + "reference": "9f36516185707d0bea384ff4285f5c36a6650442", + "shasum": "" + }, + "require": { + "php": ">=5.4", + "rmiller/error-extension": "~0.1", + "rmiller/exemplify-extension": "~0.2", + "rmiller/phpspec-extension": "~0.1", + "rmiller/phpspec-run-extension": "~0.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "RMiller\\BehatSpec\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Richard Miller", + "email": "mrrmiller46@gmail.com", + "homepage": "http://richardmiller.co.uk" + } + ], + "description": "Behat and PhpSpec integration", + "homepage": "https://github.com/richardmiller/BehatSpec", + "keywords": [ + "BDD", + "SpecBDD", + "StoryBDD" + ], + "time": "2014-11-12 14:09:59" + }, + { + "name": "rmiller/caser", + "version": "0.1.0", + "source": { + "type": "git", + "url": "https://github.com/richardmiller/caser.git", + "reference": "ec7b0d9b5db806f5e6bcee48d6cce58efb20e834" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/richardmiller/caser/zipball/ec7b0d9b5db806f5e6bcee48d6cce58efb20e834", + "reference": "ec7b0d9b5db806f5e6bcee48d6cce58efb20e834", + "shasum": "" + }, + "require-dev": { + "phpspec/phpspec": "~2.1@dev" + }, + "type": "library", + "autoload": { + "psr-0": { + "RMiller\\Caser\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Richard Miller", + "email": "mrrmiller46@gmail.com" + } + ], + "description": "Manipulates case", + "homepage": "https://github.com/richardmiller/caser", + "time": "2014-11-02 22:15:20" + }, + { + "name": "rmiller/error-extension", + "version": "0.1.0", + "source": { + "type": "git", + "url": "https://github.com/richardmiller/ErrorExtension.git", + "reference": "26d27c7c67f99fd9d56f56147f85cbc991ca4834" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/richardmiller/ErrorExtension/zipball/26d27c7c67f99fd9d56f56147f85cbc991ca4834", + "reference": "26d27c7c67f99fd9d56f56147f85cbc991ca4834", + "shasum": "" + }, + "require": { + "behat/behat": "~3.0,>=3.0.4", + "php": ">=5.4" + }, + "require-dev": { + "phpspec/phpspec": "~2.1@dev" + }, + "type": "behat-extension", + "autoload": { + "psr-4": { + "RMiller\\ErrorExtension\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Richard Miller", + "email": "mrrmiller46@gmail.com" + } + ], + "description": "Fatal error handling extension for Behat", + "homepage": "https://github.com/richardmiller/ErrorExtension", + "keywords": [ + "BDD", + "Behat" + ], + "time": "2014-11-04 10:15:46" + }, + { + "name": "rmiller/exemplify-extension", + "version": "0.2.0", + "source": { + "type": "git", + "url": "https://github.com/richardmiller/ExemplifyExtension.git", + "reference": "c08bff7c4628d8972d2f4aeb5d02f855fd4ab843" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/richardmiller/ExemplifyExtension/zipball/c08bff7c4628d8972d2f4aeb5d02f855fd4ab843", + "reference": "c08bff7c4628d8972d2f4aeb5d02f855fd4ab843", + "shasum": "" + }, + "require": { + "php": ">=5.4", + "phpspec/phpspec": "~2.0", + "rmiller/caser": "~0.1" + }, + "require-dev": { + "behat/behat": "~3.0", + "bossa/phpspec2-expect": "~1.0", + "phpspec/phpspec": "~2.1@dev" + }, + "type": "library", + "autoload": { + "psr-4": { + "RMiller\\ExemplifyExtension\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Richard Miller", + "email": "mrrmiller46@gmail.com" + } + ], + "description": "PhpSpec extension that adds exemplify command to generate examples in specs ", + "homepage": "https://github.com/richardmiller/ExemplifyExtension", + "keywords": [ + "BDD", + "phpspec" + ], + "time": "2014-11-12 13:59:10" + }, + { + "name": "rmiller/phpspec-extension", + "version": "0.1.1", + "source": { + "type": "git", + "url": "https://github.com/richardmiller/PhpSpecExtension.git", + "reference": "df9967bd39cc20b7ab57475ccc93300c8d1ac6bb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/richardmiller/PhpSpecExtension/zipball/df9967bd39cc20b7ab57475ccc93300c8d1ac6bb", + "reference": "df9967bd39cc20b7ab57475ccc93300c8d1ac6bb", + "shasum": "" + }, + "require": { + "behat/behat": "~3.0,>=3.0.4", + "php": ">=5.4", + "phpspec/phpspec": "~2.0", + "symfony/process": "~2.1" + }, + "require-dev": { + "rmiller/error-extension": "~0.1", + "rmiller/exemplify-extension": "~0.1" + }, + "type": "behat-extension", + "autoload": { + "psr-4": { + "RMiller\\PhpSpecExtension\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Richard Miller", + "email": "mrrmiller46@gmail.com" + } + ], + "description": "PhpSpec extension for Behat", + "homepage": "https://github.com/richardmiller/PhpSpecExtension", + "keywords": [ + "BDD", + "Behat", + "phpspec" + ], + "time": "2014-12-04 12:21:14" + }, + { + "name": "rmiller/phpspec-run-extension", + "version": "0.1.0", + "source": { + "type": "git", + "url": "https://github.com/richardmiller/PhpSpecRunExtension.git", + "reference": "768400bcf73e5bf01e24146937cf241f994a2b59" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/richardmiller/PhpSpecRunExtension/zipball/768400bcf73e5bf01e24146937cf241f994a2b59", + "reference": "768400bcf73e5bf01e24146937cf241f994a2b59", + "shasum": "" + }, + "require": { + "php": ">=5.4", + "phpspec/phpspec": "~2.0" + }, + "require-dev": { + "phpspec/phpspec": "~2.1@dev" + }, + "type": "library", + "autoload": { + "psr-4": { + "RMiller\\PhpSpecRunExtension\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Richard Miller", + "email": "mrrmiller46@gmail.com" + } + ], + "description": "PhpSpec extension to execute the run command after the describe command", + "homepage": "https://github.com/richardmiller/PhpSpecRunExtension", + "keywords": [ + "BDD", + "phpspec" + ], + "time": "2014-11-12 13:49:02" + }, + { + "name": "sebastian/comparator", + "version": "1.1.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "1dd8869519a225f7f2b9eb663e225298fade819e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/1dd8869519a225f7f2b9eb663e225298fade819e", + "reference": "1dd8869519a225f7f2b9eb663e225298fade819e", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "sebastian/diff": "~1.2", + "sebastian/exporter": "~1.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides the functionality to compare PHP values for equality", + "homepage": "http://www.github.com/sebastianbergmann/comparator", + "keywords": [ + "comparator", + "compare", + "equality" + ], + "time": "2015-01-29 16:28:08" + }, + { + "name": "sebastian/diff", + "version": "1.3.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "863df9687835c62aa423a22412d26fa2ebde3fd3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/863df9687835c62aa423a22412d26fa2ebde3fd3", + "reference": "863df9687835c62aa423a22412d26fa2ebde3fd3", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Diff implementation", + "homepage": "http://www.github.com/sebastianbergmann/diff", + "keywords": [ + "diff" + ], + "time": "2015-02-22 15:13:53" + }, + { + "name": "sebastian/exporter", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/exporter.git", + "reference": "84839970d05254c73cde183a721c7af13aede943" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/84839970d05254c73cde183a721c7af13aede943", + "reference": "84839970d05254c73cde183a721c7af13aede943", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "sebastian/recursion-context": "~1.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides the functionality to export PHP variables for visualization", + "homepage": "http://www.github.com/sebastianbergmann/exporter", + "keywords": [ + "export", + "exporter" + ], + "time": "2015-01-27 07:23:06" + }, + { + "name": "sebastian/recursion-context", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/recursion-context.git", + "reference": "3989662bbb30a29d20d9faa04a846af79b276252" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/3989662bbb30a29d20d9faa04a846af79b276252", + "reference": "3989662bbb30a29d20d9faa04a846af79b276252", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides functionality to recursively process PHP variables", + "homepage": "http://www.github.com/sebastianbergmann/recursion-context", + "time": "2015-01-24 09:48:32" + }, + { + "name": "symfony/class-loader", + "version": "v2.7.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/ClassLoader.git", + "reference": "84843730de48ca0feba91004a03c7c952f8ea1da" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/ClassLoader/zipball/84843730de48ca0feba91004a03c7c952f8ea1da", + "reference": "84843730de48ca0feba91004a03c7c952f8ea1da", + "shasum": "" + }, + "require": { + "php": ">=5.3.9" + }, + "require-dev": { + "symfony/finder": "~2.0,>=2.0.5", + "symfony/phpunit-bridge": "~2.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.7-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\ClassLoader\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony ClassLoader Component", + "homepage": "https://symfony.com", + "time": "2015-06-08 09:37:21" + }, + { + "name": "symfony/config", + "version": "v2.7.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/Config.git", + "reference": "58ded81f1f582a87c528ef3dae9a859f78b5f374" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Config/zipball/58ded81f1f582a87c528ef3dae9a859f78b5f374", + "reference": "58ded81f1f582a87c528ef3dae9a859f78b5f374", + "shasum": "" + }, + "require": { + "php": ">=5.3.9", + "symfony/filesystem": "~2.3" + }, + "require-dev": { + "symfony/phpunit-bridge": "~2.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.7-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Config\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Config Component", + "homepage": "https://symfony.com", + "time": "2015-06-11 14:06:56" + }, + { + "name": "symfony/console", + "version": "v2.7.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/Console.git", + "reference": "564398bc1f33faf92fc2ec86859983d30eb81806" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Console/zipball/564398bc1f33faf92fc2ec86859983d30eb81806", + "reference": "564398bc1f33faf92fc2ec86859983d30eb81806", + "shasum": "" + }, + "require": { + "php": ">=5.3.9" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/event-dispatcher": "~2.1", + "symfony/phpunit-bridge": "~2.7", + "symfony/process": "~2.1" + }, + "suggest": { + "psr/log": "For using the console logger", + "symfony/event-dispatcher": "", + "symfony/process": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.7-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Console\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Console Component", + "homepage": "https://symfony.com", + "time": "2015-06-10 15:30:22" + }, + { + "name": "symfony/dependency-injection", + "version": "v2.7.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/DependencyInjection.git", + "reference": "1a409e52a38ec891de0a7a61a191d1c62080b69d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/DependencyInjection/zipball/1a409e52a38ec891de0a7a61a191d1c62080b69d", + "reference": "1a409e52a38ec891de0a7a61a191d1c62080b69d", + "shasum": "" + }, + "require": { + "php": ">=5.3.9" + }, + "conflict": { + "symfony/expression-language": "<2.6" + }, + "require-dev": { + "symfony/config": "~2.2", + "symfony/expression-language": "~2.6", + "symfony/phpunit-bridge": "~2.7", + "symfony/yaml": "~2.1" + }, + "suggest": { + "symfony/config": "", + "symfony/proxy-manager-bridge": "Generate service proxies to lazy load them", + "symfony/yaml": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.7-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\DependencyInjection\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony DependencyInjection Component", + "homepage": "https://symfony.com", + "time": "2015-06-11 19:13:11" + }, + { + "name": "symfony/event-dispatcher", + "version": "v2.7.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/EventDispatcher.git", + "reference": "be3c5ff8d503c46768aeb78ce6333051aa6f26d9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/be3c5ff8d503c46768aeb78ce6333051aa6f26d9", + "reference": "be3c5ff8d503c46768aeb78ce6333051aa6f26d9", + "shasum": "" + }, + "require": { + "php": ">=5.3.9" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/config": "~2.0,>=2.0.5", + "symfony/dependency-injection": "~2.6", + "symfony/expression-language": "~2.6", + "symfony/phpunit-bridge": "~2.7", + "symfony/stopwatch": "~2.3" + }, + "suggest": { + "symfony/dependency-injection": "", + "symfony/http-kernel": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.7-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\EventDispatcher\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony EventDispatcher Component", + "homepage": "https://symfony.com", + "time": "2015-06-08 09:37:21" + }, + { + "name": "symfony/filesystem", + "version": "v2.7.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/Filesystem.git", + "reference": "a0d43eb3e17d4f4c6990289805a488a0482a07f3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Filesystem/zipball/a0d43eb3e17d4f4c6990289805a488a0482a07f3", + "reference": "a0d43eb3e17d4f4c6990289805a488a0482a07f3", + "shasum": "" + }, + "require": { + "php": ">=5.3.9" + }, + "require-dev": { + "symfony/phpunit-bridge": "~2.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.7-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Filesystem\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Filesystem Component", + "homepage": "https://symfony.com", + "time": "2015-06-08 09:37:21" + }, + { + "name": "symfony/finder", + "version": "v2.7.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/Finder.git", + "reference": "c13a40d638aeede1e8400f8c956c7f9246c05f75" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Finder/zipball/c13a40d638aeede1e8400f8c956c7f9246c05f75", + "reference": "c13a40d638aeede1e8400f8c956c7f9246c05f75", + "shasum": "" + }, + "require": { + "php": ">=5.3.9" + }, + "require-dev": { + "symfony/phpunit-bridge": "~2.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.7-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Finder\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Finder Component", + "homepage": "https://symfony.com", + "time": "2015-06-04 20:11:48" + }, + { + "name": "symfony/process", + "version": "v2.7.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/Process.git", + "reference": "552d8efdc80980cbcca50b28d626ac8e36e3cdd1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Process/zipball/552d8efdc80980cbcca50b28d626ac8e36e3cdd1", + "reference": "552d8efdc80980cbcca50b28d626ac8e36e3cdd1", + "shasum": "" + }, + "require": { + "php": ">=5.3.9" + }, + "require-dev": { + "symfony/phpunit-bridge": "~2.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.7-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Process\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Process Component", + "homepage": "https://symfony.com", + "time": "2015-06-08 09:37:21" + }, + { + "name": "symfony/translation", + "version": "v2.7.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/Translation.git", + "reference": "8349a2b0d11bd0311df9e8914408080912983a0b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Translation/zipball/8349a2b0d11bd0311df9e8914408080912983a0b", + "reference": "8349a2b0d11bd0311df9e8914408080912983a0b", + "shasum": "" + }, + "require": { + "php": ">=5.3.9" + }, + "conflict": { + "symfony/config": "<2.7" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/config": "~2.7", + "symfony/intl": "~2.3", + "symfony/phpunit-bridge": "~2.7", + "symfony/yaml": "~2.2" + }, + "suggest": { + "psr/log": "To use logging capability in translator", + "symfony/config": "", + "symfony/yaml": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.7-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Translation\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Translation Component", + "homepage": "https://symfony.com", + "time": "2015-06-11 17:26:34" + }, + { + "name": "symfony/yaml", + "version": "v2.7.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/Yaml.git", + "reference": "9808e75c609a14f6db02f70fccf4ca4aab53c160" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/9808e75c609a14f6db02f70fccf4ca4aab53c160", + "reference": "9808e75c609a14f6db02f70fccf4ca4aab53c160", + "shasum": "" + }, + "require": { + "php": ">=5.3.9" + }, + "require-dev": { + "symfony/phpunit-bridge": "~2.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.7-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Yaml\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Yaml Component", + "homepage": "https://symfony.com", + "time": "2015-06-10 15:30:22" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": ">=5.6" + }, + "platform-dev": [] +} diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100755 index 0000000..955edc0 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,6 @@ +web: + build: . + volumes: + - .:/var/www/city-bike + ports: + - "80:80" diff --git a/docker/php.ini b/docker/php.ini new file mode 100755 index 0000000..24b17fd --- /dev/null +++ b/docker/php.ini @@ -0,0 +1,4 @@ +date.timezone = Europe/Warsaw +short_open_tag = off + +error_reporting = E_ALL diff --git a/docker/vhost.conf b/docker/vhost.conf new file mode 100755 index 0000000..56eace2 --- /dev/null +++ b/docker/vhost.conf @@ -0,0 +1,15 @@ + + ServerName city-bike.dev + ServerAlias www.city-bike.dev + + DocumentRoot /var/www/city-bike/web + + # enable the .htaccess rewrites + AllowOverride All + Order allow,deny + Allow from All + + + ErrorLog /var/log/apache2/project_error.log + CustomLog /var/log/apache2/project_access.log combined + diff --git a/features/bootstrap/FeatureContext.php b/features/bootstrap/FeatureContext.php new file mode 100755 index 0000000..6f4428d --- /dev/null +++ b/features/bootstrap/FeatureContext.php @@ -0,0 +1,89 @@ +dockingStations = new \Cocoders\InMemory\CityBike\DockingStations(); + $this->foundDockingStations = new \Cocoders\InMemory\CityBike\FoundDockingStations(); + } + + /** + * @Given there are such docking stations: + */ + public function thereAreSuchDockingStations(TableNode $table) + { + foreach ($table->getHash() as $row) { + $dockingStation = new \Cocoders\CityBike\DockingStation( + $row['name'], + new Position( + $row['lat'], + $row['long'] + ) + ); + $dockingStation->setAvailableBikes($row['available bikes']); + $this->dockingStations->add($dockingStation); + } + } + + /** + * @When I am searching nearest bike docking stations from my posisiton which is :positionString + */ + public function iAmSearchingNearestBikeDockingStationsFromMyPosisitonWhichIs($positionString) + { + $dockingStations = $this->dockingStations->findAll(); + $this->nearestDockingStations = $this + ->foundDockingStations + ->search(Position::fromString($positionString), $dockingStations) + ; + } + + /** + * @Then I should see such nearest docking stations: + */ + public function iShouldSeeSuchNearestDockingStations(TableNode $table) + { + foreach ($this->nearestDockingStations as $key => $foundDockingStation) { + if ($foundDockingStation->distance != $table->getHash()[$key]['distance (km)']) { + throw new \Exception('Distance does not match'); + } + if ($foundDockingStation->availableBikes != $table->getHash()[$key]['available bikes']) { + throw new \Exception('Available does not match'); + } + if ($foundDockingStation->lat != $table->getHash()[$key]['lat']) { + throw new \Exception('lat does not match'); + } + if ($foundDockingStation->long != $table->getHash()[$key]['long']) { + throw new \Exception('long does not match'); + } + if ($foundDockingStation->name != $table->getHash()[$key]['name']) { + throw new \Exception('name does not match'); + } + } + } +} diff --git a/features/searchNearestDockingStation.feature b/features/searchNearestDockingStation.feature new file mode 100644 index 0000000..b759ead --- /dev/null +++ b/features/searchNearestDockingStation.feature @@ -0,0 +1,22 @@ +Feature: As a public transport user + I want to find nearest bike docking station easily + so I can use app which search nearest stations from my location + + Background: + Given there are such docking stations: + | name | lat | long | available bikes | + | Toruń Rynek Staromiejski | 53.010418 | 18.6037566 | 5 | + | Toruń Św Katarzyny | 53.0132672 | 18.613699 | 2 | + | Toruń Plac Rapackiego | 53.0099343 | 18.6010726 | 0 | + + Scenario: Searching next docking station + When I am searching nearest bike docking stations from my posisiton which is "53.03531,18.598338" + Then I should see such nearest docking stations: + | name | lat | long | available bikes | distance (km) | + | Toruń Św Katarzyny | 53.0132672 | 18.613699 | 2 | 2.66 | + | Toruń Rynek Staromiejski | 53.010418 | 18.6037566 | 5 | 2.79 | + | Toruń Plac Rapackiego | 53.0099343 | 18.6010726 | 0 | 2.83 | + + # 2.9km + # 3.0km + # 3.2km diff --git a/phpspec.yml.dist b/phpspec.yml.dist new file mode 100644 index 0000000..1e7144e --- /dev/null +++ b/phpspec.yml.dist @@ -0,0 +1,2 @@ +extensions: + - RMiller\BehatSpec\PhpSpecExtension diff --git a/spec/Cocoders/CityBike/DockingStationSpec.php b/spec/Cocoders/CityBike/DockingStationSpec.php new file mode 100755 index 0000000..fcaebdf --- /dev/null +++ b/spec/Cocoders/CityBike/DockingStationSpec.php @@ -0,0 +1,52 @@ +beConstructedWith( + 'Toruń Rynek Staromiejski', + new \Cocoders\CityBike\Position( + '53.010418', + '18.6037566' + ) + ); + } + + function it_is_initializable() + { + $this->shouldHaveType('Cocoders\CityBike\DockingStation'); + } + + function it_allows_to_get_name() + { + $this->getName()->shouldBe('Toruń Rynek Staromiejski'); + } + + function it_allows_to_get_position() + { + $this->getPosition()->shouldBeLike( + new \Cocoders\CityBike\Position( + '53.010418', + '18.6037566' + ) + ); + } + + function it_allows_set_available_bikes() + { + $this->setAvailableBikes(5); + + $this->getAvailableBikes()->shouldBe(5); + } + + function it_should_have_0_available_bikes_by_default() + { + $this->getAvailableBikes()->shouldBe(0); + } +} diff --git a/spec/Cocoders/CityBike/FoundDockingStationSpec.php b/spec/Cocoders/CityBike/FoundDockingStationSpec.php new file mode 100755 index 0000000..dec0b1b --- /dev/null +++ b/spec/Cocoders/CityBike/FoundDockingStationSpec.php @@ -0,0 +1,38 @@ +shouldHaveType('Cocoders\CityBike\FoundDockingStation'); + } + + function it_can_be_created_from_docking_station_object_and_distance( + DockingStation $dockingStation + ) + { + $dockingStation->getName()->willReturn('My docking station'); + $dockingStation->getPosition()->willReturn( + new \Cocoders\CityBike\Position( + '53.010418', + '18.6037566' + ) + ); + $dockingStation->getAvailableBikes()->willReturn(5); + + $this->beConstructedThrough('fromDockingStationAndDistance', [$dockingStation, 3]); + + $this->name->shouldBe('My docking station'); + $this->lat->shouldBe('53.010418'); + $this->long->shouldBe('18.6037566'); + $this->availableBikes->shouldBe(5); + $this->distance->shouldBe(3); + } +} diff --git a/spec/Cocoders/CityBike/PositionSpec.php b/spec/Cocoders/CityBike/PositionSpec.php new file mode 100755 index 0000000..672f8c3 --- /dev/null +++ b/spec/Cocoders/CityBike/PositionSpec.php @@ -0,0 +1,53 @@ +beConstructedWith( + '53.010418', + '18.6037566' + ); + } + + function it_is_initializable() + { + $this->shouldHaveType('Cocoders\CityBike\Position'); + } + + function it_allows_to_get_lat() + { + $this->getLat()->shouldBe('53.010418'); + } + + function it_allows_to_get_long() + { + $this->getLong()->shouldBe('18.6037566'); + } + + function it_calculate_distance_between_two_posistion() + { + $this + ->calculateDistance( + new Position(53.03531, 18.598338) + ) + ->shouldBe(2.79); + } + + public function it_creates_position_from_string() + { + $position = $this->fromString('54.010418,19.6037566'); + $position->getLat()->shouldBe(54.010418); + $position->getLong()->shouldBe(19.6037566); + + $position = $this->fromString('54.010419, 19.6037550'); + $position->getLat()->shouldBe(54.010419); + $position->getLong()->shouldBe(19.6037550); + } +} diff --git a/spec/Cocoders/InMemory/CityBike/DockingStationsSpec.php b/spec/Cocoders/InMemory/CityBike/DockingStationsSpec.php new file mode 100755 index 0000000..7a6a8ee --- /dev/null +++ b/spec/Cocoders/InMemory/CityBike/DockingStationsSpec.php @@ -0,0 +1,29 @@ +shouldHaveType('Cocoders\CityBike\DockingStations'); + } + + function it_allows_to_store_docking_station( + DockingStation $dockingStation, + DockingStation $dockingStation2 + ) { + $this->add($dockingStation); + $this->add($dockingStation2); + + $this->findAll()->shouldBe([ + $dockingStation, + $dockingStation2 + ]); + } +} diff --git a/spec/Cocoders/InMemory/CityBike/FoundDockingStationsSpec.php b/spec/Cocoders/InMemory/CityBike/FoundDockingStationsSpec.php new file mode 100755 index 0000000..5116e28 --- /dev/null +++ b/spec/Cocoders/InMemory/CityBike/FoundDockingStationsSpec.php @@ -0,0 +1,53 @@ +shouldHaveType('Cocoders\CityBike\FoundDockingStations'); + } + + function it_returns_found_docking_stations_ordered_by_distance( + DockingStation $dockingStation1, + DockingStation $dockingStation2, + DockingStation $dockingStation3 + ) { + $dockingStation1->getName()->willReturn('station 1'); + $dockingStation1->getAvailableBikes()->willReturn(1); + $dockingStation1->getPosition()->willReturn( + new Position(53.010418, 18.6037566) + ); + $dockingStation2->getName()->willReturn('station 2'); + $dockingStation2->getAvailableBikes()->willReturn(1); + $dockingStation2->getPosition()->willReturn( + new Position(53.0132672, 18.613699) + ); + $dockingStation3->getName()->willReturn('station 3'); + $dockingStation3->getAvailableBikes()->willReturn(1); + $dockingStation3->getPosition()->willReturn( + new Position(53.0099343, 18.6010726) + ); + + $foundDockingStations = $this->search( + new Position(53.03531, 18.598338), + [ + $dockingStation1, + $dockingStation2, + $dockingStation3 + ] + ); + $foundDockingStations[0]->name->shouldBe('station 2'); + $foundDockingStations[0]->distance->shouldBe(2.66); + $foundDockingStations[1]->name->shouldBe('station 1'); + $foundDockingStations[1]->distance->shouldBe(2.79); + $foundDockingStations[2]->name->shouldBe('station 3'); + $foundDockingStations[2]->distance->shouldBe(2.83); + } +} diff --git a/src/Cocoders/CityBike/DockingStation.php b/src/Cocoders/CityBike/DockingStation.php new file mode 100755 index 0000000..3496c5f --- /dev/null +++ b/src/Cocoders/CityBike/DockingStation.php @@ -0,0 +1,37 @@ +name = $name; + $this->position = $position; + $this->availableBikes = 0; + } + + public function setAvailableBikes($availableBikes) + { + $this->availableBikes = $availableBikes; + } + + public function getAvailableBikes() + { + return $this->availableBikes; + } + + public function getName() + { + return $this->name; + } + + public function getPosition() + { + return $this->position; + } +} diff --git a/src/Cocoders/CityBike/DockingStations.php b/src/Cocoders/CityBike/DockingStations.php new file mode 100755 index 0000000..95943ae --- /dev/null +++ b/src/Cocoders/CityBike/DockingStations.php @@ -0,0 +1,18 @@ +name = $dockingStation->getName(); + $foundDockingStation->lat = $dockingStation->getPosition()->getLat(); + $foundDockingStation->long = $dockingStation->getPosition()->getLong(); + $foundDockingStation->availableBikes = $dockingStation->getAvailableBikes(); + $foundDockingStation->distance = $distance; + + return $foundDockingStation; + } +} diff --git a/src/Cocoders/CityBike/FoundDockingStations.php b/src/Cocoders/CityBike/FoundDockingStations.php new file mode 100755 index 0000000..021ef74 --- /dev/null +++ b/src/Cocoders/CityBike/FoundDockingStations.php @@ -0,0 +1,14 @@ +lat = $lat; + $this->long = $long; + } + + public function getLat() + { + return $this->lat; + } + + public function getLong() + { + return $this->long; + } + + /** + * Returns distance in km between positions + * + * @param Position $position + * @return float + */ + public function calculateDistance(Position $position) + { + $theta = $this->long - $position->getLong(); + $distance = + (sin(deg2rad($this->lat)) * sin(deg2rad($position->getLat()))) + + (cos(deg2rad($this->lat)) * cos(deg2rad($position->getLat())) * cos(deg2rad($theta))); + $distance = acos($distance); + $distance = rad2deg($distance); + + + return round(($distance * 60 * 1.1515) * 1.609344, 2); + } +} diff --git a/src/Cocoders/InMemory/CityBike/DockingStations.php b/src/Cocoders/InMemory/CityBike/DockingStations.php new file mode 100755 index 0000000..eb34fe6 --- /dev/null +++ b/src/Cocoders/InMemory/CityBike/DockingStations.php @@ -0,0 +1,28 @@ +stations[] = $dockingStation; + } + + /** + * @return DockingStation[] + */ + public function findAll() + { + return $this->stations; + } +} diff --git a/src/Cocoders/InMemory/CityBike/FoundDockingStations.php b/src/Cocoders/InMemory/CityBike/FoundDockingStations.php new file mode 100755 index 0000000..3a47127 --- /dev/null +++ b/src/Cocoders/InMemory/CityBike/FoundDockingStations.php @@ -0,0 +1,37 @@ +calculateDistance($dockingStation->getPosition()) + ); + } + + usort($foundDockingStations, function (FoundDockingStation $a, FoundDockingStation $b) { + if ($a->distance == $b->distance) { + return 0; + } + + return $a->distance < $b->distance ? -1 : 1; + }); + + return $foundDockingStations; + } +}