Skip to content

Commit c5eb581

Browse files
committed
Add tests
1 parent 628a9c5 commit c5eb581

File tree

5 files changed

+379
-1
lines changed

5 files changed

+379
-1
lines changed

composer.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,20 @@
1414
"guzzlehttp/guzzle": "~6.2"
1515
},
1616
"require-dev": {
17-
"phpunit/phpunit": "^5.7"
17+
"phpunit/phpunit": "^5.7",
18+
"orchestra/testbench": "^3.3.3"
1819
},
1920
"autoload": {
2021
"psr-4": {
2122
"Maksa988\\UnitPay\\Facades\\": "src/Facades",
2223
"Maksa988\\UnitPay\\": "src"
2324
}
2425
},
26+
"autoload-dev": {
27+
"psr-4": {
28+
"Maksa988\\UnitPay\\Test\\": "tests/"
29+
}
30+
},
2531
"config": {
2632
"sort-packages": true
2733
},

phpunit.xml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit bootstrap="vendor/autoload.php"
3+
backupGlobals="false"
4+
backupStaticAttributes="false"
5+
colors="true"
6+
verbose="true"
7+
convertErrorsToExceptions="true"
8+
convertNoticesToExceptions="true"
9+
convertWarningsToExceptions="true"
10+
processIsolation="false"
11+
stopOnFailure="false">
12+
<testsuites>
13+
<testsuite name="Unit Tests">
14+
<directory>tests</directory>
15+
</testsuite>
16+
</testsuites>
17+
<filter>
18+
<whitelist>
19+
<directory suffix=".php">src/</directory>
20+
</whitelist>
21+
</filter>
22+
<php>
23+
<env name="APP_ENV" value="testing"/>
24+
<env name="CACHE_DRIVER" value="array"/>
25+
<env name="SESSION_DRIVER" value="array"/>
26+
<env name="QUEUE_DRIVER" value="sync"/>
27+
</php>
28+
</phpunit>

tests/Fake/Order.php

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
<?php
2+
3+
namespace Maksa988\UnitPay\Test\Fake;
4+
5+
use Illuminate\Http\Request;
6+
use Illuminate\Database\Eloquent\Model;
7+
8+
class Order extends Model
9+
{
10+
protected $fillable = [
11+
'_orderSum',
12+
'_orderCurrency',
13+
'_orderStatus',
14+
];
15+
16+
public function __construct(array $attributes = [])
17+
{
18+
parent::__construct($attributes);
19+
}
20+
21+
public static function SearchOrderFilterFails(Request $request, $order_id)
22+
{
23+
return false;
24+
}
25+
26+
public static function SearchOrderFilterPaidforPayOrderFromGate(Request $request, $order_id, $orderStatus = 'paid', $orderSum = '1', $orderCurrency = '1')
27+
{
28+
$order = new self([
29+
'_orderSum' => $orderSum,
30+
'_orderCurrency' => $orderCurrency,
31+
'_orderStatus' => $orderStatus,
32+
]);
33+
34+
return $order;
35+
}
36+
37+
public static function SearchOrderFilterPaid(Request $request, $order_id, $orderStatus = 'paid', $orderSum = '12345', $orderCurrency = 'RUB')
38+
{
39+
$order = new self([
40+
'_orderSum' => $orderSum,
41+
'_orderCurrency' => $orderCurrency,
42+
'_orderStatus' => $orderStatus,
43+
]);
44+
45+
return $order;
46+
}
47+
48+
public static function SearchOrderFilterNotPaid(Request $request, $order_id, $orderStatus = 'no_paid', $orderSum = '', $orderCurrency = 'RUB')
49+
{
50+
$order = new self([
51+
'_orderSum' => $orderSum,
52+
'_orderCurrency' => $orderCurrency,
53+
'_orderStatus' => $orderStatus,
54+
]);
55+
56+
return $order;
57+
}
58+
59+
public static function PaidOrderFilterFails(Request $request, $order)
60+
{
61+
return false;
62+
}
63+
64+
public static function PaidOrderFilter(Request $request, $order)
65+
{
66+
return true;
67+
}
68+
69+
/**
70+
* Get the relationships for the entity.
71+
*
72+
* @return array
73+
*/
74+
public function getQueueableRelations()
75+
{
76+
// TODO: Implement getQueueableRelations() method.
77+
}
78+
79+
/**
80+
* Get the connection of the entity.
81+
*
82+
* @return string|null
83+
*/
84+
public function getQueueableConnection()
85+
{
86+
// TODO: Implement getQueueableConnection() method.
87+
}
88+
89+
/**
90+
* Retrieve the model for a bound value.
91+
*
92+
* @param mixed $value
93+
* @return \Illuminate\Database\Eloquent\Model|null
94+
*/
95+
public function resolveRouteBinding($value)
96+
{
97+
// TODO: Implement resolveRouteBinding() method.
98+
}
99+
}

tests/TestCase.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
namespace Maksa988\UnitPay\Test;
4+
5+
use Maksa988\UnitPay\UnitPay;
6+
use Maksa988\UnitPay\UnitPayServiceProvider;
7+
use Orchestra\Testbench\TestCase as Orchestra;
8+
9+
class TestCase extends Orchestra
10+
{
11+
/**
12+
* @var UnitPay
13+
*/
14+
protected $unitpay;
15+
16+
/**
17+
*
18+
*/
19+
public function setUp()
20+
{
21+
parent::setUp();
22+
23+
$this->unitpay = $this->app['unitpay'];
24+
25+
$this->app['config']->set('unitpay.public_key', 'public_key');
26+
$this->app['config']->set('unitpay.secret_key', 'secret_key');
27+
}
28+
29+
/**
30+
* @param \Illuminate\Foundation\Application $app
31+
* @return array
32+
*/
33+
protected function getPackageProviders($app)
34+
{
35+
return [
36+
UnitPayServiceProvider::class,
37+
];
38+
}
39+
40+
/**
41+
* @param array $config
42+
*/
43+
protected function withConfig(array $config)
44+
{
45+
$this->app['config']->set($config);
46+
$this->app->forgetInstance(UnitPay::class);
47+
$this->unitpay = $this->app->make(UnitPay::class);
48+
}
49+
}

0 commit comments

Comments
 (0)