Commit 4ef022e1 authored by Mark Harding's avatar Mark Harding

(fix): resolve backend tests for new wire features

1 merge request!254WIP: &37 - Multi-currency
Pipeline #77308486 running with stages
This diff is collapsed.
......@@ -17,81 +17,59 @@ use Prophecy\Argument;
class ManagerSpec extends ObjectBehavior
{
protected $cache;
protected $cacheDelegate;
protected $repo;
protected $subscriptionsManager;
protected $txManager;
protected $txRepo;
protected $config;
protected $queue;
protected $client;
protected $token;
protected $cap;
protected $dispatcher;
protected $call;
protected $balance;
protected $redisLock;
protected $plusDelegate;
protected $offchainTxs;
public function let(
Redis $cache,
Repository $repo,
SubscriptionsManager $subscriptionsManager,
BlockchainManager $txManager,
Core\Blockchain\Transactions\Repository $txRepo,
Config $config,
Client $queue,
Core\Blockchain\Services\Ethereum $client,
Core\Blockchain\Token $token,
Core\Blockchain\Wallets\OffChain\Cap $cap,
Core\Events\EventsDispatcher $dispatcher,
Core\Data\Call $call,
Core\Blockchain\Wallets\OffChain\Balance $balance,
Core\Data\Locks\Redis $redisLock,
Core\Wire\Delegates\Plus $plusDelegate,
Core\Blockchain\Wallets\OffChain\Transactions $offchainTxs
Core\Wire\Delegates\RecurringDelegate $recurringDelegate,
Core\Wire\Delegates\NotificationDelegate $notificationDelegate,
Core\Wire\Delegates\CacheDelegate $cacheDelegate,
Core\Blockchain\Wallets\OffChain\Transactions $offchainTxs,
Core\Payments\Stripe\Intents\Manager $stripeIntentsManager
) {
$this->beConstructedWith($cache, $repo, $subscriptionsManager, $txManager, $txRepo, $config, $queue, $client,
$token, $cap, $dispatcher, $plusDelegate, $offchainTxs);
Core\Di\Di::_()->bind('Database\Cassandra\Entities', function ($di) use ($call) {
return $call->getWrappedObject();
});
Core\Di\Di::_()->bind('Database\Cassandra\UserIndexes', function ($di) use ($call) {
return $call->getWrappedObject();
});
Core\Di\Di::_()->bind('Blockchain\Transactions\Repository', function ($di) use ($txRepo) {
return $txRepo->getWrappedObject();
});
Core\Di\Di::_()->bind('Blockchain\Wallets\OffChain\Balance', function ($di) use ($balance) {
return $balance->getWrappedObject();
});
Core\Di\Di::_()->bind('Database\Locks', function ($di) use ($redisLock) {
return $redisLock->getWrappedObject();
});
$this->cache = $cache;
$this->beConstructedWith(
$repo,
$txManager,
$txRepo,
$config,
$client,
$token,
$cap,
$plusDelegate,
$recurringDelegate,
$notificationDelegate,
$cacheDelegate,
$offchainTxs,
$stripeIntentsManager
);
$this->cacheDelegate = $cacheDelegate;
$this->repo = $repo;
$this->subscriptionsManager = $subscriptionsManager;
$this->txManager = $txManager;
$this->txRepo = $txRepo;
$this->config = $config;
$this->queue = $queue;
$this->client = $client;
$this->token = $token;
$this->cap = $cap;
$this->dispatcher = $dispatcher;
$this->call = $call;
$this->balance = $balance;
$this->redisLock = $redisLock;
$this->plusDelegate = $plusDelegate;
$this->offchainTxs = $offchainTxs;
......@@ -155,16 +133,17 @@ class ManagerSpec extends ObjectBehavior
->shouldBeCalled()
->willReturn(true);
$this->queue->setQueue(Argument::any())
/*$this->queue->setQueue(Argument::any())
->shouldBeCalled()
->willReturn($this->queue);
$this->queue->send(Argument::any())
->shouldBeCalled();
->shouldBeCalled();*/
$receiver = new User();
$receiver->guid = 123;
$sender = new User();
$sender->guid = 123;
$wire = new WireModel();
$wire->setReceiver($receiver)
->setSender($sender)
......
......@@ -3,7 +3,8 @@
namespace Spec\Minds\Core\Wire\Subscriptions;
use Minds\Core\Di\Di;
use Minds\Core\Payments\Subscriptions\Manager;
use Minds\Core\Wire\Manager as WireManager;
use Minds\Core\Payments\Subscriptions\Manager as SubscriptionsManager;
use Minds\Core\Payments\Subscriptions\Repository;
use Minds\Core\Wire\Exceptions\WalletNotSetupException;
use Minds\Entities\User;
......@@ -19,10 +20,11 @@ class ManagerSpec extends ObjectBehavior
}
function it_should_create_a_subscription(
Manager $manager
WireManager $wireManager,
SubscriptionsManager $subscriptionsManager
)
{
$this->beConstructedWith($manager);
$this->beConstructedWith($wireManager, $subscriptionsManager);
$sender = new User();
......@@ -30,13 +32,13 @@ class ManagerSpec extends ObjectBehavior
$receiver = new User();
$receiver->guid = 456;
$manager->setSubscription(Argument::that(function($subscription) {
$subscriptionsManager->setSubscription(Argument::that(function($subscription) {
return $subscription->getUser()->guid == 123
&& $subscription->getEntity()->guid == 456
&& $subscription->getAmount() == 5;
}))
->willReturn(123);
$manager->create()->shouldBeCalled();
$subscriptionsManager->create()->shouldBeCalled();
$this->setAmount(5)
->setSender($sender)
......
......@@ -20,22 +20,26 @@ $CONFIG->cassandra->username = 'cassandra';
$CONFIG->cassandra->password = 'cassandra';
$CONFIG->payments = [
'braintree' => [
'default' => [
'environment' => 'sandbox',
'merchant_id' => 'foobar',
'master_merchant_id' => 'foobar',
'public_key' => 'random',
'private_key' => 'random_private'
'braintree' => [
'default' => [
'environment' => 'sandbox',
'merchant_id' => 'foobar',
'master_merchant_id' => 'foobar',
'public_key' => 'random',
'private_key' => 'random_private'
],
'merchants' => [
'environment' => 'sandbox',
'merchant_id' => 'foobar',
'master_merchant_id' => 'foobar',
'public_key' => 'random',
'private_key' => 'random_private'
],
],
'merchants' => [
'environment' => 'sandbox',
'merchant_id' => 'foobar',
'master_merchant_id' => 'foobar',
'public_key' => 'random',
'private_key' => 'random_private'
'stripe' => [
'api_key' => 'phpspec',
],
]];
];
class Mock
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment