protected function setUp()
 {
     $this->app = m::mock(Container::class);
     $this->app->shouldReceive('make')->andReturn(m::self());
     $this->cache = m::mock(CacheManager::class);
     $this->manager = new MetaDataManager($this->app);
 }
 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);
 }
Exemple #3
0
 public function testJob_Is_Not_Find()
 {
     $this->fixture->shouldReceive('getJobByVacancyId')->with(2)->andReturn(\Mockery::self())->atLeast(1);
     $this->fixture->shouldReceive('extendJob')->andReturn(true)->atLeast(1);
     $parser = new Parser([], $this->fixture);
     $parser->parseVacancy(2, null);
 }
Exemple #4
0
 /**
  * endTest is called after each test and checks if \Mockery::close() has
  * been called, and will let the test fail if it hasn't.
  *
  * @param  PHPUnit_Framework_Test $test
  * @param  float                  $time
  */
 public function endTest(\PHPUnit_Framework_Test $test, $time)
 {
     if (!$test instanceof \PHPUnit_Framework_TestCase) {
         // We need the getTestResultObject and getStatus methods which are
         // not part of the interface.
         return;
     }
     if ($test->getStatus() !== \PHPUnit_Runner_BaseTestRunner::STATUS_PASSED) {
         // If the test didn't pass there is no guarantee that
         // verifyMockObjects and assertPostConditions have been called.
         // And even if it did, the point here is to prevent false
         // negatives, not to make failing tests fail for more reasons.
         return;
     }
     try {
         // The self() call is used as a sentinel. Anything that throws if
         // the container is closed already will do.
         \Mockery::self();
     } catch (\LogicException $_) {
         return;
     }
     $e = new \PHPUnit_Framework_ExpectationFailedException(sprintf("Mockery's expectations have not been verified. Make sure that \\Mockery::close() is called at the end of the test. Consider using %s\\MockeryPHPUnitIntegration or extending %s\\MockeryTestCase.", __NAMESPACE__, __NAMESPACE__));
     $result = $test->getTestResultObject();
     $result->addFailure($test, $e, $time);
 }
 protected function _before()
 {
     $serviceLocator = \Mockery::mock('Zend\\ServiceManager\\ServiceLocatorInterface');
     $serviceLocator->shouldReceive('get')->with('elasticsearch')->andReturn(\Mockery::self());
     $serviceLocator->shouldReceive('search')->with(array('index' => 'test-index', 'body' => 'test-query'))->andReturn(array('test-response', 'test-data'));
     $this->service = new ElasticSearch($serviceLocator);
 }
