/** @test */
 public function it_should_not_call_remove_from_indices_if_afterUpdate_is_set_to_false()
 {
     $dummyModel = new DummyActiveRecordModel();
     $dummyModel->attachBehavior('test', ['class' => SynchronousAutoIndexBehavior::class, 'afterUpdate' => false]);
     $this->dummyAlgoliaManager->shouldNotReceive('updateInIndices');
     $dummyModel->trigger(ActiveRecord::EVENT_AFTER_UPDATE);
 }
 /** @test */
 public function it_responds_internal_error_when_something_bad_happens()
 {
     $this->speakers->shouldReceive('findProfile')->andThrow(new Exception('Zomgz it blew up somehow.'));
     $response = $this->sut->handleShowSpeakerProfile($this->getRequest());
     $this->assertEquals(500, $response->getStatusCode());
     $this->assertContains('Zomgz it blew up somehow', $response->getContent());
 }
 public function test_calc()
 {
     /** === Test Data === */
     $CUST_1 = 1;
     $PARENT_1 = 101;
     $ORDR_1 = 10;
     $PV_1 = 100;
     $RANK_1 = 2;
     $PERCENT_1 = 0.01;
     $BONUS_1 = 'bonus';
     $TREE = 'tree';
     $TREE_EXP = [$CUST_1 => [Snap::ATTR_PATH => 'path1']];
     $MAP_RANKS = [$PARENT_1 => $RANK_1];
     $ORDERS = [[Cfg::E_SALE_ORDER_A_CUSTOMER_ID => $CUST_1, PvSale::ATTR_SALE_ID => $ORDR_1, PvSale::ATTR_TOTAL => $PV_1]];
     $PARAMS = [];
     $PERCENTS = [$RANK_1 => [1 => $PERCENT_1]];
     $PARENTS = [$PARENT_1];
     /** === Setup Mocks === */
     // $mapTreeExp = $this->_expandTree($tree);
     // $resp = $this->_callDownlineSnap->expandMinimal($req);
     $this->mCallDownlineSnap->shouldReceive('expandMinimal')->once()->andReturn(new DataObject(['SnapData' => $TREE_EXP]));
     // $mapRankById = $this->_rankQualifier->qualifyCustomers($tree, $params);
     $this->mRankQualifier->shouldReceive('qualifyCustomers')->once()->andReturn($MAP_RANKS);
     // $parents = $this->_toolDownlineTree->getParentsFromPathReversed($path);
     $this->mToolDownlineTree->shouldReceive('getParentsFromPathReversed')->once()->andReturn($PARENTS);
     // $bonus = $this->_toolFormat->roundBonus($bonus);
     $this->mToolFormat->shouldReceive('roundBonus')->once()->with($PV_1 * $PERCENT_1)->andReturn($BONUS_1);
     /** === Call and asserts  === */
     $resp = $this->sub->calc($TREE, $ORDERS, $PARAMS, $PERCENTS);
     $this->assertEquals($BONUS_1, $resp[$PARENT_1][$ORDR_1]);
 }
Пример #4
0
 /**
  * @covers \Ilios\CliBundle\Command\ListRootUsersCommand::execute
  */
 public function testListUsersNoResults()
 {
     $this->userManager->shouldReceive('findDTOsBy')->with(['root' => true])->andReturn([]);
     $this->commandTester->execute(['command' => ListRootUsersCommand::COMMAND_NAME]);
     $output = $this->commandTester->getDisplay();
     $this->assertEquals('No users with root-level privileges found.', trim($output));
 }
 public function testDestroy()
 {
     $redirect = $this->app['config']->get('laravel-sentry-backend::logout_redirect');
     $this->auth->shouldReceive('logout')->once()->withNoArgs();
     $this->route('delete', 'session.destroy');
     $this->assertRedirectedToRoute($redirect);
 }
