Merge pull request #65 from JoshuaEstes/WorkingOnTesting

Working on testing
This commit is contained in:
Joshua Estes 2014-07-21 12:35:28 -04:00
commit ec8f146902
12 changed files with 258 additions and 155 deletions

1
.gitattributes vendored
View File

@ -29,5 +29,4 @@
.travis.yml export-ignore .travis.yml export-ignore
build.xml export-ignore build.xml export-ignore
composer.json export-ignore composer.json export-ignore
/tests export-ignore
modman export-ignore modman export-ignore

1
.gitignore vendored
View File

@ -26,6 +26,7 @@ lib/bitpay/bp_config.php
/build/cache/ /build/cache/
/build/docs/ /build/docs/
/build/logs/ /build/logs/
/build/magento/
/vendor/ /vendor/
composer.lock composer.lock
composer.phar composer.phar

View File

@ -26,8 +26,10 @@ php:
- 5.3 - 5.3
install: install:
- composer install - composer install
script: ./bin/phing -propertyfile build/travis.properties build-travis script: ./bin/phing -verbose -propertyfile build/travis.properties build-travis
cache: cache:
directories: directories:
- bin/
- build/cache/ - build/cache/
- build/magento/
- vendor/ - vendor/

View File

@ -1,6 +1,6 @@
The MIT License (MIT) 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 Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@ -36,20 +36,19 @@
<target name="build" depends="prepare" <target name="build" depends="prepare"
description="Runs a full build"> description="Runs a full build">
<phingcall target="lint" /> <phingcall target="lint" />
<phingcall target="magento:install" />
<phingcall target="phpunit" /> <phingcall target="phpunit" />
<parallel threadCount="5"> <phingcall target="phpcs" />
<phingcall target="phpcs" /> <phingcall target="phpmd" />
<phingcall target="phpmd" /> <phingcall target="phploc" />
<phingcall target="phploc" /> <phingcall target="pdepend" />
<phingcall target="pdepend" /> <phingcall target="build-api-docs" />
<phingcall target="build-api-docs" />
</parallel>
</target> </target>
<!-- <!--
Build API and other documentation Build API and other documentation
--> -->
<target name="build-api-docs" depends="prepare" <target name="build-api-docs"
description="Generates API docs for the project"> description="Generates API docs for the project">
<delete dir="${phpdoc.target}" verbose="true" /> <delete dir="${phpdoc.target}" verbose="true" />
<exec executable="${project.bindir}/phpdoc" passthru="true"> <exec executable="${project.bindir}/phpdoc" passthru="true">
@ -197,4 +196,72 @@
<arg path="${phpcs.source}" /> <arg path="${phpcs.source}" />
</exec> </exec>
</target> </target>
<!--
This target will copy over the magerun config and will install magento
in the build directory. It will then symlink the plugin so that tests
can be ran.
-->
<target name="magento:install">
<delete dir="build/magento" includeemptydirs="true" />
<mkdir dir="build/magento/app/etc/" />
<copy file="build/n98-magerun.yaml" tofile="build/magento/app/etc/n98-magerun.yaml" />
<exec executable="bin/n98-magerun" passthru="true">
<arg value="install" />
<arg value="-n" />
<arg value="-vvv" />
<arg value="--magentoVersion=${magento.version}" />
<arg value="--installationFolder=build/magento" />
<arg value="--dbHost=${db.host}" />
<arg value="--dbUser=${db.user}" />
<arg value="--dbPass=${db.pass}" />
<arg value="--dbName=${db.name}" />
<arg value="--installSampleData=no" />
<arg value="--useDefaultConfigParams=yes" />
<arg value="--baseUrl=${magento.baseurl}" />
</exec>
<exec executable="bin/n98-magerun" passthru="true" dir="${project.basedir}/build/magento">
<arg value="config:set" />
<arg value="dev/template/allow_symlink" />
<arg value="1" />
</exec>
<exec executable="bin/n98-magerun" passthru="true" dir="${project.basedir}/build/magento">
<arg value="config:set" />
<arg value="dev/log/active" />
<arg value="1" />
</exec>
<exec executable="bin/n98-magerun" passthru="true" dir="${project.basedir}/build/magento">
<arg value="config:set" />
<arg value="payment/Bitcoins/api_key" />
<arg value="GArM63Kab9ahw2muesTWptJneXFoxUZoFXrAKWs5c" />
</exec>
<phingcall target="plugin:symlink" />
</target>
<!--
This will create symlinks so the module can be tested inside a magento
environment. This should closely follow the `modman` file.
-->
<target name="plugin:symlink" hidden="true">
<symlink
target="${project.basedir}/app/code/community/Bitpay"
link="${project.basedir}/build/magento/app/code/community/Bitpay"
overwrite="true" />
<symlink
target="${project.basedir}/app/design/frontend/base/default/layout/bitcoins.xml"
link="${project.basedir}/build/magento/app/design/frontend/base/default/layout/bitcoins.xml"
overwrite="true" />
<symlink
target="${project.basedir}/app/design/frontend/base/default/template/bitcoins"
link="${project.basedir}/build/magento/app/design/frontend/base/default/template/bitcoins"
overwrite="true" />
<symlink
target="${project.basedir}/app/etc/modules/Bitpay_Bitcoins.xml"
link="${project.basedir}/build/magento/app/etc/modules/Bitpay_Bitcoins.xml"
overwrite="true" />
<symlink
target="${project.basedir}/lib/bitpay"
link="${project.basedir}/build/magento/lib/bitpay"
overwrite="true" />
</target>
</project> </project>

