function its_method_set_port_should_throw_an_exception_on_invalid_port_value()
 {
     $this->shouldThrow('\\Superdesk\\ContentApiSdk\\Exception\\InvalidArgumentException')->duringSetPort(Argument::is(null));
     $this->shouldThrow('\\Superdesk\\ContentApiSdk\\Exception\\InvalidArgumentException')->duringSetPort(Argument::type('string'));
     $this->shouldThrow('\\Superdesk\\ContentApiSdk\\Exception\\InvalidArgumentException')->duringSetPort(Argument::type('array'));
     $this->shouldThrow('\\Superdesk\\ContentApiSdk\\Exception\\InvalidArgumentException')->duringSetPort(Argument::type('object'));
 }
    /**
     * @test
     */
    public function sets_RID_and_registers_inserted_document_with_UnitOfWork()
    {
        $c = new Contact();
        $oid = spl_object_hash($c);
        $uow = $this->prophesize(UnitOfWork::class);
        $uow->getDocumentInsertions()->willReturn([$oid => $c]);
        $uow->getDocumentChangeSet(Arg::is($c))->willReturn(['name' => ['old', 'new']]);
        $uow->getDocumentUpdates()->willReturn([]);
        $uow->getCollectionUpdates()->willReturn([]);
        $uow->getCollectionDeletions()->willReturn([]);
        $uow->getDocumentDeletions()->willReturn([]);
        $uow->getDocumentActualData(Arg::is($c))->willReturn([]);
        $uow->registerManaged($c, '#1:0', [])->shouldBeCalled();
        $uow->raisePostPersist(Arg::any(), $c)->shouldBeCalled();
        $res = json_decode(<<<JSON
{
    "result":[{
        "n0":"#1:0"
    }]
}
JSON
, true);
        $b = $this->prophesize(BindingInterface::class);
        $b->sqlBatch(Arg::any())->willReturn($res);
        $p = new SQLBatchPersister($this->metadataFactory, $b->reveal());
        $p->process($uow->reveal());
    }
示例#3
0
 protected function setupMockResponse(RequestInterface $request, $response)
 {
     // If a string is passed in, assume its a path to a HTTP representation
     if (is_string($response)) {
         $response = $this->getFixture($response);
     }
     $this->client->send(Argument::is($request))->shouldBeCalled()->willReturn($response);
 }
示例#4
0
 /**
  * @return \oat\oatbox\task\Task
  */
 private function getTask()
 {
     $invocableReport = new \common_report_Report(\common_report_Report::TYPE_INFO, 'Invocable Called');
     $taskInvocableProphecy = $this->prophet->prophesize('oat\\oatbox\\action\\Action');
     $taskInvocableProphecy->__invoke(Argument::is(['foo', 'bar']))->shouldBeCalledTimes(1)->willReturn($invocableReport);
     $taskProphecy = $this->prophet->prophesize('oat\\oatbox\\task\\Task');
     $taskProphecy->getId()->shouldBeCalled()->willReturn('testTask');
     $taskProphecy->getInvocable()->shouldBeCalled()->willReturn($taskInvocableProphecy->reveal());
     $taskProphecy->getParameters()->shouldBeCalled()->willReturn(['foo', 'bar']);
     return $taskProphecy->reveal();
 }
 public function it_be_add_tow_user_to_onw_day(EntityManagerInterface $entityManager, DayRepository $dayRepository, UserRepository $userRepository, DayAndUserRelationship $dayAndUserRelationship, Day $day, User $user)
 {
     $entityManager->getRepository(Argument::is("TrolleyAgendaBundle:Day"))->willReturn($dayRepository)->shouldBeCalled();
     $entityManager->getRepository(Argument::is("TrolleyAgendaBundle:User"))->willReturn($userRepository)->shouldBeCalled();
     $dayRepository->find('31')->willReturn($day)->shouldBeCalled();
     $userRepository->find('20')->willReturn($user)->shouldBeCalled();
     $userRepository->find('errorID')->shouldNotBeCalled();
     $dayAndUserRelationship->addUserToDay(Argument::is($user->getWrappedObject()), Argument::is($day->getWrappedObject()))->shouldBeCalled();
     $formular = ['dayid_31' => [20, 'errorID']];
     $this->processForm($formular);
 }