Пример #6
0
 /**
  * @expectedException \Exception
  */
 public function test_request_false()
 {
     /** === Test Data === */
     $PARAMS = 'params';
     $PARAMS_JSON = 'JSON encoded params';
     $ROUTE = 'route';
     $SESS_ID = 'session id';
     $CONTEXT_OPTS_JSON = 'JSON encoded context options';
     $RESULT = 'result';
     /** === Setup Mocks === */
     // $sessId = $this->_login->getSessionId();
     $this->mLogin->shouldReceive('getSessionId')->once()->andReturn($SESS_ID);
     // $request = $this->_adapter->encodeJson($params);
     $this->mAdapter->shouldReceive('encodeJson')->once()->with($PARAMS)->andReturn($PARAMS_JSON);
     // $context = $this->_adapter->createContext($contextOpts);
     $this->mAdapter->shouldReceive('createContext')->once()->andReturn($PARAMS_JSON);
     // this->_logger->debug("Request URI:\t$uri");
     $this->mLogger->shouldReceive('debug');
     // $jsonContextOpt = $this->_adapter->encodeJson($contextOpts);
     $this->mAdapter->shouldReceive('encodeJson')->once()->andReturn($CONTEXT_OPTS_JSON);
     // $contents = $this->_adapter->getContents($uri, $context);
     $this->mAdapter->shouldReceive('getContents')->once()->andReturn(false);
     // $this->_logger->critical($msg);
     $this->mLogger->shouldReceive('critical')->once();
     /** === Call and asserts  === */
     $res = $this->obj->request($PARAMS, $ROUTE);
     $this->assertEquals($RESULT, $res);
 }
Пример #7
0
    /**
     * @covers phpDocumentor\Plugin\Core\Transformer\Writer\CheckStyle::transform
     */
    public function testTransform()
    {
        $transformer = m::mock('phpDocumentor\\Transformer\\Transformation');
        $transformer->shouldReceive('getTransformer->getTarget')->andReturn(vfsStream::url('CheckStyleTest'));
        $transformer->shouldReceive('getArtifact')->andReturn('artifact.xml');
        $fileDescriptor = m::mock('phpDocumentor\\Descriptor\\FileDescriptor');
        $projectDescriptor = m::mock('phpDocumentor\\Descriptor\\ProjectDescriptor');
        $projectDescriptor->shouldReceive('getFiles->getAll')->andReturn(array($fileDescriptor));
        $error = m::mock('phpDocumentor\\Descriptor\\Validator\\Error');
        $fileDescriptor->shouldReceive('getPath')->andReturn('/foo/bar/baz');
        $fileDescriptor->shouldReceive('getAllErrors->getAll')->andReturn(array($error));
        $error->shouldReceive('getLine')->andReturn(1234);
        $error->shouldReceive('getCode')->andReturn(5678);
        $error->shouldReceive('getSeverity')->andReturn('error');
        $error->shouldReceive('getContext')->andReturn('myContext');
        $this->translator->shouldReceive('translate')->with('5678')->andReturn('5678 %s');
        // Call the actual method
        $this->checkStyle->transform($projectDescriptor, $transformer);
        // Assert file exists
        $this->assertTrue($this->fs->hasChild('artifact.xml'));
        // Inspect XML
        $xml = <<<XML
<?xml version="1.0"?>
<checkstyle version="1.3.0">
  <file name="/foo/bar/baz">
    <error line="1234" severity="error" message="5678 myContext" source="phpDocumentor.file.5678"/>
  </file>
</checkstyle>
XML;
        $expectedXml = new \DOMDocument();
        $expectedXml->loadXML($xml);
        $actualXml = new \DOMDocument();
        $actualXml->load(vfsStream::url('CheckStyleTest/artifact.xml'));
        $this->assertEqualXMLStructure($expectedXml->firstChild, $actualXml->firstChild, true);
    }