Exemple #6
0
 protected function setUp()
 {
     $this->app = m::mock(Container::class);
     $this->app->shouldReceive('make')->andReturn(m::self());
     $this->app->shouldReceive('get')->with('doctrine.cache.default', 'array')->andReturn('array');
     $this->manager = new CacheManager($this->app);
 }
 public function testGetLoggedUserId()
 {
     $authenticator_mock = \Mockery::mock('Jacopo\\Authentication\\SentryAuthenticator');
     $authenticator_mock->shouldReceive('getLoggedUser')->once()->andReturn(\Mockery::self())->shouldReceive('toArray')->once()->andReturn(['id' => 'foobar']);
     $this->app->instance('authenticator', $authenticator_mock);
     assertThat($this->authMgr()->getLoggedUserId(), identicalTo('foobar'));
 }
 public function testConfigureOptionsResolver()
 {
     $this->factory->configureOptionsResolver(\Mockery::mock('Symfony\\Component\\OptionsResolver\\OptionsResolver')->shouldReceive('setRequired')->once()->with(array('container'))->andReturn(\Mockery::self())->getMock()->shouldReceive('setAllowedTypes')->once()->with(array('container' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface'))->andReturn(\Mockery::self())->getMock());
     $container = new Container();
     $factory = new ContainerParametersSourceBuilder($container);
     $factory->configureOptionsResolver(\Mockery::mock('Symfony\\Component\\OptionsResolver\\OptionsResolver')->shouldReceive('setRequired')->once()->with(array('container'))->andReturn(\Mockery::self())->getMock()->shouldReceive('setAllowedTypes')->once()->with(array('container' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface'))->andReturn(\Mockery::self())->getMock()->shouldReceive('setDefaults')->once()->with(array('container' => $container))->andReturn(\Mockery::self())->getMock());
 }
 public function testAuthenticatingWithQueryStringSucceedsAndReturnsUserObject()
 {
     $request = Request::create('foo', 'GET', ['token' => 'foo']);
     $this->auth->shouldReceive('setToken')->with('foo')->andReturn(m::self());
     $this->auth->shouldReceive('authenticate')->once()->andReturn((object) ['id' => 1]);
     $this->assertEquals(1, $this->provider->authenticate($request, m::mock('Dingo\\Api\\Routing\\Route'))->id);
 }
 public function testSetLookUpIdCallsApaiioDependencyCorrectly()
 {
     $apai_op_mock = Mockery::mock('ApaiIO\\Operations\\Lookup');
     $apai_op_mock->shouldReceive('setItemId')->once()->with('stub item id')->andReturn(Mockery::self());
     $this->app->instance('ApaiIO\\Operations\\Lookup', $apai_op_mock);
     $lookup_op = $this->app->make('Giftertipster\\Service\\Api\\AmzProductApi\\ApaiIO\\Operations\\LookupOperation');
     $response = $lookup_op->setItemId('stub item id');
 }
Exemple #11
0
 protected function setUp()
 {
     $this->app = m::mock(Container::class);
     $this->app->shouldReceive('make')->andReturn(m::self());
     $this->config = m::mock(Repository::class);
     $this->config->shouldReceive('get');
     $this->manager = new ConnectionManager($this->app);
 }
 public function testFlush()
 {
     $cache = $this->getCache();
     $cache->shouldReceive('flush');
     $cache->shouldReceive('getStore')->andReturn(m::self());
     $transCache = new TransCache($cache);
     $transCache->flush();
 }
 protected function getPropelQuery($model, $results)
 {
     $mock = Mockery::mock('overload:PropelQuery');
     $mock->shouldReceive('from')->once()->with($model)->andReturn(\Mockery::self());
     $mock->shouldReceive('setFormatter')->once()->with('PropelOnDemandFormatter')->andReturn(\Mockery::self());
     $mock->shouldReceive('find')->once()->andReturn($results);
     return $mock;
 }
Exemple #14
0
 public function testGetSchema()
 {
     $connection = M::mock('Fuel\\Database\\Connection');
     $connection->shouldReceive('getSchemaManager')->andReturn(M::self());
     $connection->shouldReceive('createSchema')->andReturn('called');
     $schema = new Schema($connection);
     $this->assertEquals('called', $schema->getSchema());
 }
 protected function getConn()
 {
     $conn = m::mock(\Xpressengine\Database\VirtualConnectionInterface::class);
     $conn->shouldReceive('where')->andReturn(m::self());
     $conn->shouldReceive('table')->andReturn(m::self());
     $conn->shouldReceive('insert')->andReturn(m::self());
     $conn->shouldReceive('update')->andReturn(m::self());
     return $conn;
 }
 public function testDestroy()
 {
     $datas = ['delete_items' => [1, 2, 3]];
     $this->mock->shouldReceive('whereIn')->once()->with('id', $datas['delete_items'])->andReturn(m::self())->shouldReceive('delete')->once();
     $this->delete(route('admin.tags.destroy'), $datas);
     $this->assertRedirectedToRoute('admin.tags.index');
     $this->assertSessionHas('flash_notification.message');
     $this->assertSessionHas('flash_notification.level', 'success');
 }
 public function testDestroyCatchException()
 {
     $datas = ['delete_items' => [1, 2]];
     $this->mock->shouldReceive('whereIn')->once()->with('id', $datas['delete_items'])->andReturn(m::self())->shouldReceive('get')->once()->andReturn([m::self(), m::self()])->shouldReceive('unlink')->andThrow(new \Exception('file unlink error!!'));
     $this->delete(route('admin.upload_files.destroy'), $datas);
     $this->assertRedirectedToRoute('admin.upload_files.index');
     $this->assertSessionHas('flash_notification.message');
     $this->assertSessionHas('flash_notification.level', 'danger');
 }
 /**
  * @test
  */
 public function it_loads_an_existing_view_error_bag_from_a_request()
 {
     $request = Mockery::mock(Illuminate\Http\Request::class);
     $messageBags = $this->bag->getBags();
     $request->shouldReceive('session')->once()->andReturn(Mockery::self())->shouldReceive('get')->once()->andReturn(Mockery::self())->shouldReceive('getBags')->once()->andReturn($messageBags);
     // MessageBags
     $bag = new ViewErrorBag();
     $bag->make($request);
     $this->assertEquals(3, $bag->count());
 }
 public function testGetByEmail()
 {
     $bxObject = m::mock('object');
     TestUser::$bxObject = $bxObject;
     $bxObject->shouldReceive('getList')->with(['SORT' => 'ASC'], false, ['EMAIL' => '*****@*****.**'], ['SELECT' => false, 'NAV_PARAMS' => ['nPageSize' => 1], 'FIELDS' => ['ID', 'NAME']])->once()->andReturn(m::self());
     $bxObject->shouldReceive('fetch')->times(2)->andReturn(['ID' => 1, 'NAME' => 'foo'], false);
     $query = $this->createQuery($bxObject);
     $item = $query->sort(['SORT' => 'ASC'])->select('ID', 'NAME')->getByEmail('*****@*****.**');
     $this->assertSame(['ID' => 1, 'NAME' => 'foo'], $item->toArray());
 }
 public function testOnBootstrap()
 {
     $mvcEvent = \Mockery::mock('Zend\\Mvc\\MvcEvent');
     $mvcEvent->shouldReceive('getApplication')->andReturn(\Mockery::self());
     $mvcEvent->shouldReceive('getServiceManager')->andReturn(\Mockery::self());
     $eventManager = \Mockery::mock('Zend\\EventManager\\EventManager')->shouldDeferMissing();
     $mvcEvent->shouldReceive('getEventManager')->andReturn($eventManager);
     $this->instance->onBootstrap($mvcEvent);
     $this->assertEquals(array('route'), $eventManager->getEvents());
 }
 public function test_can_delete_expired()
 {
     $this->em->shouldReceive('createQueryBuilder')->once()->andReturn($this->builder);
     $this->builder->shouldReceive('delete')->once()->with(PasswordReminder::class, 'o')->andReturn(m::self());
     $this->builder->shouldReceive('where')->once()->with('o.createdAt < :expired')->andReturn(m::self());
     $this->builder->shouldReceive('setParameter')->once()->with('expired', (string) Carbon::now()->subSeconds(3600))->andReturn(m::self());
     $this->builder->shouldReceive('getQuery')->once()->andReturn(m::self());
     $this->builder->shouldReceive('execute')->once();
     $this->repository->deleteExpired();
 }
 /** @test */
 public function everything()
 {
     list($mailer, $app, $exception, $appInfo, $input, $queryLog) = $this->makeEverything();
     $app['request']->shouldReceive('root')->once()->andReturn('http://localhost');
     $app['mailer']->shouldReceive('send')->once()->with(m::type('array'), m::type('array'), m::type('Closure'))->andReturnUsing(function ($v, $d, \Closure $callback) {
         $msg = m::mock('Illuminate\\Mail\\Message');
         $msg->shouldReceive('to')->once()->with('*****@*****.**')->andReturn(m::self())->getMock()->shouldReceive('subject')->once()->with('[production] TestException - http://localhost');
         $callback($msg);
     });
     $mailer->send('*****@*****.**');
 }
 public function testLogRequest()
 {
     $this->instance->setLog($this->logger);
     $request = \Mockery::mock('Zend\\Http\\PhpEnvironment\\Request');
     $request->shouldReceive('getUri')->andReturn(\Mockery::self());
     $request->shouldReceive('getHost')->andReturn('mock.host');
     $eventManager = \Mockery::mock('Zend\\EventManager\\Event')->shouldDeferMissing();
     $eventManager->shouldReceive('getRequest')->andReturn($request);
     $this->instance->logRequest($eventManager);
     $this->assertTrue(is_int(strpos($this->writer->events[0]['message'], 'mock.host')));
 }
Exemple #24
0
 public function testResets()
 {
     $fetcher = Mockery::mock('\\Mcprohosting\\Skinner\\Fetcher');
     $provider = Mockery::mock('\\Mcprohosting\\Skinner\\ImageProvider');
     $imagemock = Mockery::mock('Image');
     $imagemock->shouldReceive('backup')->andReturn(Mockery::self());
     $imagemock->shouldReceive('reset')->andReturn('bar');
     $fetcher->shouldReceive('download')->with('notch')->andReturn('foo');
     $provider->shouldReceive('make')->with('foo')->andReturn($imagemock);
     $skin = (new Skin('notch', $fetcher, $provider))->skin()->skin();
     $this->assertEquals($skin->data, 'bar');
 }
 public function testRefreshAllCategories()
 {
     $categories_repo_mock = \Mockery::mock('Giftertipster\\Repository\\Categories\\CategoriesRepositoryInterface');
     $categories_repo_mock->shouldReceive('getCategories')->once();
     $this->app->instance('Giftertipster\\Repository\\Categories\\CategoriesRepositoryInterface', $categories_repo_mock);
     $cache_mgr_mock = \Mockery::mock('Giftertipster\\Service\\Cache\\Categories\\CategoriesCacheMgrInterface');
     $cache_mgr_mock->shouldReceive('allCategories')->once()->andReturn(\Mockery::self());
     $cache_mgr_mock->shouldReceive('clear')->once();
     $this->app->instance('Giftertipster\\Service\\Cache\\Categories\\CategoriesCacheMgrInterface', $cache_mgr_mock);
     $cache_refresher = $this->app->make('Giftertipster\\Service\\Cache\\Categories\\CategoriesCacheRefresher');
     $cache_refresher->refreshAllCategories();
 }
 public function testRefreshAllProducts()
 {
     $product_fetcher_mock = \Mockery::mock('Giftertipster\\Service\\ProductSuite\\ProductSuiteFromIndexFetcherInterface');
     $product_fetcher_mock->shouldReceive('popularProducts')->once();
     $this->app->instance('Giftertipster\\Service\\ProductSuite\\ProductSuiteFromIndexFetcherInterface', $product_fetcher_mock);
     $cache_mgr_mock = \Mockery::mock('Giftertipster\\Service\\Cache\\Products\\ProductsCacheMgrInterface');
     $cache_mgr_mock->shouldReceive('popularProducts')->once()->andReturn(\Mockery::self());
     $cache_mgr_mock->shouldReceive('clear')->once();
     $this->app->instance('Giftertipster\\Service\\Cache\\Products\\ProductsCacheMgrInterface', $cache_mgr_mock);
     $cache_refresher = $this->app->make('Giftertipster\\Service\\Cache\\Products\\ProductsCacheRefresher');
     $cache_refresher->refreshPopularProducts();
 }
 public function testRefreshGetSalesAgentIdsByEmail()
 {
     $user_repo_mock = \Mockery::mock('Giftertipster\\Repository\\User\\UserRepositoryInterface');
     $user_repo_mock->shouldReceive('getSalesAgentIdsByEmail')->once();
     $this->app->instance('Giftertipster\\Repository\\User\\UserRepositoryInterface', $user_repo_mock);
     $cache_mgr_mock = \Mockery::mock('Giftertipster\\Service\\Cache\\Users\\UsersCacheMgrInterface');
     $cache_mgr_mock->shouldReceive('salesAgentIdsByEmail')->once()->andReturn(\Mockery::self());
     $cache_mgr_mock->shouldReceive('clear')->once();
     $this->app->instance('Giftertipster\\Service\\Cache\\Users\\UsersCacheMgrInterface', $cache_mgr_mock);
     $cache_refresher = $this->app->make('Giftertipster\\Service\\Cache\\Users\\UsersCacheRefresher');
     $cache_refresher->refreshSalesAgentIdsByEmail();
 }
 protected function setUp()
 {
     parent::setUp();
     $this->pageFactory->shouldReceive('initPage')->andReturn(\Mockery::self());
     $this->pageFactory->shouldReceive('initElementContainer')->andReturn(\Mockery::self());
     $this->pageFactory->shouldReceive('initElements')->andReturn(\Mockery::self());
     $this->selectorsHandler->shouldReceive('isSelectorRegistered')->andReturn(false);
     $this->selectorsHandler->shouldReceive('registerSelector')->with('se', m::any())->andReturnNull();
     $this->annotationManager = m::mock(self::ANNOTATION_MANAGER_CLASS);
     $this->urlBuilderFactory = m::mock(self::URL_BUILDER_FACTORY_INTERFACE);
     $this->config = new Config(array('base_url' => 'http://domain.tld'));
     $this->realFactory = $this->createFactory();
 }
 public function testGetByUsersCreatesNewGalleries()
 {
     $galleryStubs = [$this->galleryStub, $this->galleryStub];
     $stub = Mockery::mock('PullAutomaticallyGalleries\\RemoteApi\\RemoteApiModelInterface')->shouldReceive('setAuth')->times(2)->andReturn(Mockery::self())->shouldReceive('all')->times(2)->andReturn($galleryStubs)->getMock();
     $mock = Test::double('RemoteGallery', ['newModel' => $stub]);
     $userStubs = [['host' => 'DummyHost', 'credentials' => ['foo']], ['host' => 'AnotherDummyHost', 'credentials' => ['bar']]];
     $galleries = RemoteGallery::getByUsers($userStubs);
     $mock->verifyInvokedMultipleTimes('setHost', 2);
     $mock->verifyInvokedMultipleTimes('newModel', 2);
     $mock->verifyInvokedMultipleTimes('modifyAttributes', 4);
     $mock->verifyInvoked('newCollection');
     assertThat($galleries, is(traversableWithSize(4)));
 }
 public function testConfigureOptionsResolver()
 {
     $this->builder->configureOptionsResolver(\Mockery::mock('Symfony\\Component\\OptionsResolver\\OptionsResolver')->shouldReceive('setRequired')->once()->with(array('pdo', 'table', 'fields', 'id_field'))->andReturn(\Mockery::self())->getMock()->shouldReceive('setAllowedTypes')->once()->with(array('pdo' => 'PDO', 'table' => 'string', 'fields' => 'array', 'id_field' => 'string'))->andReturn(\Mockery::self())->getMock()->shouldReceive('addAllowedTypes')->once()->with(array('pdo' => 'string'))->andReturn(\Mockery::self())->getMock()->shouldReceive('setNormalizers')->once()->with(new EqualsMatcher(array('pdo' => function () {
     })))->andReturn(\Mockery::self())->getMock());
     $pdo = new MockPDO(\Mockery::mock());
     $resolver = new OptionsResolver();
     $this->builder->configureOptionsResolver($resolver);
     $options = $resolver->resolve(array('pdo' => $pdo, 'table' => '', 'fields' => array(), 'id_field' => ''));
     $this->assertSame($pdo, $options['pdo']);
     $this->container->set('pdo', $pdo);
     $options = $resolver->resolve(array('pdo' => 'pdo', 'table' => '', 'fields' => array(), 'id_field' => ''));
     $this->assertSame($pdo, $options['pdo']);
 }