示例#6
0
 public function setUpEvents()
 {
     $events = $this->prophesize('Zend\\EventManager\\EventManagerInterface');
     $events->attach(Argument::type('ZF\\MvcAuth\\MvcRouteListener'));
     $events->attach(MvcAuthEvent::EVENT_AUTHENTICATION, Argument::type('ZF\\MvcAuth\\Authentication\\DefaultAuthenticationListener'));
     $events->attach(MvcAuthEvent::EVENT_AUTHENTICATION_POST, Argument::type('ZF\\MvcAuth\\Authentication\\DefaultAuthenticationPostListener'));
     $events->attach(MvcAuthEvent::EVENT_AUTHORIZATION, Argument::type('ZF\\MvcAuth\\Authorization\\DefaultResourceResolverListener'), 1000);
     $events->attach(MvcAuthEvent::EVENT_AUTHORIZATION, Argument::type('ZF\\MvcAuth\\Authorization\\DefaultAuthorizationListener'));
     $events->attach(MvcAuthEvent::EVENT_AUTHORIZATION_POST, Argument::type('ZF\\MvcAuth\\Authorization\\DefaultAuthorizationPostListener'));
     $events->attach(MvcAuthEvent::EVENT_AUTHENTICATION_POST, Argument::is([$this->module, 'onAuthenticationPost']), -1);
     return $events;
 }
    /**
     * @before
     */
    public function before()
    {
        /** @var BindingInterface|ObjectProphecy $binding */
        $binding = $this->prophesize(BindingInterface::class);
        $binding->getDatabaseName()->willReturn("ODM");
        $data = <<<JSON
{
    "classes": [
        {"name":"LinkedContact", "clusters":[1]},
        {"name":"LinkedEmailAddress", "clusters":[2]},
        {"name":"LinkedPhone", "clusters":[3]}
    ]
}
JSON;
        $binding->getDatabaseInfo()->willReturn(json_decode($data, true));
        $rawResult = '{
            "@type": "d", "@rid": "#2:1", "@version": 1, "@class": "LinkedEmailAddress",
            "type": "work",
            "email": "*****@*****.**",
            "contact": "#1:1"
        }';
        $binding->getDocument(Arg::is("#2:1"), Arg::any())->willReturn(json_decode($rawResult, true));
        $rawResult = '[{
            "@type": "d", "@rid": "#3:1", "@version": 1, "@class": "LinkedPhone",
            "type": "work",
            "phoneNumber": "4805551920",
            "primary": true
        },{
            "@type": "d", "@rid": "#3:2", "@version": 1, "@class": "LinkedPhone",
            "type": "home",
            "phoneNumber": "5552094878",
            "primary": false
        }]';
        $binding->query(Arg::any())->willReturn(json_decode($rawResult, true));
        $this->manager = $this->createDocumentManagerWithBinding($binding->reveal(), [], ['test/Doctrine/ODM/OrientDB/Tests/Document/Stub']);
        $this->uow = $this->manager->getUnitOfWork();
        $this->metadataFactory = $this->manager->getMetadataFactory();
    }
 /**
  * @cover ::handleHiPayNotification
  * @throws \HiPay\Wallet\Mirakl\Exception\ChecksumFailedException
  * @throws \HiPay\Wallet\Mirakl\Exception\IllegalNotificationOperationException
  */
 public function testWithdrawCancelNotification()
 {
     $xml = $this->readFile("withdrawCanceled.xml");
     $operation = new Operation(2000, new DateTime(), "000001", rand());
     $operation->setStatus(new Status(Status::WITHDRAW_REQUESTED));
     $this->operationManager->findByWithdrawalId(Argument::type("string"))->willReturn($operation)->shouldBeCalled();
     $this->operationManager->save(Argument::is($operation))->shouldBeCalled();
     $this->setEventAssertion(array("withdraw", "canceled"), "Withdraw");
     $this->notificationHandler->handleHiPayNotification($xml);
     $this->assertEquals(Status::WITHDRAW_CANCELED, $operation->getStatus());
 }
 /**
  * @cover ::handleBankInfo
  */
 public function testBankInfoValidate()
 {
     $vendors = Mirakl::getVendor();
     $miraklData = reset($vendors);
     $vendor = $this->getVendorInstance($miraklData);
     $miraklData = array($vendor->getMiraklId() => $miraklData);
     $this->hipay->bankInfosStatus($this->vendorArgument)->willReturn(BankInfoStatus::VALIDATED)->shouldBeCalled();
     $this->hipay->bankInfosCheck(Argument::is($vendor))->will(function () use($miraklData, $vendor) {
         $bankInfo = new BankInfo();
         return $bankInfo->setMiraklData($miraklData[$vendor->getMiraklId()]);
     })->shouldBeCalled();
     $this->vendorProcessor->handleBankInfo(array($vendor), $miraklData);
 }
 /**
  * @cover ::withdraw
  * @group withdraw
  */
 public function testWithdrawUnvalidatedBankInfo()
 {
     $amount = floatval(rand());
     $vendor = new Vendor("*****@*****.**", rand(), rand());
     $operation = new Operation($amount, new DateTime(), "000001", $vendor->getHipayId());
     $operation->setStatus(new Status(Status::TRANSFER_SUCCESS));
     /** @var VendorInterface $vendorArgument */
     $vendorArgument = Argument::is($vendor);
     $this->vendorManager->findByMiraklId(Argument::is($operation->getMiraklId()))->willReturn($vendor);
     $this->hipay->isAvailable(Argument::containingString("@"), Argument::any())->willReturn(false);
     $this->hipay->isIdentified(Argument::containingString("@"))->willReturn(true);
     $this->hipay->bankInfosStatus($vendorArgument)->willReturn(BankInfo::BLANK)->shouldBeCalled();
     $this->hipay->getBalance($vendorArgument)->willReturn($amount + 1);
     $this->hipay->withdraw(Argument::cetera())->shouldNotBeCalled();
     $this->setExpectedException("\\HiPay\\Wallet\\Mirakl\\Exception\\UnconfirmedBankAccountException");
     $this->cashoutProcessor->withdraw($operation);
 }