Пример #8
0
 public function testParseLine()
 {
     $this->line['34:39'] = 'seeya';
     $this->line['40:42'] = 'ho';
     $this->formatter->shouldReceive('formatFromFile')->once()->with($this->spec->getFieldSpec('field2'), 'ho')->andReturn('ha')->getMock()->shouldReceive('formatFromFile')->once()->with($this->spec->getFieldSpec('field1'), 'seeya')->andReturn('booya')->getMock();
     $this->assertEquals(array('field1' => 'booya', 'field2' => 'ha'), $this->reader->getFields());
 }
 public function testUpdate()
 {
     $this->users->shouldReceive('findById')->once()->andReturn(false);
     $this->route('put', 'password-reset.update');
     $this->assertRedirectedToRoute('password-reset.create');
     $this->users->shouldReceive('findById')->once()->andReturn(false);
     $this->route('put', 'password-reset.update', null, array('code' => '123456789'));
     $this->assertRedirectedToRoute('password-reset.create');
     $this->users->shouldReceive('findById')->once()->andReturn(true);
     $this->route('put', 'password-reset.update', null, array('id' => '1'));
     $this->assertRedirectedToRoute('password-reset.create');
     $user = m::mock();
     $user->id = 1;
     $this->users->shouldReceive('findById')->with(1)->once()->andReturn($user);
     $this->validator->shouldReceive('validate')->once()->andReturn(false);
     $this->validator->shouldReceive('getErrors')->once()->andReturn(array());
     $this->route('put', 'password-reset.update', null, array('id' => '1', 'code' => '123456789'));
     $this->assertRedirectedToRoute('password-reset.edit', array(1, '123456789'));
     $this->assertSessionHasErrors();
     $this->users->shouldReceive('findById')->with(1)->once()->andReturn($user);
     $this->validator->shouldReceive('validate')->once()->andReturn(true);
     $user->shouldReceive('checkResetPasswordCode')->with('123456789')->once()->andReturn(false);
     $this->route('put', 'password-reset.update', null, array('id' => '1', 'code' => '123456789'));
     $this->assertRedirectedToRoute('password-reset.create');
     $this->users->shouldReceive('findById')->with(1)->once()->andReturn($user);
     $this->validator->shouldReceive('validate')->once()->andReturn(true);
     $user->shouldReceive('checkResetPasswordCode')->with('123456789')->once()->andReturn(true);
     $user->shouldReceive('attemptResetPassword')->with('123456789', 'newPassword')->once()->andReturn(true);
     $this->route('put', 'password-reset.update', null, array('id' => '1', 'code' => '123456789', 'password' => 'newPassword'));
     $this->assertRedirectedToRoute('session.create');
     $this->assertSessionHas('success_password_reset', true);
 }
Пример #10
0
 /** @test */
 public function it_should_respond_unauthorized_when_no_authentication_provided()
 {
     $this->speakers->shouldReceive('getTalks')->andThrow(\OpenCFP\Domain\Services\NotAuthenticatedException::class);
     $response = $this->sut->handleViewAllTalks($this->getValidRequest());
     $this->assertEquals(401, $response->getStatusCode());
     $this->assertContains('Unauthorized', $response->getContent());
 }
 public function testExecuteWithoutViolations()
 {
     $list = new ConstraintViolationList([]);
     $this->validator->shouldReceive('validate')->once()->andReturn($list);
     $this->middleware->execute(new FakeCommand(), function () {
     });
 }
Пример #12
0
 public function testHighlightLastQueryIsEmpty()
 {
     $this->queryRunner->shouldReceive('getLastQuery')->andReturn(false);
     $this->analyzerConfig->shouldReceive('setHighlighterAnalyzer')->never();
     $this->analyzerConfig->shouldReceive('setDefaultAnalyzer')->never();
     $this->assertEquals('test', $this->html->highlight('test'));
 }
