Working on added tests to the project

This commit is contained in:
Joshua Estes 2014-07-17 15:52:39 -04:00
parent ef7ea99452
commit 02e482854f
11 changed files with 252 additions and 23 deletions

1
.gitignore vendored
View File

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

View File

@ -30,4 +30,5 @@ script: ./bin/phing -propertyfile build/travis.properties build-travis
cache:
directories:
- build/cache/
- build/magento/
- vendor/

View File

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

View File

@ -0,0 +1,87 @@
<?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'));
}
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()
{
}
}

View File

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

View File

@ -36,14 +36,13 @@
<target name="build" depends="prepare"
description="Runs a full build">
<phingcall target="lint" />
<phingcall target="magento:install" />
<phingcall target="phpunit" />
<parallel threadCount="5">
<phingcall target="phpcs" />
<phingcall target="phpmd" />
<phingcall target="phploc" />
<phingcall target="pdepend" />
<phingcall target="build-api-docs" />
</parallel>
<phingcall target="phpcs" />
<phingcall target="phpmd" />
<phingcall target="phploc" />
<phingcall target="pdepend" />
<phingcall target="build-api-docs" />
</target>
<!--
@ -197,4 +196,72 @@
<arg path="${phpcs.source}" />
</exec>
</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>

View File

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

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

@ -27,7 +27,7 @@
<phpunit
backupGlobals = "false"
backupStaticAttributes = "false"
bootstrap = "../tests/bootstrap.php"
bootstrap = "magento/app/code/community/Bitpay/Bitcoins/tests/bootstrap.php"
colors = "true"
convertErrorsToExceptions = "true"
convertNoticesToExceptions = "true"
@ -39,14 +39,17 @@
<testsuites>
<testsuite name="bitpay/magento-plugin Test Suite">
<directory>tests/</directory>
<directory>magento/app/code/community/Bitpay/Bitcoins/tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>app/</directory>
<directory>lib/</directory>
<directory>magento/app/code/community/Bitpay/Bitcoins/</directory>
<directory>magento/lib/bitpay</directory>
<exclude>
<directory>magento/app/code/community/Bitpay/Bitcoins/tests</directory>
</exclude>
</whitelist>
</filter>

View File

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

View File

@ -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"
},