示例#11
0
 public function test_true_is_returned_when_token_validation_returns_error()
 {
     $request = $this->setupMockRequest('HEAD', 'auth/tokens', [], ['X-Subject-Token' => 'tokenId']);
     $this->client->send(Argument::is($request))->shouldBeCalled()->willThrow(new BadResponseError());
     $this->assertFalse($this->service->validateToken('tokenId'));
 }
 function it_is_initializable()
 {
     $this->beConstructedWith(Argument::is('url'), Argument::is(8087), Argument::is('user'), Argument::is('password'));
     $this->shouldHaveType(WowzaConnectionCount::class);
 }
示例#13
0
 public function test_it_checks_nonexistent_group_role()
 {
     $request = $this->setupMockRequest('HEAD', 'domains/DOMAIN_ID/groups/GROUP_ID/roles/ROLE_ID');
     $this->client->send(Argument::is($request))->shouldBeCalled()->willThrow(new BadResponseError());
     $this->assertFalse($this->domain->checkGroupRole(['groupId' => 'GROUP_ID', 'roleId' => 'ROLE_ID']));
 }
 /**
  * @param $file
  * @param bool|true $withOperatorOperation
  */
 public function setOrderTestProphecy($file, $withOperatorOperation = true)
 {
     $this->mirakl->getTransactions(Argument::type('integer'), Argument::is(null), Argument::is(null), Argument::is(null), Argument::is(null), Argument::is(null), Argument::type("string"), Argument::cetera())->will(function ($args) use($file) {
         $shopId = $args[0];
         $paymentVoucher = $args[6];
         $array = Mirakl::getOrderTransactions($shopId, $paymentVoucher, $file);
         return $array;
     })->shouldBeCalled();
     $this->transactionValidator->isValid(Argument::type('array'))->willReturn(true)->shouldBeCalled();
     $this->operationManager->create(Argument::type('float'), Argument::type('DateTime'), Argument::type('string'), Argument::type('int'))->will(function ($args) {
         list($amount, $cycleDate, $paymentVoucher, $miraklId) = $args;
         return new Operation($amount, $cycleDate, $paymentVoucher, $miraklId);
     })->shouldBeCalled();
     if ($withOperatorOperation) {
         $this->operationManager->create(Argument::type('float'), Argument::type('DateTime'), Argument::type('string'), Argument::is(null))->will(function ($args) {
             list($amount, $cycleDate, $paymentVoucher, $miraklId) = $args;
             return new Operation($amount, $cycleDate, $paymentVoucher, $miraklId);
         })->shouldBeCalled();
     }
 }