Пример #13
0
 public function test_getItemsByOrderId()
 {
     /** === Test Data === */
     $ORDER_ID = 32;
     $ITEM_ID = 64;
     $TBL_ORDER = 'sale order item';
     $TBL_PV_ITEM = 'pv item';
     /** === Setup Mocks === */
     // $tblOrder = [$asOrder => $this->_resource->getTableName(Cfg::ENTITY_MAGE_SALES_ORDER_ITEM)];
     $this->mResource->shouldReceive('getTableName')->once()->andReturn($TBL_ORDER);
     // $tblPvItem = [$asPvItem => $this->_resource->getTableName(Entity::ENTITY_NAME)];
     $this->mResource->shouldReceive('getTableName')->once()->andReturn($TBL_PV_ITEM);
     // $query = $conn->select();
     $mQuery = $this->_mockDbSelect();
     $this->mConn->shouldReceive('select')->once()->andReturn($mQuery);
     // $query->from($tblOrder, $cols);
     $mQuery->shouldReceive('from')->once();
     // $query->joinLeft($tblPvItem, $on, $cols);
     $mQuery->shouldReceive('joinLeft')->once();
     // $query->where($where);
     $mQuery->shouldReceive('where')->once();
     // $rows = $conn->fetchAll($query);
     $mRow = [];
     $mRows = [$mRow];
     $this->mConn->shouldReceive('fetchAll')->once()->andReturn($mRows);
     // $item = $this->_manObj->create(Entity::class, $row);
     $mItem = $this->_mock(\Praxigento\Pv\Data\Entity\Sale\Item::class);
     $this->mManObj->shouldReceive('create')->once()->with(\Praxigento\Pv\Data\Entity\Sale\Item::class, $mRow)->andReturn($mItem);
     // $result[$item->getSaleItemId()] = $item;
     $mItem->shouldReceive('getSaleItemId')->once()->andReturn($ITEM_ID);
     /** === Call and asserts  === */
     $res = $this->obj->getItemsByOrderId($ORDER_ID);
     $this->assertTrue(is_array($res));
     $this->assertTrue(isset($res[$ITEM_ID]));
 }
Пример #14
0
 public function testComposeShouldComposeAllComponents()
 {
     $this->mockSeeder->shouldReceive("setAllServiceProvidersFrom")->once();
     $this->mockSeeder->shouldReceive("seedAll")->once();
     $this->mockComposer->shouldReceive("setEnvironment")->with("")->once();
     $this->installer->seed();
 }
 /**
  * @test
  */
 public function shouldCreateTheUser()
 {
     $this->userSessionFactory->shouldReceive('create');
     $user = $this->createUser();
     $userToken = $this->createUserToken();
     $this->repository->create($user, $userToken);
 }
Пример #16
0
 public function testSetHighlighterAnalyzer()
 {
     $this->app->instance('filterClass1', $tokenFilterMock = m::mock('ZendSearch\\Lucene\\Analysis\\TokenFilter\\TokenFilterInterface'));
     $this->analyzer->shouldReceive('addFilter')->with($tokenFilterMock)->once();
     $this->config->setHighlighterAnalyzer();
     $this->assertEquals($this->analyzer, Analyzer::getDefault());
 }
Пример #17
0
 /**
  * @group        certificate
  * @test
  *
  * @dataProvider invalidConfigurationProvider
  * @expectedException \SAML2\Exception\InvalidArgumentException
  */
 public function it_correctly_parses_arrays_and_traversables($configurationValue)
 {
     $this->configurationMock->shouldReceive('getCertificateFingerprints')->once()->andReturn($configurationValue);
     $result = $this->fingerprintLoader->loadFingerprints($this->configurationMock);
     $this->assertInstanceOf('\\SAML2\\Certificate\\FingerprintCollection', $result);
     $this->assertCount(count($configurationValue), $result);
 }
 public function testCreateService()
 {
     $config = array('PhpClientPoeditor' => array('options' => array()));
     $this->serviceLocator->shouldReceive('get')->with('Config')->andReturn($config)->once();
     $instance = $this->fixture->createService($this->serviceLocator);
     $this->assertInstanceOf('PhpClientPoeditor\\Options\\Options', $instance);
 }
Пример #19
0
 protected function createDirGenTest($baseDir, $dir)
 {
     $this->fs->shouldReceive('exists')->once()->with(m::mustBe(Path::join($baseDir, $dir)))->andReturn(false);
     $this->fs->shouldReceive('makeDirectory')->once()->with(m::mustBe(Path::join($baseDir, $dir)), m::mustBe(0755), m::mustBe(true))->andReturn(true);
     $generator = $this->generator->generateDirectoryStructure($baseDir, [$dir]);
     $this->assertInstanceOf(StubGenerator::class, $generator);
 }