View File

@ -22,11 +22,12 @@
# Running a build locally, this also is used # Running a build locally, this also is used
# to define all the default properties. # to define all the default properties.
DB_USER=root db.user=root
DB_PASS=root db.pass=
DB_NAME=magento db.name=magento
DB_HOST=127.0.0.1 db.host=127.0.0.1
MAGENTO_VERSION=1.9.0.1 magento.version=1.9.0.1
magento.baseurl=http://www.localhost.com
#### ####
# #
@ -100,7 +101,7 @@ phpmd.ruleset=${project.builddir}/rulesets/phpmd.xml
phpmd.report.file=${project.logsdir}/phpmd.xml phpmd.report.file=${project.logsdir}/phpmd.xml
# comma-separated string of patterns that are used to ignore directories # 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 #### #### phpmd ####
#### ####
@ -118,7 +119,7 @@ phploc.log.csv=${project.logsdir}/phploc.csv
phploc.log.xml=${project.logsdir}/phploc.xml phploc.log.xml=${project.logsdir}/phploc.xml
# Small hack to exclude multiple directories # 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 #### #### phploc ####
#### ####
@ -130,7 +131,7 @@ pdepend.jdepend.chart=${project.cachedir}/jdepend_chart.svg
pdepend.jdepend.xml=${project.logsdir}/jdepend.xml pdepend.jdepend.xml=${project.logsdir}/jdepend.xml
pdepend.overview.pyramid=${project.cachedir}/pyramid.svg pdepend.overview.pyramid=${project.cachedir}/pyramid.svg
pdepend.summary.xml=${project.logsdir}/jdepend_summary.xml 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 #### #### pdepend ####
#### ####
@ -140,7 +141,7 @@ pdepend.ignore=bin,build,vendor
phpcs.source=${project.source} phpcs.source=${project.source}
phpcs.report.xml=${project.logsdir}/phpcs.xml phpcs.report.xml=${project.logsdir}/phpcs.xml
phpcs.standard=PSR1 --standard=PSR2 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 #### #### phpcs ####
#### ####
@ -149,5 +150,5 @@ phpcs.ignore=vendor --ignore=bin --ignore=build --ignore=tests/
# #
phpdoc.directory=${project.source}/ phpdoc.directory=${project.source}/
phpdoc.target=${project.docsdir}/api phpdoc.target=${project.docsdir}/api
phpdoc.ignore=vendor/,bin/,tests/ phpdoc.ignore=vendor/,bin/,app/code/community/Bitpay/Bitcoins/tests/,build/
#### phpdoc #### #### phpdoc ####

28
build/n98-magerun.yaml Normal file
View File

@ -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

View File

@ -39,14 +39,14 @@
<testsuites> <testsuites>
<testsuite name="bitpay/magento-plugin Test Suite"> <testsuite name="bitpay/magento-plugin Test Suite">
<directory>tests/</directory> <directory>../tests/</directory>
</testsuite> </testsuite>
</testsuites> </testsuites>
<filter> <filter>
<whitelist> <whitelist>
<directory>app/</directory> <directory>../app/code/community/Bitpay/Bitcoins/</directory>
<directory>lib/</directory> <directory>../lib/bitpay</directory>
</whitelist> </whitelist>
</filter> </filter>

View File

@ -21,132 +21,4 @@
# THE SOFTWARE. # THE SOFTWARE.
# Properties file for running a build on Travis CI # Properties file for running a build on Travis CI
DB_USER=travis 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 ####

View File

@ -22,8 +22,7 @@
"pdepend/pdepend" : "1.1.0", "pdepend/pdepend" : "1.1.0",
"squizlabs/php_codesniffer": "*", "squizlabs/php_codesniffer": "*",
"phpunit/phpunit": "*", "phpunit/phpunit": "*",
"phploc/phploc": "*", "phploc/phploc": "*"
"phpunit/phpunit-skeleton-generator": "*"
}, },
"config": { "config": {
"bin-dir": "bin" "bin-dir": "bin"

View File

@ -0,0 +1,102 @@
<?php
/**
* The MIT License (MIT)
*
* 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
* 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.
*/
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()
{
$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();
}
}

32
tests/bootstrap.php Normal file
View File

@ -0,0 +1,32 @@
<?php
/**
* The MIT License (MIT)
*
* 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
* 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.
*/
if ($mage = realpath(__DIR__ . '/../build/magento/app/Mage.php')) {
require_once $mage;
Mage::app();
} else {
exit('Could not find Mage.php');
}