示例#15
0
 public function test_it_checks_nonexistent_memberships()
 {
     $request = $this->setupMockRequest('HEAD', 'groups/GROUP_ID/users/USER_ID');
     $this->client->send(Argument::is($request))->shouldBeCalled()->willThrow(new BadResponseError());
     $this->assertFalse($this->group->checkMembership(['userId' => 'USER_ID']));
 }
示例#16
0
 /**
  * @param MockListener $listener1
  * @param MockListener $listener2
  * @param Event        $event
  *
  * @throws \DomainException
  * @throws \InvalidArgumentException
  */
 public function it_should_only_call_listeners_for_current_events_when_event_triggers(MockListener $listener1, MockListener $listener2, Event $event)
 {
     $this->addListener('test1', [$listener1, 'method1']);
     $this->addListener('test2', [$listener2, 'method2']);
     $this->getListeners()->shouldHaveKey('test1');
     $this->getListeners()->shouldHaveKey('test2');
     $event->hasBeenHandled()->willReturn(true);
     /** @noinspection PhpStrictTypeCheckingInspection */
     $listener2->method2(Argument::type('\\EventMediator\\EventInterface'), Argument::is('test2'), $this)->shouldBeCalled();
     /** @noinspection PhpStrictTypeCheckingInspection */
     $listener1->method1(Argument::type('\\EventMediator\\EventInterface'), Argument::any(), Argument::type('\\EventMediator\\MediatorInterface'))->shouldNotBeCalled();
     $this->trigger('test2', $event);
 }
示例#17
0
 public function test_false_is_returned_for_non_existing_object()
 {
     $req = $this->setupMockRequest('HEAD', 'test/bar');
     $res = new Response(404);
     $e = new BadResponseError();
     $e->setRequest($req);
     $e->setResponse($res);
     $this->client->send(Argument::is($req))->willThrow($e);
     $this->assertFalse($this->container->objectExists('bar'));
 }
示例#18
0
 /**
  * @test
  */
 public function it_uses_is_done_condition_to_check_if_chapter_is_done_based_on_received_message()
 {
     $fileWasUploaded = new FileWasUploaded();
     $startCondition = $this->prophesize(MessageCondition::class);
     $isDoneCondition = $this->prophesize(MessageCondition::class);
     $isDoneCondition->isTrueFor(Argument::is($fileWasUploaded))->willReturn(true);
     $commandTemplate = new MessageTemplate(ProcessFile::class, new FQCNMessageFactory());
     $chapterTemplate = new ChapterTemplate(ChapterName::fromString('File Processor'), $commandTemplate, $startCondition->reveal(), $isDoneCondition->reveal());
     $this->assertTrue($chapterTemplate->isDoneBy($fileWasUploaded));
 }