diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..3a693c9
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,6 @@
+composer.phar
+vendor/
+
+# Commit your application's lock file http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file
+# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
+# composer.lock
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..ab52479
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,18 @@
+language: php
+
+php:
+ - 5.5
+ - 5.6
+ - hhvm
+
+before_script:
+ - composer self-update
+ - composer --dev install
+
+script:
+ - phpunit --coverage-text
+
+notifications:
+ email:
+ - arielferrandini@gmail.com
+
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..bfc05e0
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,22 @@
+The MIT License (MIT)
+
+Copyright (c) 2014 Ariel Ferrandini
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..0414ebd
--- /dev/null
+++ b/README.md
@@ -0,0 +1,30 @@
+Board Helper
+============
+
+[](http://travis-ci.org/PHPGames/BoardHelper)
+[](https://packagist.org/packages/phpgames/board-helper)
+[](https://insight.sensiolabs.com/projects/d45be279-f4f6-4e1a-9801-79b2ef5c767c)
+
+## Installation
+
+### Step 1: Composer
+
+Add the following line to the `composer.json` file:
+
+``` json
+{
+ "require": {
+ "phpgames/board-helper": "~1.0"
+ }
+}
+```
+
+## Usage
+@todo
+
+```php
+$board = new Board($output);
+```
+
+## License
+Released under the MIT License attached with this code.
diff --git a/composer.json b/composer.json
new file mode 100644
index 0000000..6b5d7f8
--- /dev/null
+++ b/composer.json
@@ -0,0 +1,28 @@
+{
+ "name": "phpgames/board-helper",
+ "description": "Board Symfony Console Helper",
+ "homepage": "https://github.com/aferrandini/BoardHelper",
+ "keywords": ["phpgames", "board", "symfony", "console", "helper"],
+ "license": "MIT",
+ "authors": [
+ {
+ "name": "Ariel Ferrandini",
+ "email": "arielferrandini@gmail.com"
+ },
+ {
+ "name": "Eduardo Gulias",
+ "email": "eduardomgulias@gmail.com"
+ }
+ ],
+ "require": {
+ "symfony/console": "~2.5"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "~4.0"
+ },
+ "autoload": {
+ "psr-4": {
+ "PHPGames\\": "src/PHPGames"
+ }
+ }
+}
diff --git a/composer.lock b/composer.lock
new file mode 100644
index 0000000..eb86eea
--- /dev/null
+++ b/composer.lock
@@ -0,0 +1,816 @@
+{
+ "_readme": [
+ "This file locks the dependencies of your project to a known state",
+ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
+ "This file is @generated automatically"
+ ],
+ "hash": "f0eb99edf2a5acc7cf5cba5f96e8a033",
+ "packages": [
+ {
+ "name": "symfony/console",
+ "version": "v2.5.7",
+ "target-dir": "Symfony/Component/Console",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/Console.git",
+ "reference": "61b13c27c9258e97009249d4ef193c964bf346b7"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/Console/zipball/61b13c27c9258e97009249d4ef193c964bf346b7",
+ "reference": "61b13c27c9258e97009249d4ef193c964bf346b7",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.3"
+ },
+ "require-dev": {
+ "psr/log": "~1.0",
+ "symfony/event-dispatcher": "~2.1"
+ },
+ "suggest": {
+ "psr/log": "For using the console logger",
+ "symfony/event-dispatcher": ""
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.5-dev"
+ }
+ },
+ "autoload": {
+ "psr-0": {
+ "Symfony\\Component\\Console\\": ""
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Symfony Community",
+ "homepage": "http://symfony.com/contributors"
+ },
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ }
+ ],
+ "description": "Symfony Console Component",
+ "homepage": "http://symfony.com",
+ "time": "2014-11-20 13:22:25"
+ }
+ ],
+ "packages-dev": [
+ {
+ "name": "doctrine/instantiator",
+ "version": "1.0.4",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/doctrine/instantiator.git",
+ "reference": "f976e5de371104877ebc89bd8fecb0019ed9c119"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/doctrine/instantiator/zipball/f976e5de371104877ebc89bd8fecb0019ed9c119",
+ "reference": "f976e5de371104877ebc89bd8fecb0019ed9c119",
+ "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.*@ALPHA"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.0.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-0": {
+ "Doctrine\\Instantiator\\": "src"
+ }
+ },
+ "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": "2014-10-13 12:58:55"
+ },
+ {
+ "name": "phpunit/php-code-coverage",
+ "version": "2.0.11",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/sebastianbergmann/php-code-coverage.git",
+ "reference": "53603b3c995f5aab6b59c8e08c3a663d2cc810b7"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/53603b3c995f5aab6b59c8e08c3a663d2cc810b7",
+ "reference": "53603b3c995f5aab6b59c8e08c3a663d2cc810b7",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.3",
+ "phpunit/php-file-iterator": "~1.3",
+ "phpunit/php-text-template": "~1.2",
+ "phpunit/php-token-stream": "~1.3",
+ "sebastian/environment": "~1.0",
+ "sebastian/version": "~1.0"
+ },
+ "require-dev": {
+ "ext-xdebug": ">=2.1.4",
+ "phpunit/phpunit": "~4.1"
+ },
+ "suggest": {
+ "ext-dom": "*",
+ "ext-xdebug": ">=2.2.1",
+ "ext-xmlwriter": "*"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.0.x-dev"
+ }
+ },
+ "autoload": {
+ "classmap": [
+ "src/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "include-path": [
+ ""
+ ],
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "authors": [
+ {
+ "name": "Sebastian Bergmann",
+ "email": "sb@sebastian-bergmann.de",
+ "role": "lead"
+ }
+ ],
+ "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.",
+ "homepage": "https://github.com/sebastianbergmann/php-code-coverage",
+ "keywords": [
+ "coverage",
+ "testing",
+ "xunit"
+ ],
+ "time": "2014-08-31 06:33:04"
+ },
+ {
+ "name": "phpunit/php-file-iterator",
+ "version": "1.3.4",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/sebastianbergmann/php-file-iterator.git",
+ "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/acd690379117b042d1c8af1fafd61bde001bf6bb",
+ "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.3"
+ },
+ "type": "library",
+ "autoload": {
+ "classmap": [
+ "File/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "include-path": [
+ ""
+ ],
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "authors": [
+ {
+ "name": "Sebastian Bergmann",
+ "email": "sb@sebastian-bergmann.de",
+ "role": "lead"
+ }
+ ],
+ "description": "FilterIterator implementation that filters files based on a list of suffixes.",
+ "homepage": "https://github.com/sebastianbergmann/php-file-iterator/",
+ "keywords": [
+ "filesystem",
+ "iterator"
+ ],
+ "time": "2013-10-10 15:34:57"
+ },
+ {
+ "name": "phpunit/php-text-template",
+ "version": "1.2.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/sebastianbergmann/php-text-template.git",
+ "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/206dfefc0ffe9cebf65c413e3d0e809c82fbf00a",
+ "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.3"
+ },
+ "type": "library",
+ "autoload": {
+ "classmap": [
+ "Text/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "include-path": [
+ ""
+ ],
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "authors": [
+ {
+ "name": "Sebastian Bergmann",
+ "email": "sb@sebastian-bergmann.de",
+ "role": "lead"
+ }
+ ],
+ "description": "Simple template engine.",
+ "homepage": "https://github.com/sebastianbergmann/php-text-template/",
+ "keywords": [
+ "template"
+ ],
+ "time": "2014-01-30 17:20:04"
+ },
+ {
+ "name": "phpunit/php-timer",
+ "version": "1.0.5",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/sebastianbergmann/php-timer.git",
+ "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/19689d4354b295ee3d8c54b4f42c3efb69cbc17c",
+ "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.3"
+ },
+ "type": "library",
+ "autoload": {
+ "classmap": [
+ "PHP/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "include-path": [
+ ""
+ ],
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "authors": [
+ {
+ "name": "Sebastian Bergmann",
+ "email": "sb@sebastian-bergmann.de",
+ "role": "lead"
+ }
+ ],
+ "description": "Utility class for timing",
+ "homepage": "https://github.com/sebastianbergmann/php-timer/",
+ "keywords": [
+ "timer"
+ ],
+ "time": "2013-08-02 07:42:54"
+ },
+ {
+ "name": "phpunit/php-token-stream",
+ "version": "1.3.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/sebastianbergmann/php-token-stream.git",
+ "reference": "f8d5d08c56de5cfd592b3340424a81733259a876"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/f8d5d08c56de5cfd592b3340424a81733259a876",
+ "reference": "f8d5d08c56de5cfd592b3340424a81733259a876",
+ "shasum": ""
+ },
+ "require": {
+ "ext-tokenizer": "*",
+ "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": "Sebastian Bergmann",
+ "email": "sebastian@phpunit.de"
+ }
+ ],
+ "description": "Wrapper around PHP's tokenizer extension.",
+ "homepage": "https://github.com/sebastianbergmann/php-token-stream/",
+ "keywords": [
+ "tokenizer"
+ ],
+ "time": "2014-08-31 06:12:13"
+ },
+ {
+ "name": "phpunit/phpunit",
+ "version": "4.3.5",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/sebastianbergmann/phpunit.git",
+ "reference": "2dab9d593997db4abcf58d0daf798eb4e9cecfe1"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/2dab9d593997db4abcf58d0daf798eb4e9cecfe1",
+ "reference": "2dab9d593997db4abcf58d0daf798eb4e9cecfe1",
+ "shasum": ""
+ },
+ "require": {
+ "ext-dom": "*",
+ "ext-json": "*",
+ "ext-pcre": "*",
+ "ext-reflection": "*",
+ "ext-spl": "*",
+ "php": ">=5.3.3",
+ "phpunit/php-code-coverage": "~2.0",
+ "phpunit/php-file-iterator": "~1.3.2",
+ "phpunit/php-text-template": "~1.2",
+ "phpunit/php-timer": "~1.0.2",
+ "phpunit/phpunit-mock-objects": "~2.3",
+ "sebastian/comparator": "~1.0",
+ "sebastian/diff": "~1.1",
+ "sebastian/environment": "~1.0",
+ "sebastian/exporter": "~1.0",
+ "sebastian/version": "~1.0",
+ "symfony/yaml": "~2.0"
+ },
+ "suggest": {
+ "phpunit/php-invoker": "~1.1"
+ },
+ "bin": [
+ "phpunit"
+ ],
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "4.3.x-dev"
+ }
+ },
+ "autoload": {
+ "classmap": [
+ "src/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "include-path": [
+ "",
+ "../../symfony/yaml/"
+ ],
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "authors": [
+ {
+ "name": "Sebastian Bergmann",
+ "email": "sebastian@phpunit.de",
+ "role": "lead"
+ }
+ ],
+ "description": "The PHP Unit Testing framework.",
+ "homepage": "http://www.phpunit.de/",
+ "keywords": [
+ "phpunit",
+ "testing",
+ "xunit"
+ ],
+ "time": "2014-11-11 10:11:09"
+ },
+ {
+ "name": "phpunit/phpunit-mock-objects",
+ "version": "2.3.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git",
+ "reference": "c63d2367247365f688544f0d500af90a11a44c65"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/c63d2367247365f688544f0d500af90a11a44c65",
+ "reference": "c63d2367247365f688544f0d500af90a11a44c65",
+ "shasum": ""
+ },
+ "require": {
+ "doctrine/instantiator": "~1.0,>=1.0.1",
+ "php": ">=5.3.3",
+ "phpunit/php-text-template": "~1.2"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "~4.3"
+ },
+ "suggest": {
+ "ext-soap": "*"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.3.x-dev"
+ }
+ },
+ "autoload": {
+ "classmap": [
+ "src/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "authors": [
+ {
+ "name": "Sebastian Bergmann",
+ "email": "sb@sebastian-bergmann.de",
+ "role": "lead"
+ }
+ ],
+ "description": "Mock Object library for PHPUnit",
+ "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/",
+ "keywords": [
+ "mock",
+ "xunit"
+ ],
+ "time": "2014-10-03 05:12:11"
+ },
+ {
+ "name": "sebastian/comparator",
+ "version": "1.0.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/sebastianbergmann/comparator.git",
+ "reference": "e54a01c0da1b87db3c5a3c4c5277ddf331da4aef"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/e54a01c0da1b87db3c5a3c4c5277ddf331da4aef",
+ "reference": "e54a01c0da1b87db3c5a3c4c5277ddf331da4aef",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.3",
+ "sebastian/diff": "~1.1",
+ "sebastian/exporter": "~1.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "~4.1"
+ },
+ "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": "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": "2014-05-11 23:00:21"
+ },
+ {
+ "name": "sebastian/diff",
+ "version": "1.2.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/sebastianbergmann/diff.git",
+ "reference": "5843509fed39dee4b356a306401e9dd1a931fec7"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/5843509fed39dee4b356a306401e9dd1a931fec7",
+ "reference": "5843509fed39dee4b356a306401e9dd1a931fec7",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.3"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "~4.2"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.2-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": "2014-08-15 10:29:00"
+ },
+ {
+ "name": "sebastian/environment",
+ "version": "1.2.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/sebastianbergmann/environment.git",
+ "reference": "0d9bf79554d2a999da194a60416c15cf461eb67d"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/0d9bf79554d2a999da194a60416c15cf461eb67d",
+ "reference": "0d9bf79554d2a999da194a60416c15cf461eb67d",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.3"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "~4.3"
+ },
+ "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": "Sebastian Bergmann",
+ "email": "sebastian@phpunit.de"
+ }
+ ],
+ "description": "Provides functionality to handle HHVM/PHP environments",
+ "homepage": "http://www.github.com/sebastianbergmann/environment",
+ "keywords": [
+ "Xdebug",
+ "environment",
+ "hhvm"
+ ],
+ "time": "2014-10-22 06:38:05"
+ },
+ {
+ "name": "sebastian/exporter",
+ "version": "1.0.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/sebastianbergmann/exporter.git",
+ "reference": "c7d59948d6e82818e1bdff7cadb6c34710eb7dc0"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/c7d59948d6e82818e1bdff7cadb6c34710eb7dc0",
+ "reference": "c7d59948d6e82818e1bdff7cadb6c34710eb7dc0",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.3"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "~4.0"
+ },
+ "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": "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": "2014-09-10 00:51:36"
+ },
+ {
+ "name": "sebastian/version",
+ "version": "1.0.3",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/sebastianbergmann/version.git",
+ "reference": "b6e1f0cf6b9e1ec409a0d3e2f2a5fb0998e36b43"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/b6e1f0cf6b9e1ec409a0d3e2f2a5fb0998e36b43",
+ "reference": "b6e1f0cf6b9e1ec409a0d3e2f2a5fb0998e36b43",
+ "shasum": ""
+ },
+ "type": "library",
+ "autoload": {
+ "classmap": [
+ "src/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "authors": [
+ {
+ "name": "Sebastian Bergmann",
+ "email": "sebastian@phpunit.de",
+ "role": "lead"
+ }
+ ],
+ "description": "Library that helps with managing the version number of Git-hosted PHP projects",
+ "homepage": "https://github.com/sebastianbergmann/version",
+ "time": "2014-03-07 15:35:33"
+ },
+ {
+ "name": "symfony/yaml",
+ "version": "v2.5.7",
+ "target-dir": "Symfony/Component/Yaml",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/Yaml.git",
+ "reference": "900d38bc8f74a50343ce65dd1c1e9819658ee56b"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/Yaml/zipball/900d38bc8f74a50343ce65dd1c1e9819658ee56b",
+ "reference": "900d38bc8f74a50343ce65dd1c1e9819658ee56b",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.3"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.5-dev"
+ }
+ },
+ "autoload": {
+ "psr-0": {
+ "Symfony\\Component\\Yaml\\": ""
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Symfony Community",
+ "homepage": "http://symfony.com/contributors"
+ },
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ }
+ ],
+ "description": "Symfony Yaml Component",
+ "homepage": "http://symfony.com",
+ "time": "2014-11-20 13:22:25"
+ }
+ ],
+ "aliases": [],
+ "minimum-stability": "stable",
+ "stability-flags": [],
+ "prefer-stable": false,
+ "platform": [],
+ "platform-dev": []
+}
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
new file mode 100644
index 0000000..b7ba3fa
--- /dev/null
+++ b/phpunit.xml.dist
@@ -0,0 +1,26 @@
+
+
+
+
+
+ ./tests/PHPGames/Tests/
+ ./vendor/
+
+
+
+
+
+ ./vendor
+
+
+
diff --git a/src/PHPGames/Console/Exception/InvalidScreenSizeException.php b/src/PHPGames/Console/Exception/InvalidScreenSizeException.php
new file mode 100644
index 0000000..db6a8eb
--- /dev/null
+++ b/src/PHPGames/Console/Exception/InvalidScreenSizeException.php
@@ -0,0 +1,18 @@
+
+ * 27/09/14
+ */
+
+namespace PHPGames\Console\Exception;
+
+class InvalidScreenSizeException extends \RuntimeException
+{
+ public function __construct($width, $height)
+ {
+ parent::__construct(sprintf('Invalid screen size %sx%s.', $width, $height));
+ }
+
+}
diff --git a/src/PHPGames/Console/Exception/InvalidSizeException.php b/src/PHPGames/Console/Exception/InvalidSizeException.php
new file mode 100644
index 0000000..1d61457
--- /dev/null
+++ b/src/PHPGames/Console/Exception/InvalidSizeException.php
@@ -0,0 +1,18 @@
+
+ * 27/09/14
+ */
+
+namespace PHPGames\Console\Exception;
+
+class InvalidSizeException extends \RuntimeException
+{
+ public function __construct($size)
+ {
+ parent::__construct(sprintf('Invalid size %s.', $size));
+ }
+
+}
diff --git a/src/PHPGames/Console/Exception/MoveAlreadyDoneException.php b/src/PHPGames/Console/Exception/MoveAlreadyDoneException.php
new file mode 100644
index 0000000..795b732
--- /dev/null
+++ b/src/PHPGames/Console/Exception/MoveAlreadyDoneException.php
@@ -0,0 +1,18 @@
+
+ * 27/09/14
+ */
+
+namespace PHPGames\Console\Exception;
+
+class MoveAlreadyDoneException extends \RuntimeException
+{
+ public function __construct($x, $y, $player)
+ {
+ parent::__construct(sprintf('Move [%s, %s] already done by player %s.', $x, $y, $player));
+ }
+
+}
diff --git a/src/PHPGames/Console/Exception/PlayerNotFoundException.php b/src/PHPGames/Console/Exception/PlayerNotFoundException.php
new file mode 100644
index 0000000..3fe4794
--- /dev/null
+++ b/src/PHPGames/Console/Exception/PlayerNotFoundException.php
@@ -0,0 +1,16 @@
+
+ * 27/09/14
+ */
+namespace PHPGames\Console\Exception;
+
+class PlayerNotFoundException extends \RuntimeException
+{
+ public function __construct($player)
+ {
+ parent::__construct(sprintf('Player "%s" not found.', $player));
+ }
+}
diff --git a/src/PHPGames/Console/Exception/PlayerRepeatGameException.php b/src/PHPGames/Console/Exception/PlayerRepeatGameException.php
new file mode 100644
index 0000000..519da07
--- /dev/null
+++ b/src/PHPGames/Console/Exception/PlayerRepeatGameException.php
@@ -0,0 +1,16 @@
+
+ * 27/09/14
+ */
+namespace PHPGames\Console\Exception;
+
+class PlayerRepeatGameException extends \RuntimeException
+{
+ public function __construct($player)
+ {
+ parent::__construct(sprintf('The last game was player by player "%s".', $player));
+ }
+}
diff --git a/src/PHPGames/Console/Helper/Board.php b/src/PHPGames/Console/Helper/Board.php
new file mode 100644
index 0000000..0298ab4
--- /dev/null
+++ b/src/PHPGames/Console/Helper/Board.php
@@ -0,0 +1,340 @@
+
+ * 27/09/14
+ */
+
+namespace PHPGames\Console\Helper;
+
+use PHPGames\Console\Exception\InvalidSizeException;
+use PHPGames\Console\Exception\MoveAlreadyDoneException;
+use PHPGames\Console\Exception\PlayerNotFoundException;
+use PHPGames\Console\Exception\PlayerRepeatGameException;
+use PHPGames\Console\Screen\Size;
+use Symfony\Component\Console\Helper\Helper;
+use Symfony\Component\Console\Output\OutputInterface;
+
+class Board
+{
+ /**
+ * @var OutputInterface
+ */
+ private $output;
+
+ /**
+ * Board size
+ * @var int
+ */
+ private $size;
+
+ /**
+ * @var string
+ */
+ private $player1_char;
+
+ /**
+ * @var string
+ */
+ private $player2_char;
+
+ /**
+ * @var string
+ */
+ private $player1_color;
+
+ /**
+ * @var string
+ */
+ private $player2_color;
+
+ /**
+ * @var int
+ */
+ private $last_player;
+
+ /**
+ * @var Size
+ */
+ private $screenSize;
+
+ /**
+ * @var array
+ */
+ private $board;
+
+ /**
+ * @var bool
+ */
+ private $overwrite;
+
+ /**
+ * @var bool
+ */
+ private $background;
+
+ /**
+ * @var string
+ */
+ private $background_color;
+
+ /**
+ * @var int
+ */
+ private $spacesBeforeStart = 0;
+
+ /**
+ * @param OutputInterface $output
+ * @param array $screenSize
+ * @param int $size
+ * @param bool $overwrite
+ * @param bool $background
+ * @param string $background_color
+ * @param string $player1_char
+ * @param string $player2_char
+ * @param string $player1_color
+ * @param string $player2_color
+ */
+ public function __construct
+ (
+ OutputInterface $output,
+ array $screenSize,
+ $size = 3,
+ $overwrite = true,
+ $background = false,
+ $background_color = 'red',
+ $player1_char = 'X',
+ $player2_char = 'O',
+ $player1_color = 'green',
+ $player2_color = 'yellow'
+ ) {
+ $this->output = $output;
+
+ $screenWidth = 0;
+ $screenHeight = 0;
+ if (is_array($screenSize)) {
+ if (!empty($screenSize[0])) {
+ $screenWidth = $screenSize[0];
+ }
+
+ if (!empty($screenSize[1])) {
+ $screenHeight = $screenSize[1];
+ }
+ }
+ $this->screenSize = new Size($screenWidth, $screenHeight);
+ if ($this->screenSize->getWidth() < $this->size) {
+ throw new InvalidSizeException($size);
+ }
+ $this->size = $size;
+
+ // Center table in screen
+ if ($this->screenSize->isValid()) {
+ $this->spacesBeforeStart = (int) round(($this->screenSize->getWidth()-($this->size*4))/2);
+ }
+
+ $this->overwrite = $overwrite ? true : false;
+ $this->background = $background ? true : false;
+ $this->background_color = $background_color;
+ $this->player1_char = $player1_char;
+ $this->player2_char = $player2_char;
+ $this->player1_color = $player1_color;
+ $this->player2_color = $player2_color;
+
+ $this->initGame();
+ }
+
+ /**
+ * Restarts the board and the game vars
+ */
+ public function initGame()
+ {
+ $this->board = array();
+ $this->last_player = null;
+
+ for ($x=0; $x<$this->size; $x++) {
+ $row = array();
+
+ for ($y=0; $y<$this->size; $y++) {
+ $row[] = null;
+ }
+
+ $this->board[] = $row;
+ }
+
+ $this->display();
+ }
+
+ /**
+ * Draws the board
+ */
+ public function display()
+ {
+ $message = '';
+
+ $message .= $this->getLineSeparator();
+ foreach ($this->board as $i => $row) {
+ $message .= $this->getRow($i, $row);
+ }
+
+ $message .= $this->getPlayers();
+ $message .= $this->getLastMove();
+
+ $this->writeOutput($message);
+ }
+
+ private function getLastMove()
+ {
+ $message = '';
+ if ($this->last_player) {
+ $message = "Last move by player: {$this->getPlayerChar($this->last_player, false)}";
+ }
+
+ return $message . "\n";
+ }
+
+ private function getPlayers()
+ {
+ $player1 = "player1_color}>{$this->player1_char}player1_color}> Player 1";
+ $player2 = "Player 2 player2_color}>{$this->player2_char}player2_color}>";
+
+ $table_length = ($this->size*4)+1;
+ $player1_length = Helper::strlenWithoutDecoration($this->output->getFormatter(), $player1);
+ $player2_length = Helper::strlenWithoutDecoration($this->output->getFormatter(), $player2);
+
+ $spaces = $table_length - $player1_length - $player2_length;
+ if ($spaces < 4) {
+ $spaces = 4;
+ }
+
+ return $player1 . str_repeat("\x20", $spaces) . $player2 . "\n";
+ }
+
+ /**
+ * Returns the row text that should be write
+ *
+ * @param int $row_number
+ * @param array $row
+ * @return string
+ */
+ private function getRow($row_number, array $row)
+ {
+ $message = '';
+ foreach ($row as $cell_number => $player) {
+ $withBackground = $this->drawCellBackground($row_number, $cell_number);
+ $message .= ($withBackground ? "|background_color}> " : '| ')
+ . $this->getPlayerChar($player, $withBackground)
+ . ($withBackground ? " background_color}>" : ' ')
+ ;
+ }
+ $message .= "|\n";
+ $message .= $this->getLineSeparator();
+
+ return $message;
+ }
+
+ /**
+ * Returns if the background cell should be drawn
+ *
+ * @param int $row_number
+ * @param int $cell_number
+ * @return bool
+ */
+ private function drawCellBackground($row_number, $cell_number)
+ {
+ if ($this->size%2) {
+ return $this->background && (($row_number%2 && $cell_number%2) || (!($row_number%2) && !($cell_number%2)));
+ }
+
+ return $this->background && (($row_number%2 && !($cell_number%2)) || (!($row_number%2) && $cell_number%2));
+ }
+
+ /**
+ * Returns the board line separator
+ *
+ * @return string
+ */
+ private function getLineSeparator()
+ {
+ return str_repeat('-', ($this->size*4)+1) . "\n";
+ }
+
+ /**
+ * Update the board status and repaint the board
+ *
+ * @param int $x
+ * @param int $y
+ * @param int $player
+ */
+ public function updateGame($x, $y, $player)
+ {
+ if (!in_array($player, array(1,2))) {
+ throw new PlayerNotFoundException($player);
+ }
+
+ if ($this->last_player === $player) {
+ throw new PlayerRepeatGameException($player);
+ }
+
+ if (!is_null($this->board[$x][$y])) {
+ throw new MoveAlreadyDoneException($x, $y, $this->board[$x][$y]);
+ }
+
+ $this->last_player = $player;
+ $this->board[$x][$y] = $player;
+
+ $this->display();
+ }
+
+ /**
+ * Overwrites a previous message to the output.
+ *
+ * @param string $message The message
+ */
+ private function writeOutput($message)
+ {
+ $lines = explode("\n", $message);
+
+ if ($this->overwrite) {
+ // clear the screen
+ $this->clear();
+ } else {
+ // move to new line
+ $this->output->writeln('');
+ }
+
+ // append whitespace to center the board
+ foreach ($lines as $i => $line) {
+ $this->output->writeln(str_pad($line, $this->spacesBeforeStart + strlen($line), "\x20", STR_PAD_LEFT));
+ }
+ }
+
+ /**
+ * Clears the output buffer
+ */
+ private function clear()
+ {
+ $this->output->write("\e[2J");
+ }
+
+ /**
+ * Returns the player board cell
+ *
+ * @param int $player
+ * @param bool $withBackground
+ * @return string
+ */
+ private function getPlayerChar($player, $withBackground)
+ {
+ switch ($player) {
+ case 1:
+ return "player1_color}".($withBackground ? ";bg={$this->background_color}" : '').">{$this->player1_char}player1_color}".($withBackground ? ";bg={$this->background_color}" : '').">";
+
+ case 2:
+ return "player2_color}".($withBackground ? ";bg={$this->background_color}" : '').">{$this->player2_char}player2_color}".($withBackground ? ";bg={$this->background_color}" : '').">";
+
+ default:
+ return ' ';
+ }
+ }
+}
diff --git a/src/PHPGames/Console/Screen/Size.php b/src/PHPGames/Console/Screen/Size.php
new file mode 100644
index 0000000..76d4ce3
--- /dev/null
+++ b/src/PHPGames/Console/Screen/Size.php
@@ -0,0 +1,91 @@
+
+ * 29/09/14
+ */
+
+namespace PHPGames\Console\Screen;
+
+use PHPGames\Console\Exception\InvalidScreenSizeException;
+
+final class Size
+{
+ /**
+ * @var int
+ */
+ private $width;
+
+ /**
+ * @var int
+ */
+ private $height;
+
+ /**
+ * @param int $width
+ * @param int $height
+ */
+ public function __construct($width, $height)
+ {
+ if (0 >= $width || 0 >= $height) {
+ throw new InvalidScreenSizeException($width, $height);
+ }
+
+ $this->setWidth($width);
+ $this->setHeight($height);
+ }
+
+ /**
+ * @return int
+ */
+ public function getHeight()
+ {
+ return $this->height;
+ }
+
+ /**
+ * @param int $height
+ *
+ * @return self
+ */
+ public function setHeight($height)
+ {
+ $height = (int) $height;
+
+ if ($height>0) {
+ $this->height = $height;
+ }
+
+ return $this;
+ }
+
+ /**
+ * @return int
+ */
+ public function getWidth()
+ {
+ return $this->width;
+ }
+
+ /**
+ * @param int $width
+ *
+ * @return self
+ */
+ public function setWidth($width)
+ {
+ $width = (int) $width;
+
+ if ($width>0) {
+ $this->width = $width;
+ }
+
+ return $this;
+ }
+
+ public function isValid()
+ {
+ return ($this->getWidth()>0 && $this->getHeight()>0);
+ }
+}
diff --git a/tests/PHPGames/Tests/Console/Helper/BoardTest.php b/tests/PHPGames/Tests/Console/Helper/BoardTest.php
new file mode 100644
index 0000000..0de7112
--- /dev/null
+++ b/tests/PHPGames/Tests/Console/Helper/BoardTest.php
@@ -0,0 +1,253 @@
+
+ * 27/09/14
+ */
+namespace PHPGames\Tests\Console\Helper;
+
+use PHPGames\Console\Helper\Board;
+use Symfony\Component\Console\Output\StreamOutput;
+
+class BoardTest extends \PHPUnit_Framework_TestCase
+{
+ public function testDisplay()
+ {
+ $ticTacToe = new Board($output = $this->getOutputStream(false), array(10, 10), 3, false);
+
+ rewind($output->getStream());
+
+ $this->assertEquals(
+ $this->generateOutput('').
+ $this->generateOutput('-------------').
+ $this->generateOutput('| | | |').
+ $this->generateOutput('-------------').
+ $this->generateOutput('| | | |').
+ $this->generateOutput('-------------').
+ $this->generateOutput('| | | |').
+ $this->generateOutput('-------------').
+ $this->generateOutput('X Player 1 Player 2 O').
+ $this->generateOutput('').
+ $this->generateOutput(''),
+ stream_get_contents($output->getStream())
+ );
+ }
+
+ public function testDisplayCentered()
+ {
+ $ticTacToe = new Board($output = $this->getOutputStream(false), array(40, 40), 3, false);
+
+ rewind($output->getStream());
+
+ $this->assertEquals(
+ $this->generateOutput('').
+ $this->generateOutput(' -------------').
+ $this->generateOutput(' | | | |').
+ $this->generateOutput(' -------------').
+ $this->generateOutput(' | | | |').
+ $this->generateOutput(' -------------').
+ $this->generateOutput(' | | | |').
+ $this->generateOutput(' -------------').
+ $this->generateOutput(' X Player 1 Player 2 O').
+ $this->generateOutput(' ').
+ $this->generateOutput(' '),
+ stream_get_contents($output->getStream())
+ );
+ }
+
+ public function testDisplayCenteredBigSize()
+ {
+ $ticTacToe = new Board($output = $this->getOutputStream(false), array(100, 100), 10, false);
+
+ rewind($output->getStream());
+
+ $this->assertEquals(
+ $this->generateOutput('').
+ $this->generateOutput(' -----------------------------------------').
+ $this->generateOutput(' | | | | | | | | | | |').
+ $this->generateOutput(' -----------------------------------------').
+ $this->generateOutput(' | | | | | | | | | | |').
+ $this->generateOutput(' -----------------------------------------').
+ $this->generateOutput(' | | | | | | | | | | |').
+ $this->generateOutput(' -----------------------------------------').
+ $this->generateOutput(' | | | | | | | | | | |').
+ $this->generateOutput(' -----------------------------------------').
+ $this->generateOutput(' | | | | | | | | | | |').
+ $this->generateOutput(' -----------------------------------------').
+ $this->generateOutput(' | | | | | | | | | | |').
+ $this->generateOutput(' -----------------------------------------').
+ $this->generateOutput(' | | | | | | | | | | |').
+ $this->generateOutput(' -----------------------------------------').
+ $this->generateOutput(' | | | | | | | | | | |').
+ $this->generateOutput(' -----------------------------------------').
+ $this->generateOutput(' | | | | | | | | | | |').
+ $this->generateOutput(' -----------------------------------------').
+ $this->generateOutput(' | | | | | | | | | | |').
+ $this->generateOutput(' -----------------------------------------').
+ $this->generateOutput(' X Player 1 Player 2 O').
+ $this->generateOutput(' ').
+ $this->generateOutput(' '),
+ stream_get_contents($output->getStream())
+ );
+ }
+
+ public function testDisplayOtherSize()
+ {
+ $ticTacToe = new Board($output = $this->getOutputStream(false), array(10, 10), 5, false);
+
+ rewind($output->getStream());
+
+ $this->assertEquals(
+ $this->generateOutput('').
+ $this->generateOutput('---------------------').
+ $this->generateOutput('| | | | | |').
+ $this->generateOutput('---------------------').
+ $this->generateOutput('| | | | | |').
+ $this->generateOutput('---------------------').
+ $this->generateOutput('| | | | | |').
+ $this->generateOutput('---------------------').
+ $this->generateOutput('| | | | | |').
+ $this->generateOutput('---------------------').
+ $this->generateOutput('| | | | | |').
+ $this->generateOutput('---------------------').
+ $this->generateOutput('X Player 1 Player 2 O').
+ $this->generateOutput('').
+ $this->generateOutput(''),
+ stream_get_contents($output->getStream())
+ );
+ }
+
+ public function testUpdateGame()
+ {
+ $ticTacToe = new Board($output = $this->getOutputStream(false), array(10, 10), 3, false);
+ $ticTacToe->updateGame(1, 1, 1);
+ $ticTacToe->updateGame(0, 0, 2);
+
+ rewind($output->getStream());
+
+ $this->assertEquals(
+ $this->generateOutput('').
+ $this->generateOutput('-------------').
+ $this->generateOutput('| | | |').
+ $this->generateOutput('-------------').
+ $this->generateOutput('| | | |').
+ $this->generateOutput('-------------').
+ $this->generateOutput('| | | |').
+ $this->generateOutput('-------------').
+ $this->generateOutput('X Player 1 Player 2 O').
+ $this->generateOutput('').
+ $this->generateOutput('').
+ $this->generateOutput('').
+ $this->generateOutput('-------------').
+ $this->generateOutput('| | | |').
+ $this->generateOutput('-------------').
+ $this->generateOutput('| | X | |').
+ $this->generateOutput('-------------').
+ $this->generateOutput('| | | |').
+ $this->generateOutput('-------------').
+ $this->generateOutput('X Player 1 Player 2 O').
+ $this->generateOutput('Last move by player: X').
+ $this->generateOutput('').
+ $this->generateOutput('').
+ $this->generateOutput('-------------').
+ $this->generateOutput('| O | | |').
+ $this->generateOutput('-------------').
+ $this->generateOutput('| | X | |').
+ $this->generateOutput('-------------').
+ $this->generateOutput('| | | |').
+ $this->generateOutput('-------------').
+ $this->generateOutput('X Player 1 Player 2 O').
+ $this->generateOutput('Last move by player: O').
+ $this->generateOutput(''),
+ stream_get_contents($output->getStream())
+ );
+ }
+
+ public function testInitGame()
+ {
+ $ticTacToe = new Board($output = $this->getOutputStream(false), array(10, 10), 3, false);
+ $ticTacToe->updateGame(1, 1, 1);
+ $ticTacToe->initGame();
+
+ rewind($output->getStream());
+
+ $this->assertEquals(
+ $this->generateOutput('').
+ $this->generateOutput('-------------').
+ $this->generateOutput('| | | |').
+ $this->generateOutput('-------------').
+ $this->generateOutput('| | | |').
+ $this->generateOutput('-------------').
+ $this->generateOutput('| | | |').
+ $this->generateOutput('-------------').
+ $this->generateOutput('X Player 1 Player 2 O').
+ $this->generateOutput('').
+ $this->generateOutput('').
+ $this->generateOutput('').
+ $this->generateOutput('-------------').
+ $this->generateOutput('| | | |').
+ $this->generateOutput('-------------').
+ $this->generateOutput('| | X | |').
+ $this->generateOutput('-------------').
+ $this->generateOutput('| | | |').
+ $this->generateOutput('-------------').
+ $this->generateOutput('X Player 1 Player 2 O').
+ $this->generateOutput('Last move by player: X').
+ $this->generateOutput('').
+ $this->generateOutput('').
+ $this->generateOutput('-------------').
+ $this->generateOutput('| | | |').
+ $this->generateOutput('-------------').
+ $this->generateOutput('| | | |').
+ $this->generateOutput('-------------').
+ $this->generateOutput('| | | |').
+ $this->generateOutput('-------------').
+ $this->generateOutput('X Player 1 Player 2 O').
+ $this->generateOutput('').
+ $this->generateOutput(''),
+ stream_get_contents($output->getStream())
+ );
+ }
+
+ /**
+ * @expectedException PHPGames\Console\Exception\PlayerNotFoundException
+ */
+ public function testPlayerNotFoundException()
+ {
+ $ticTacToe = new Board($output = $this->getOutputStream(false), array(10, 10));
+ $ticTacToe->updateGame(1, 1, 3);
+ }
+
+ /**
+ * @expectedException PHPGames\Console\Exception\PlayerRepeatGameException
+ */
+ public function testLastPlayerGameException()
+ {
+ $ticTacToe = new Board($output = $this->getOutputStream(false), array(10, 10));
+ $ticTacToe->updateGame(1, 1, 1);
+ $ticTacToe->updateGame(0, 0, 1);
+ }
+
+ /**
+ * @expectedException PHPGames\Console\Exception\MoveAlreadyDoneException
+ */
+ public function testMoveAlreadyPlayedException()
+ {
+ $ticTacToe = new Board($output = $this->getOutputStream(false), array(10, 10));
+ $ticTacToe->updateGame(1, 1, 1);
+ $ticTacToe->updateGame(1, 1, 2);
+ }
+
+ protected function getOutputStream($decorated = true, $verbosity = StreamOutput::VERBOSITY_NORMAL)
+ {
+ return new StreamOutput(fopen('php://memory', 'r+', false), $verbosity, $decorated);
+ }
+
+ protected function generateOutput($expected)
+ {
+ $count = substr_count($expected, "\n");
+
+ return $expected . ($count ? "" : "\n");
+ }
+}
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
new file mode 100644
index 0000000..676c4b1
--- /dev/null
+++ b/tests/bootstrap.php
@@ -0,0 +1,8 @@
+