Пример #20
0
 /**
  * @covers \Ilios\CliBundle\Command\AddRootUserCommand::execute
  */
 public function testUserNotFound()
 {
     $userId = 0;
     $this->userManager->shouldReceive('findOneBy')->with(['id' => $userId])->andReturn(null);
     $this->setExpectedException('Exception', "No user with id #{$userId} was found.");
     $this->commandTester->execute(['command' => AddRootUserCommand::COMMAND_NAME, 'userId' => $userId]);
 }
 /**
  * @expectedException \Akamon\OAuth2\Server\Domain\Exception\OAuthError\UnsupportedGrantTypeOAuthErrorException
  */
 public function testGrantShouldThrowAnUnsupportedGrantTypeException()
 {
     $request = $this->createRequestForGrantType('no');
     $client = $this->createClient(['allowedGrantTypes' => ['no']]);
     $this->clientObtainer->shouldReceive('getClient')->with($request)->once()->andReturn($client);
     $this->granter->grant($request);
 }
Пример #22
0
 public function testRotate()
 {
     $newProfile = $this->getFaker()->word;
     $encryptor = \Mockery::mock('Giftcards\\Encryption\\Encryptor');
     $observer = \Mockery::mock('Giftcards\\Encryption\\CipherText\\Rotator\\ObserverInterface');
     $fields = $this->fields;
     $fields[] = $this->idField;
     $faker = $this->getFaker();
     $row1 = array_combine($fields, array_map(function () use($faker) {
         return $faker->unique()->word;
     }, $fields));
     $row2 = array_combine($fields, array_map(function () use($faker) {
         return $faker->unique()->word;
     }, $fields));
     $row3 = array_combine($fields, array_map(function () use($faker) {
         return $faker->unique()->word;
     }, $fields));
     $this->connection->shouldReceive('createQueryBuilder')->once()->andReturn(\Mockery::mock()->shouldReceive('select')->once()->with($fields)->andReturn(\Mockery::self())->getMock()->shouldReceive('from')->once()->with($this->table)->andReturn(\Mockery::self())->getMock()->shouldReceive('execute')->once()->andReturn(\Mockery::mock()->shouldReceive('fetch')->times(4)->with(\PDO::FETCH_ASSOC)->andReturn($row1, $row2, $row3, false)->getMock())->getMock());
     $observer->shouldReceive('rotating')->once()->ordered()->with($row1[$this->idField])->getMock()->shouldReceive('rotated')->once()->ordered()->with($row1[$this->idField])->getMock()->shouldReceive('rotating')->once()->ordered()->with($row2[$this->idField])->getMock()->shouldReceive('rotated')->once()->ordered()->with($row2[$this->idField])->getMock()->shouldReceive('rotating')->once()->ordered()->with($row3[$this->idField])->getMock()->shouldReceive('rotated')->once()->ordered()->with($row3[$this->idField])->getMock();
     foreach (array($row1, $row2, $row3) as $row) {
         $encryptedRow = array();
         foreach ($row as $field => $value) {
             if ($field == $this->idField) {
                 continue;
             }
             $encryptor->shouldReceive('decrypt')->once()->with($value)->andReturn($decrypted = $this->getFaker()->unique()->word)->getMock()->shouldReceive('encrypt')->once()->with($decrypted, $newProfile)->andReturn($encrypted = $this->getFaker()->unique()->word)->getMock();
             $encryptedRow[$field] = $encrypted;
         }
         $this->connection->shouldReceive('update')->once()->with($this->table, $encryptedRow, array($this->idField => $row[$this->idField]));
     }
     $this->rotator->rotate($observer, $encryptor, $newProfile);
 }
