From 02e482854fd2ac3f1e2b09d853c9379df163050c Mon Sep 17 00:00:00 2001 From: Joshua Estes Date: Thu, 17 Jul 2014 15:52:39 -0400 Subject: [PATCH 1/8] Working on added tests to the project --- .gitignore | 1 + .travis.yml | 1 + LICENSE | 2 +- .../Bitcoins/Model/PaymentMethodTest.php | 87 +++++++++++++++++++ .../Bitpay/Bitcoins/tests/bootstrap.php | 35 ++++++++ build.xml | 81 +++++++++++++++-- build/build.properties | 13 +-- build/n98-magerun.yaml | 28 ++++++ build/phpunit.xml.dist | 11 ++- build/travis.properties | 10 +-- composer.json | 6 ++ 11 files changed, 252 insertions(+), 23 deletions(-) create mode 100644 app/code/community/Bitpay/Bitcoins/tests/Bitpay/Bitcoins/Model/PaymentMethodTest.php create mode 100644 app/code/community/Bitpay/Bitcoins/tests/bootstrap.php create mode 100644 build/n98-magerun.yaml diff --git a/.gitignore b/.gitignore index 0b34963..8f41432 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,7 @@ lib/bitpay/bp_config.php /build/cache/ /build/docs/ /build/logs/ +/build/magento/ /vendor/ composer.lock composer.phar diff --git a/.travis.yml b/.travis.yml index e714753..8027ea5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,4 +30,5 @@ script: ./bin/phing -propertyfile build/travis.properties build-travis cache: directories: - build/cache/ + - build/magento/ - vendor/ diff --git a/LICENSE b/LICENSE index 7a8d8f8..5dd2731 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2011-2014 BitPay LLC +Copyright (c) 2011-2014 BitPay Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/app/code/community/Bitpay/Bitcoins/tests/Bitpay/Bitcoins/Model/PaymentMethodTest.php b/app/code/community/Bitpay/Bitcoins/tests/Bitpay/Bitcoins/Model/PaymentMethodTest.php new file mode 100644 index 0000000..623c1d1 --- /dev/null +++ b/app/code/community/Bitpay/Bitcoins/tests/Bitpay/Bitcoins/Model/PaymentMethodTest.php @@ -0,0 +1,87 @@ +assertTrue($paymentMethod->canUseForCurrency('USD')); + } + + public function testCanUseCheckout() + { + } + + public function testIsApiKeyConfigured() + { + } + + public function testIsTransactionSpeedConfigured() + { + } + + public function testAuthorize() + { + } + + public function testCheckForPayment() + { + } + + public function testInvoiceOrder() + { + } + + public function testMarkOrderPaid() + { + } + + public function testMarkOrderComplete() + { + } + + public function testMarkOrderCancelled() + { + } + + public function testExtractAddress() + { + } + + public function testCreateInvoiceAndRedirect() + { + } + + public function testGetOrderPlaceRedirectUrl() + { + } + + public function testGetQuoteHash() + { + } +} diff --git a/app/code/community/Bitpay/Bitcoins/tests/bootstrap.php b/app/code/community/Bitpay/Bitcoins/tests/bootstrap.php new file mode 100644 index 0000000..50c8c64 --- /dev/null +++ b/app/code/community/Bitpay/Bitcoins/tests/bootstrap.php @@ -0,0 +1,35 @@ + + - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build/build.properties b/build/build.properties index 248d96f..f07950e 100644 --- a/build/build.properties +++ b/build/build.properties @@ -22,11 +22,12 @@ # Running a build locally, this also is used # to define all the default properties. -DB_USER=root -DB_PASS=root -DB_NAME=magento -DB_HOST=127.0.0.1 -MAGENTO_VERSION=1.9.0.1 +db.user=root +db.pass= +db.name=magento +db.host=127.0.0.1 +magento.version=1.9.0.1 +magento.baseurl=http://www.localhost.com #### # @@ -149,5 +150,5 @@ phpcs.ignore=vendor --ignore=bin --ignore=build --ignore=tests/ # phpdoc.directory=${project.source}/ phpdoc.target=${project.docsdir}/api -phpdoc.ignore=vendor/,bin/,tests/ +phpdoc.ignore=vendor/,bin/,tests/,build/ #### phpdoc #### diff --git a/build/n98-magerun.yaml b/build/n98-magerun.yaml new file mode 100644 index 0000000..246b2ea --- /dev/null +++ b/build/n98-magerun.yaml @@ -0,0 +1,28 @@ +# The MIT License (MIT) +# +# Copyright (c) 2011-2014 BitPay LLC +# +# 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. +commands: + N98\Magento\Command\Installer\InstallCommand: + installation: + defaults: + currency: USD + locale: en_US + timezone: America/New_York diff --git a/build/phpunit.xml.dist b/build/phpunit.xml.dist index 38d2db5..f501086 100644 --- a/build/phpunit.xml.dist +++ b/build/phpunit.xml.dist @@ -27,7 +27,7 @@ - tests/ + magento/app/code/community/Bitpay/Bitcoins/tests/ - app/ - lib/ + magento/app/code/community/Bitpay/Bitcoins/ + magento/lib/bitpay + + magento/app/code/community/Bitpay/Bitcoins/tests + diff --git a/build/travis.properties b/build/travis.properties index 796edbc..6a14969 100644 --- a/build/travis.properties +++ b/build/travis.properties @@ -21,11 +21,11 @@ # THE SOFTWARE. # Properties file for running a build on Travis CI -DB_USER=travis -DB_PASS= -DB_NAME=magento -DB_HOST=127.0.0.1 -MAGENTO_VERSION=1.9.0.1 +db.user=travis +db.pass= +db.name=magento +db.host=127.0.0.1 +magento.version=1.9.0.1 #### # diff --git a/composer.json b/composer.json index 43faa1b..83b6770 100644 --- a/composer.json +++ b/composer.json @@ -11,6 +11,12 @@ "issues": "https://github.com/bitpay/magento-plugin/issues", "source": "https://github.com/bitpay/magento-plugin" }, + "repositories": [ + { + "type": "vcs", + "url": "https://github.com/colinmollenhour/modman.git" + } + ], "require": { "composer/installers": "~1.0" }, From 0d7ba17f471c32583feea66cfa66e60cdf905e51 Mon Sep 17 00:00:00 2001 From: Joshua Estes Date: Thu, 17 Jul 2014 16:08:38 -0400 Subject: [PATCH 2/8] A few minor updates and fixes --- build.xml | 2 +- build/build.properties | 10 ++-- build/travis.properties | 128 ---------------------------------------- 3 files changed, 6 insertions(+), 134 deletions(-) diff --git a/build.xml b/build.xml index 772cd95..72738c1 100644 --- a/build.xml +++ b/build.xml @@ -48,7 +48,7 @@ - diff --git a/build/build.properties b/build/build.properties index f07950e..8881bae 100644 --- a/build/build.properties +++ b/build/build.properties @@ -101,7 +101,7 @@ phpmd.ruleset=${project.builddir}/rulesets/phpmd.xml phpmd.report.file=${project.logsdir}/phpmd.xml # comma-separated string of patterns that are used to ignore directories -phpmd.exclude=${project.bindir},${project.builddir},${project.vendordir} +phpmd.exclude=${project.bindir},${project.builddir},${project.vendordir},app/code/community/Bitpay/Bitcoins/tests #### phpmd #### #### @@ -119,7 +119,7 @@ phploc.log.csv=${project.logsdir}/phploc.csv phploc.log.xml=${project.logsdir}/phploc.xml # Small hack to exclude multiple directories -phploc.exclude=vendor --exclude=build --exclude=bin +phploc.exclude=vendor --exclude=build --exclude=bin --exclude=app/code/community/Bitpay/Bitcoins/tests #### phploc #### #### @@ -131,7 +131,7 @@ pdepend.jdepend.chart=${project.cachedir}/jdepend_chart.svg pdepend.jdepend.xml=${project.logsdir}/jdepend.xml pdepend.overview.pyramid=${project.cachedir}/pyramid.svg pdepend.summary.xml=${project.logsdir}/jdepend_summary.xml -pdepend.ignore=bin,build,vendor +pdepend.ignore=bin,build,vendor,app/code/community/Bitpay/Bitcoins/tests #### pdepend #### #### @@ -141,7 +141,7 @@ pdepend.ignore=bin,build,vendor phpcs.source=${project.source} phpcs.report.xml=${project.logsdir}/phpcs.xml phpcs.standard=PSR1 --standard=PSR2 -phpcs.ignore=vendor --ignore=bin --ignore=build --ignore=tests/ +phpcs.ignore=vendor --ignore=bin --ignore=build --ignore=app/code/community/Bitpay/Bitcoins/tests/ #### phpcs #### #### @@ -150,5 +150,5 @@ phpcs.ignore=vendor --ignore=bin --ignore=build --ignore=tests/ # phpdoc.directory=${project.source}/ phpdoc.target=${project.docsdir}/api -phpdoc.ignore=vendor/,bin/,tests/,build/ +phpdoc.ignore=vendor/,bin/,app/code/community/Bitpay/Bitcoins/tests/,build/ #### phpdoc #### diff --git a/build/travis.properties b/build/travis.properties index 6a14969..cb38dee 100644 --- a/build/travis.properties +++ b/build/travis.properties @@ -22,131 +22,3 @@ # Properties file for running a build on Travis CI db.user=travis -db.pass= -db.name=magento -db.host=127.0.0.1 -magento.version=1.9.0.1 - -#### -# -# This properties file is used to configure the entire build. The purpose of -# this file is so that it is easy to drop it into a project and change a few -# of these settings and have a build run successfully. -# -# NOTE: You may still need to take a look at and edit `phpunit.xml.dist`. -# - -#### -# -# Directory Configuration -# - -# The main location of all the projects source code, this should be the only -# property that you need to change. Code can live in the root directory or it -# can live inside of it's own directory. -project.source=${project.basedir} -#project.source=${project.basedir}/src - -# --- You shouldn't need to edit any of the below value --- - -# Location of all executables, this is the location on the `bin-dir` that you -# have configured in `composer.json`. If you have not configured this in -# 1composer.json` the default is to put it in the `vendor` directory. -project.bindir=${project.basedir}/bin -#project.bindir=${project.basedir}/vendor/bin - -# Where to put the build artifacts, cache, logs, docs, etc. -project.builddir=${project.basedir}/build - -# Location of vendor directory created by composer. -project.vendordir=${project.basedir}/vendor - -# build artifacts for code analysis -project.logsdir=${project.builddir}/logs - -# Build artifacts that can be reused or updated, they do not need to be deleted -# every build. These would include charts and images. -project.cachedir=${project.builddir}/cache - -# Location of generated documentation such as API and code coverage -project.docsdir=${project.builddir}/docs -#### directory #### - -#### -# -# phpunit configuration -# - -# Directory that contains phpunit.xml or the phpunit.xml file itself -phpunit.configuration=${project.builddir}/phpunit.xml.dist -#### phpunit #### - -#### -# -# phpmd configuration -# - -# php source code filename or directory. Can be a comma-separated string -phpmd.source=${project.source} - -# report format, text, xml, or html -phpmd.report.format=xml - -# ruleset filename or a comma-separated string of rulesetfilenames -phpmd.ruleset=${project.builddir}/rulesets/phpmd.xml - -# send report output to this file -phpmd.report.file=${project.logsdir}/phpmd.xml - -# comma-separated string of patterns that are used to ignore directories -phpmd.exclude=${project.bindir},${project.builddir},${project.vendordir} -#### phpmd #### - -#### -# -# phploc Configuration -# - -# Source directory of project -phploc.source=${project.source}/ - -# Where to put the csv log -phploc.log.csv=${project.logsdir}/phploc.csv - -# Location of xml log -phploc.log.xml=${project.logsdir}/phploc.xml - -# Small hack to exclude multiple directories -phploc.exclude=vendor --exclude=build --exclude=bin -#### phploc #### - -#### -# -# pdepend configuration -# -pdepend.source=${project.source} -pdepend.jdepend.chart=${project.cachedir}/jdepend_chart.svg -pdepend.jdepend.xml=${project.logsdir}/jdepend.xml -pdepend.overview.pyramid=${project.cachedir}/pyramid.svg -pdepend.summary.xml=${project.logsdir}/jdepend_summary.xml -pdepend.ignore=bin,build,vendor -#### pdepend #### - -#### -# -# phpcs configuration -# -phpcs.source=${project.source} -phpcs.report.xml=${project.logsdir}/phpcs.xml -phpcs.standard=PSR1 --standard=PSR2 -phpcs.ignore=vendor --ignore=bin --ignore=build -#### phpcs #### - -#### -# -# phpdoc configuration -# -phpdoc.directory=${project.source}/ -phpdoc.target=${project.docsdir}/api -phpdoc.ignore=vendor/,bin/ -#### phpdoc #### From 2b1ce93debc78f2e6cea45580ba07a658c8d91e9 Mon Sep 17 00:00:00 2001 From: Joshua Estes Date: Thu, 17 Jul 2014 16:15:51 -0400 Subject: [PATCH 3/8] Not using this, removing --- composer.json | 7 ------- 1 file changed, 7 deletions(-) diff --git a/composer.json b/composer.json index 83b6770..374d64a 100644 --- a/composer.json +++ b/composer.json @@ -11,17 +11,10 @@ "issues": "https://github.com/bitpay/magento-plugin/issues", "source": "https://github.com/bitpay/magento-plugin" }, - "repositories": [ - { - "type": "vcs", - "url": "https://github.com/colinmollenhour/modman.git" - } - ], "require": { "composer/installers": "~1.0" }, "require-dev": { - "colinmollenhour/modman": "*", "n98/magerun": "*", "phpmd/phpmd": "*", "phpdocumentor/phpdocumentor": "*", From c0bf4957835c8f593aa9240b23af5a7be9e86928 Mon Sep 17 00:00:00 2001 From: Joshua Estes Date: Thu, 17 Jul 2014 16:17:15 -0400 Subject: [PATCH 4/8] Not using this either --- composer.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 374d64a..d2db870 100644 --- a/composer.json +++ b/composer.json @@ -22,8 +22,7 @@ "pdepend/pdepend" : "1.1.0", "squizlabs/php_codesniffer": "*", "phpunit/phpunit": "*", - "phploc/phploc": "*", - "phpunit/phpunit-skeleton-generator": "*" + "phploc/phploc": "*" }, "config": { "bin-dir": "bin" From 41baf4d8d7bae485c4f733b0a2bdfcfd9895cdb0 Mon Sep 17 00:00:00 2001 From: Joshua Estes Date: Thu, 17 Jul 2014 16:23:22 -0400 Subject: [PATCH 5/8] Minor tweaks --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8027ea5..c4bebd5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,9 +26,10 @@ php: - 5.3 install: - composer install -script: ./bin/phing -propertyfile build/travis.properties build-travis +script: ./bin/phing -verbose -propertyfile build/travis.properties build-travis cache: directories: + - bin/ - build/cache/ - build/magento/ - vendor/ From 2593183300a24cff3529443c5e15eab1c789d8d9 Mon Sep 17 00:00:00 2001 From: Joshua Estes Date: Mon, 21 Jul 2014 11:10:36 -0400 Subject: [PATCH 6/8] Updated so tests are in the root directory --- .gitattributes | 1 - build/phpunit.xml.dist | 11 ++++------- .../Bitpay/Bitcoins/Model/PaymentMethodTest.php | 0 .../Bitpay/Bitcoins/tests => tests}/bootstrap.php | 5 +---- 4 files changed, 5 insertions(+), 12 deletions(-) rename {app/code/community/Bitpay/Bitcoins/tests => tests}/Bitpay/Bitcoins/Model/PaymentMethodTest.php (100%) rename {app/code/community/Bitpay/Bitcoins/tests => tests}/bootstrap.php (86%) diff --git a/.gitattributes b/.gitattributes index d88b370..f8ef91d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -29,5 +29,4 @@ .travis.yml export-ignore build.xml export-ignore composer.json export-ignore -/tests export-ignore modman export-ignore diff --git a/build/phpunit.xml.dist b/build/phpunit.xml.dist index f501086..9898031 100644 --- a/build/phpunit.xml.dist +++ b/build/phpunit.xml.dist @@ -27,7 +27,7 @@ - magento/app/code/community/Bitpay/Bitcoins/tests/ + ../tests/ - magento/app/code/community/Bitpay/Bitcoins/ - magento/lib/bitpay - - magento/app/code/community/Bitpay/Bitcoins/tests - + ../app/code/community/Bitpay/Bitcoins/ + ../lib/bitpay diff --git a/app/code/community/Bitpay/Bitcoins/tests/Bitpay/Bitcoins/Model/PaymentMethodTest.php b/tests/Bitpay/Bitcoins/Model/PaymentMethodTest.php similarity index 100% rename from app/code/community/Bitpay/Bitcoins/tests/Bitpay/Bitcoins/Model/PaymentMethodTest.php rename to tests/Bitpay/Bitcoins/Model/PaymentMethodTest.php diff --git a/app/code/community/Bitpay/Bitcoins/tests/bootstrap.php b/tests/bootstrap.php similarity index 86% rename from app/code/community/Bitpay/Bitcoins/tests/bootstrap.php rename to tests/bootstrap.php index 50c8c64..e597545 100644 --- a/app/code/community/Bitpay/Bitcoins/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -24,10 +24,7 @@ * THE SOFTWARE. */ -if ($mage = realpath(__DIR__ . '/../../../../../Mage.php')) { - require_once $mage; - Mage::app(); -} elseif ($mage = realpath(__DIR__ . '/../../../../../../build/magento/app/Mage.php')) { +if ($mage = realpath(__DIR__ . '/../build/magento/app/Mage.php')) { require_once $mage; Mage::app(); } else { From 0b4d62eafbb53a1d28e7c8a4bf7245a1642e9421 Mon Sep 17 00:00:00 2001 From: Joshua Estes Date: Mon, 21 Jul 2014 12:18:27 -0400 Subject: [PATCH 7/8] Updated test to make sure it only takes valid currencies --- tests/Bitpay/Bitcoins/Model/PaymentMethodTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/Bitpay/Bitcoins/Model/PaymentMethodTest.php b/tests/Bitpay/Bitcoins/Model/PaymentMethodTest.php index 623c1d1..29f317c 100644 --- a/tests/Bitpay/Bitcoins/Model/PaymentMethodTest.php +++ b/tests/Bitpay/Bitcoins/Model/PaymentMethodTest.php @@ -30,7 +30,9 @@ class Bitpay_Bitcoins_Model_PaymentMethodTest extends PHPUnit_Framework_TestCase public function testCanUseForCurrency() { $paymentMethod = Mage::getModel('Bitcoins/paymentMethod'); + $this->assertTrue($paymentMethod->canUseForCurrency('USD')); + $this->assertFalse($paymentMethod->canUseForCurrency('ASDF')); } public function testCanUseCheckout() From 8d30dfcf0c74c638c3298beb968e5521926e2317 Mon Sep 17 00:00:00 2001 From: Joshua Estes Date: Mon, 21 Jul 2014 12:31:27 -0400 Subject: [PATCH 8/8] Marked other tests as incomplete --- tests/Bitpay/Bitcoins/Model/PaymentMethodTest.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/Bitpay/Bitcoins/Model/PaymentMethodTest.php b/tests/Bitpay/Bitcoins/Model/PaymentMethodTest.php index 29f317c..9b81e93 100644 --- a/tests/Bitpay/Bitcoins/Model/PaymentMethodTest.php +++ b/tests/Bitpay/Bitcoins/Model/PaymentMethodTest.php @@ -37,53 +37,66 @@ class Bitpay_Bitcoins_Model_PaymentMethodTest extends PHPUnit_Framework_TestCase public function testCanUseCheckout() { + $this->markTestIncomplete(); } public function testIsApiKeyConfigured() { + $this->markTestIncomplete(); } public function testIsTransactionSpeedConfigured() { + $this->markTestIncomplete(); } public function testAuthorize() { + $this->markTestIncomplete(); } public function testCheckForPayment() { + $this->markTestIncomplete(); } public function testInvoiceOrder() { + $this->markTestIncomplete(); } public function testMarkOrderPaid() { + $this->markTestIncomplete(); } public function testMarkOrderComplete() { + $this->markTestIncomplete(); } public function testMarkOrderCancelled() { + $this->markTestIncomplete(); } public function testExtractAddress() { + $this->markTestIncomplete(); } public function testCreateInvoiceAndRedirect() { + $this->markTestIncomplete(); } public function testGetOrderPlaceRedirectUrl() { + $this->markTestIncomplete(); } public function testGetQuoteHash() { + $this->markTestIncomplete(); } }