예제 #1
0
 /** @before */
 function generateFixtures()
 {
     $this->members = $this->membersInstance();
     $this->existingMember = A::member()->withId('abcd')->withBalance(3000)->build();
     $this->members->add(A::member()->withId('wxyz')->withBalance(1000)->build());
     $this->members->add($this->existingMember);
     $this->members->add(A::member()->withId('hijk')->build());
 }
예제 #2
0
 /** @test */
 function beneficiary_balance_should_increase_after_funds_have_been_transferred()
 {
     $this->forAll(Generator\int(1, 10000))->then(function ($amount) {
         $fromMember = A::member()->withBalance(10000)->build();
         $toMember = A::member()->withBalance(5000)->build();
         $fromMember->transfer(Money::MXN($amount), $toMember);
         $this->assertBalanceIsGreaterThan(5000, $toMember, "Transferring {$amount} increased balance of receiver member");
     });
 }
 /** @test */
 function it_should_send_deposit_received_email()
 {
     $template = Mockery::mock(TemplateEngine::class);
     $template->shouldReceive('render')->once()->with(Mockery::type('string'), Mockery::type('array'));
     $transport = new InMemory();
     $sender = new TransferFundsZendMailSender($template, $transport);
     $sender->sendDepositReceivedEmail(A::member()->build()->information(), A::member()->withEmail('*****@*****.**')->build()->information(), Money::MXN(500), new DateTime());
     $this->assertEquals('*****@*****.**', $transport->getLastMessage()->getTo()->current()->getEmail(), 'Address doesn\'t belong to the member receiving the deposit');
     $this->assertRegExp('/received.*deposit/', $transport->getLastMessage()->getSubject(), 'Email\'s subject is wrong');
 }
예제 #4
0
 function it_should_transfer_funds_between_accounts(Members $members, TransferFundsNotifier $notifier)
 {
     $fromMember = A::member()->withBalance(2000)->build();
     $toMember = A::member()->withBalance(1000)->build();
     $members->with($fromMember->information()->id())->willReturn($fromMember);
     $members->with($toMember->information()->id())->willReturn($toMember);
     $members->update($fromMember)->shouldBeCalled();
     $members->update($toMember)->shouldBeCalled();
     $this->beConstructedWith($members);
     $this->attach($notifier);
     $this->transfer(TransferFundsRequest::from(['fromMemberId' => (string) $fromMember->information()->id(), 'toMemberId' => (string) $toMember->information()->id(), 'amount' => 5]));
     $notifier->transferCompleted(Argument::type(TransferFundsResponse::class))->shouldHaveBeenCalled();
 }
 /** @test */
 function it_should_build_a_response_to_show_that_a_transfer_was_successful()
 {
     $configuration = Mockery::mock(MembersConfiguration::class);
     $form = Mockery::mock(TransferFundsForm::class);
     $form->shouldReceive('configure')->once()->with($configuration, Mockery::type(Identifier::class));
     $form->shouldReceive('buildView')->once();
     $view = Mockery::mock(TemplateEngine::class);
     $view->shouldReceive('render')->once()->with(Mockery::type('string'), Mockery::type('array'))->andReturn('');
     $result = new TransferFundsResponse(A::member()->build(), A::member()->build());
     $responder = new TransferFundsFormResponder($view, new DiactorosResponseFactory(), $form, $configuration);
     $responder->respondTransferCompleted($result);
     $this->assertEquals(200, $responder->response()->getStatusCode());
 }
 /** @test */
 function it_should_transfer_funds_from_one_member_to_another()
 {
     $responder = Mockery::mock(TransferFundsWebResponder::class);
     $responder->shouldReceive('respondTransferCompleted')->once()->with(Mockery::type(TransferFundsResponse::class));
     $responder->shouldReceive('response')->once()->andReturn(new Response());
     $members = new InMemoryMembers();
     $members->add(A::member()->withId('abc')->withBalance(20000)->build());
     $members->add(A::member()->withId('xyz')->build());
     $useCase = new TransferFunds($members);
     $request = Mockery::mock(FilteredRequest::class);
     $request->shouldReceive('isValid')->once()->andReturn(true);
     $request->shouldReceive('values')->once()->andReturn(['fromMemberId' => 'abc', 'toMemberId' => 'xyz', 'amount' => 100]);
     $controller = new TransferFundsAction($responder, $useCase);
     $response = $controller->transfer($request);
     $this->assertEquals(200, $response->getStatusCode());
 }
예제 #7
0
 /**
  * @Given my friend has an account balance of :amount MXN
  */
 public function myFriendHasAnAccountBalanceOfMxn($amount)
 {
     $myFriend = A::member()->withId('xyz')->withBalance($amount)->build();
     $this->members->add($myFriend);
 }
 /** @test */
 function it_should_format_a_member_information()
 {
     $aMember = A::member()->withName('Mario Montealegre')->withBalance(1500025)->build();
     $this->assertEquals('Mario Montealegre $15,000.25 MXN', $this->formatter->formatMember($aMember->information()));
 }
예제 #9
0
 function it_should_know_when_another_member_is_not_equal_to_it()
 {
     $aDifferentMember = A::member()->withId('xyz')->build();
     $this->equals($aDifferentMember)->shouldBe(false);
 }
 function it_should_delegate_formatting_a_member()
 {
     $member = A::member()->build()->information();
     $this->extension->formatMember($member);
     $this->formatter->shouldHaveReceived('formatMember')->once()->with($member);
 }