Пример #23
0
 /**
  * @SuppressWarnings(PHPMD.ShortVariable)
  */
 public function test_savePv()
 {
     /** === Test Data === */
     $id = 4;
     $state = \Magento\Sales\Model\Order::STATE_PROCESSING;
     $dateCreated = 'created at';
     $order = $this->_mock(\Magento\Sales\Api\Data\OrderInterface::class);
     /** === Setup Mocks === */
     // $orderId = $order->getId();
     $order->shouldReceive('getId')->once()->andReturn($id);
     // $state = $order->getState();
     $order->shouldReceive('getState')->once()->andReturn($state);
     // $dateCreated = $order->getCreatedAt();
     $order->shouldReceive('getCreatedAt')->once()->andReturn($dateCreated);
     // $itemsData = $this->_subCollector->getServiceItemsForMageSaleOrder($order);
     $mItemsData = [];
     $this->mSubCollector->shouldReceive('getServiceItemsForMageSaleOrder')->once()->andReturn($mItemsData);
     // $req = $this->_manObj->create(\Praxigento\Pv\Service\Sale\Request\Save::class);
     $mReq = $this->_mock(\Praxigento\Pv\Service\Sale\Request\Save::class);
     $this->mManObj->shouldReceive('create')->once()->andReturn($mReq);
     // $req->setSaleOrderId($orderId);
     $mReq->shouldReceive('setSaleOrderId')->once()->with($id);
     // $req->setOrderItems($itemsData);
     $mReq->shouldReceive('setOrderItems')->once()->with($mItemsData);
     // $req->setSaleOrderDatePaid($dateCreated);
     $mReq->shouldReceive('setSaleOrderDatePaid')->once()->with($dateCreated);
     // $this->_callSale->save($req);
     $this->mCallSale->shouldReceive('save')->once()->with($mReq);
     /** === Call and asserts  === */
     $this->obj->savePv($order);
 }
Пример #24
0
 /**
  * @test
  * @covers Plum\PlumDoctrine\ORM\QueryReader::count()
  */
 public function countShouldReturnNumberOfResults()
 {
     $result = new stdClass();
     $this->query->shouldReceive('getResult')->andReturn([$result, $result]);
     $reader = new QueryReader($this->query);
     $this->assertEquals(2, $reader->count());
 }
 /**
  * @test
  */
 public function shouldReturnOwnUserFilterWhenNotHavingAdminRights()
 {
     $this->loggedInUser->shouldReceive('isAdminUser')->andReturn(false);
     $this->loggedInUser->shouldReceive('username')->andReturn('test1');
     $filter = $this->filterFactory->createFrom('admin,elton,test1', date('d-m-Y H:i:s'), date('d-m-Y H:i:s'));
     $this->assertSame(['test1'], $filter->users()->asArray());
 }
 public function test_create_new()
 {
     /** === Test Data === */
     $TRANS = 'transaction name';
     $CONN = 'connection name';
     /** === Setup Mocks === */
     // $result = $this->_manObj->create(\Praxigento\Core\Transaction\Database\Def\Item::class);
     $mResult = $this->_mock(\Praxigento\Core\Transaction\Database\Def\Item::class);
     $this->mManObj->shouldReceive('create')->once()->andReturn($mResult);
     // $result->setTransactionName($transactionName);
     $mResult->shouldReceive('setTransactionName')->once()->with($TRANS);
     // $result->setConnectionName($connectionName);
     $mResult->shouldReceive('setConnectionName')->once()->with($CONN);
     // $cfgData = $this->_configDeployment->get($cfgName);
     $mCfgData = [];
     $this->mConfigDeployment->shouldReceive('get')->once()->andReturn($mCfgData);
     // $conn = $this->_factoryConn->create($cfgData);
     $mConn = $this->_mock(\Magento\Framework\DB\Adapter\AdapterInterface::class);
     $this->mFactoryConn->shouldReceive('create')->once()->andReturn($mConn);
     // $result->setConnection($conn);
     $mResult->shouldReceive('setConnection')->once();
     /** === Call and asserts  === */
     $res = $this->obj->create($TRANS, $CONN);
     $this->assertTrue($res instanceof \Praxigento\Core\Transaction\Database\IItem);
 }
Пример #27
0
 public function testRotate()
 {
     $newProfile = $this->getFaker()->word;
     $encryptor = \Mockery::mock('Giftcards\\Encryption\\Encryptor');
     $observer = \Mockery::mock('Giftcards\\Encryption\\CipherText\\Rotator\\ObserverInterface');
     $fields = $this->fields;
     $fields[] = $this->idField;
     $faker = $this->getFaker();
     $row1 = array_combine($fields, array_map(function () use($faker) {
         return $faker->unique()->word;
     }, $fields));
     $row2 = array_combine($fields, array_map(function () use($faker) {
         return $faker->unique()->word;
     }, $fields));
     $row3 = array_combine($fields, array_map(function () use($faker) {
         return $faker->unique()->word;
     }, $fields));
     $this->pdo->shouldReceive('prepare')->once()->with(sprintf('SELECT %s FROM %s', implode(', ', $fields), $this->table))->andReturn(\Mockery::mock()->shouldReceive('execute')->once()->getMock()->shouldReceive('fetch')->times(4)->with(\PDO::FETCH_ASSOC)->andReturn($row1, $row2, $row3, false)->getMock());
     $observer->shouldReceive('rotating')->once()->ordered()->with($row1[$this->idField])->getMock()->shouldReceive('rotated')->once()->ordered()->with($row1[$this->idField])->getMock()->shouldReceive('rotating')->once()->ordered()->with($row2[$this->idField])->getMock()->shouldReceive('rotated')->once()->ordered()->with($row2[$this->idField])->getMock()->shouldReceive('rotating')->once()->ordered()->with($row3[$this->idField])->getMock()->shouldReceive('rotated')->once()->ordered()->with($row3[$this->idField])->getMock();
     foreach (array($row1, $row2, $row3) as $row) {
         $parameters = array();
         $setFields = array();
         foreach ($row as $field => $value) {
             if ($field == $this->idField) {
                 continue;
             }
             $encryptor->shouldReceive('decrypt')->once()->with($value)->andReturn($decrypted = $this->getFaker()->unique()->word)->getMock()->shouldReceive('encrypt')->once()->with($decrypted, $newProfile)->andReturn($parameters[] = $this->getFaker()->unique()->word)->getMock();
             $setFields[] = sprintf('%s = ?', $field);
         }
         $parameters[] = $row[$this->idField];
         $this->pdo->shouldReceive('prepare')->once()->with(sprintf('UPDATE %s SET %s WHERE %s = ?', $this->table, implode(',', $setFields), $this->idField))->andReturn(\Mockery::mock()->shouldReceive('execute')->once()->with($parameters)->getMock());
     }
     $this->rotator->rotate($observer, $encryptor, $newProfile);
 }
Пример #28
0
 public function testGetMessages()
 {
     $conversation = Mockery::mock('FOS\\Message\\Model\\ConversationInterface');
     $message = Mockery::mock('FOS\\Message\\Model\\PersonInterface');
     $this->driver->shouldReceive('findMessages')->once()->with($conversation, 5, 10, 'DESC')->andReturn([$message]);
     $this->assertSame([$message], $this->repository->getMessages($conversation, 5, 10, 'DESC'));
 }
Пример #29
0
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     $this->factory = new ProcessFactory('pwd');
     $this->directory = \Mockery::mock(\SplFileInfo::class);
     $this->directory->shouldReceive('__toString')->andReturn('/tmp');
 }
 /**
  * @test
  * @group signature
  */
 public function it_cannot_validate_when_no_certificates_are_found()
 {
     $this->mockConfiguration->shouldReceive('getCertificateFingerprints')->once()->andReturn(array());
     $this->mockSignedElement->shouldReceive('getCertificates')->once()->andReturn(array());
     $validator = new SAML2_Signature_FingerprintValidator(new SAML2_SimpleTestLogger(), new SAML2_Certificate_FingerprintLoader());
     $this->assertFalse($validator->canValidate($this->mockSignedElement, $this->mockConfiguration));
 }