public function testFilterWhenThereAreDuplicatesAndNoPrimary()
 {
     $suite_images = [['category' => 'variant', 'field1' => 'foobar', 'field2' => 'foobar'], ['category' => 'variant', 'field1' => 'foobar1', 'field2' => 'foobar2'], ['category' => 'variant', 'field1' => 'foobar', 'field2' => 'foobar']];
     $expected_filtered_images = [['category' => 'variant', 'field1' => 'foobar', 'field2' => 'foobar'], ['category' => 'variant', 'field1' => 'foobar1', 'field2' => 'foobar2']];
     $filtered_images = $this->filter_service->filter($suite_images);
     assertThat($filtered_images, identicalTo($expected_filtered_images));
 }
コード例 #2
0
 public function testPrepWhenNullAddFormIsSupplied()
 {
     $add_form_prepper = $this->app->make('Giftertipster\\Service\\Add\\AddFormPrepper');
     $prepped_add_form = $add_form_prepper->prep(null);
     $expected_prepped_add_form = [];
     assertThat($prepped_add_form, identicalTo($expected_prepped_add_form));
 }
コード例 #3
0
 public function testShouldReturnTokenResponseWhenTokenIsNotLoaded()
 {
     $token = $this->givenAccessToken('');
     $token->response = 'irrelevant response (instanceof Response)';
     $response = $this->api->getStatus('irrelevant id');
     assertThat($response, identicalTo($token->response));
 }
 public function testMakeBucketLabelReturnsExpectedResponseWhenMaxIsNull()
 {
     $expected_response = '$10 +';
     $bucket = ['min' => 1000, 'max' => null];
     $response = $this->labeler->makeBucketLabel($bucket);
     assertThat($response, identicalTo($expected_response));
 }
 public function testIsProductSuiteBlacklistedReturnsFalseWhenItIsNot()
 {
     $create_response = $this->eloquent_bp->create(['vendor' => 'vendor.com', 'vendor_id' => 1]);
     $prod_suite_stub = ['vendor' => 'vendor.com', 'vendor_id' => 2];
     assertThat($create_response, equalTo(true));
     assertThat($this->eloquent_bp->isProductSuiteBlacklisted($prod_suite_stub), identicalTo(false));
 }
コード例 #6
0
 public function testClearUserAddSelftProfile()
 {
     \Session::put('Giftertipster\\Service\\Add\\AddProfileMgr.user_add_self_profile', 'test');
     assertThat(\Session::has('Giftertipster\\Service\\Add\\AddProfileMgr.user_add_self_profile'), identicalTo(true));
     $this->add_profile_mgr->clearUserAddSelfProfile();
     assertThat(\Session::has('Giftertipster\\Service\\Add\\AddProfileMgr.user_add_self_profile'), identicalTo(false));
 }
コード例 #7
0
 public function testValidateReturnsTrueOnSuccess()
 {
     $filter = $this->app->make('Giftertipster\\Entity\\ProductSearchFilter\\CategoriesFilter');
     $validator = $this->app->make('Giftertipster\\Service\\Validate\\ProductSearchFilter\\FilterValidatorInterface');
     $response = $validator->validate($filter);
     assertThat($response, identicalTo(true));
 }
コード例 #8
0
 public function testHasPermission()
 {
     $auth_helper_mock = \Mockery::mock('Jacopo\\Authentication\\Helpers\\SentryAuthenticationHelper');
     $auth_helper_mock->shouldReceive('hasPermission')->once()->with(['permissions stub'])->andReturn('foobar');
     $this->app->instance('authentication_helper', $auth_helper_mock);
     assertThat($this->authMgr()->hasPermission(['permissions stub']), identicalTo('foobar'));
 }
コード例 #9
0
 /**
  * @test
  */
 function matches_using_callback()
 {
     $matcher = new CallbackMatcher(function ($value) {
         return $value === "Hello, world.";
     });
     assertThat($matcher->matches("Hello, world."), is(identicalTo(true)));
 }
 public function testUpdateForProduct()
 {
     $product = Factory::create('Giftertipster\\Entity\\Eloquent\\Product');
     $keyword_profile = Factory::make('Giftertipster\\Entity\\Eloquent\\KeywordProfile');
     $product->keywordProfile()->save($keyword_profile);
     $this->repo->updateForProduct(1, ['profile' => ['updated', 'profile']]);
     assertThat(KeywordProfile::find(1)->profile, identicalTo(['updated', 'profile']));
 }
コード例 #11
0
 public function testMakeParamsReturnsExpectedParamsWhenRefreshIsRequested()
 {
     \Config::shouldReceive('get')->with('index.index_products_type_product')->once()->andReturn($this->config);
     $doc_id = 100;
     $params_mock = ['index' => 'tests', 'type' => 'test', 'id' => $doc_id, 'refresh' => true];
     $result = $this->gen->makeParams('products', 'product', $doc_id, true);
     assertThat($result, identicalTo($params_mock));
 }
コード例 #12
0
ファイル: ArrayIntegrationTest.php プロジェクト: traxo/queue
 public function testReceiveWithPolling()
 {
     $msgs = [];
     $this->client->receive(function ($msg) use(&$msgs) {
         $msgs[] = $msg;
     }, null);
     assertThat($msgs, is(identicalTo($this->messages)));
 }
コード例 #13
0
 public function testMakeCompilesBucketsCorrectlyAndReturnsResult()
 {
     $expected_result = ['label' => '$0 – $510', 'count' => 84, 'min' => null, 'max' => 51000, 'filter' => ['filter' => 'NumberRangeFilter', 'params' => ['field' => 'min_price', 'min' => null, 'max' => 51000]]];
     $this->bucket_label_mock->shouldReceive('makeBucketLabel')->with(['min' => $expected_result['min'], 'max' => $expected_result['max'], 'count' => $expected_result['count'], 'filter' => $expected_result['filter'], 'label' => ''])->andReturn($expected_result['label']);
     $processor = $this->app->make('Giftertipster\\Service\\ESIndex\\FacetsGenerator\\SmartRange\\Processor\\LowBucket\\LowBucketProcessor');
     $result = $processor->make($this->bucket_label_mock, 'min_price', 1000, $this->low_buckets, 1000);
     assertThat($result, identicalTo($expected_result));
 }
コード例 #14
0
 /**
  * @test
  */
 public function write_withContentsAndAFile_writesContentsToTheFileOnTheFileSystem()
 {
     $writtenContent = 'my new content that is awesome';
     $file = Mockery::mock('FileSystem\\File[]', array('file.txt', $this->rootObject));
     $file->content = $writtenContent;
     $this->fileSystem->write($file, VFS::url('root'));
     assertThat(file_get_contents(VFS::url('root/file.txt')), is(identicalTo($writtenContent)));
 }
コード例 #15
0
 public function testCheckIfPaginationExistsEnvPagination()
 {
     $search = new SearchTraitDummyClass();
     $this->mock->shouldReceive('paginate')->once()->with(identicalTo(env('PAGINATION_NUMBER')))->andReturn(true);
     $query = $this->mock;
     $pagination = $search->checkIfPaginationExists($query);
     $this->assertTrue($pagination);
 }
 public function testSubProductMatchingVendorIdReturnsFalseWhenThereAreNoMatches()
 {
     $sub_product = Factory::create('Giftertipster\\Entity\\Eloquent\\SubProduct', ['vendor_id' => 'asin stub2']);
     $sub_product2 = Factory::create('Giftertipster\\Entity\\Eloquent\\SubProduct', ['vendor_id' => 'asin stub2']);
     $sub_product_repo = $this->app->make('Giftertipster\\Repository\\SubProduct\\EloquentSubProductRepository');
     $result_sub_product = $sub_product_repo->subProductMatchingVendorId('asin stub');
     assertThat($result_sub_product, identicalTo(false));
 }
コード例 #17
0
ファイル: ConfigTest.php プロジェクト: sickhye/php-db-migrate
 /**
  * @test
  */
 function construct_()
 {
     $extract = array('obj' => new \stdClass());
     $cfg = array('pdo' => $this->pdo, 'extract' => $extract);
     $config = new Config($cfg, __FILE__);
     $adapter = new PdoAdapter($this->pdo);
     assertThat($config->adapter, isInstanceOf(get_class($adapter)));
     assertThat($config->extract, identicalTo($extract));
 }
 public function testMakeParamsReturnsExpectedParams()
 {
     \Config::shouldReceive('get')->with('index.index_products_type_product')->once()->andReturn($this->config);
     \Config::shouldReceive('get')->with('index.index_products_type_add')->once()->andReturn($this->child_config);
     $doc_id = 100;
     $params_mock = ['index' => 'tests', 'type' => 'test,testchild', 'body' => ['query' => ['bool' => ['should' => [['term' => ['_parent' => 'test#' . $doc_id]], ['ids' => ['type' => 'test', 'values' => [$doc_id]]]]]]]];
     $result = $this->gen->makeParams('products', 'product', ['add'], $doc_id);
     assertThat($result, identicalTo($params_mock));
 }
コード例 #19
0
 public function testMakeReturnsExpectedFilterWhenValueIsEmpty()
 {
     $filter_type = 'TermFilter';
     $filter_params = ['field' => 'testfield', 'value' => ''];
     $expected_response = ['term' => ['testfield' => '']];
     $filter = $this->app->make('Giftertipster\\Service\\ESIndex\\ParamsGenerator\\Search\\Filters\\' . $filter_type);
     $response = $filter->make($filter_params);
     assertThat($response, identicalTo($expected_response));
 }
コード例 #20
0
 public function testMakeReturnsNoFacetDivisionsWhenIndexReturnsOnlyOneDivision()
 {
     $term_facet_generator = $this->app->make('Giftertipster\\Service\\ESIndex\\FacetsGenerator\\Term\\ESTermGenerator');
     $filter_field_name_stub = 'testfield';
     $buckets_stub = [['key' => 'value1', 'doc_count' => 3]];
     $expected_response = [];
     $response = $term_facet_generator->make($filter_field_name_stub, $buckets_stub);
     assertThat($response, identicalTo($expected_response));
 }
 public function testMakeReturnsExpectedFilterWhenValueIsEmpty()
 {
     $filter_type = 'TermFilter';
     $filter_params = ['field' => 'testfield', 'value' => ''];
     $expected_response = ['term' => ['testfield' => '']];
     $filter = $this->app->make('Ryanrobertsname\\LaravelElasticsearchRepository\\ParamsGenerator\\Search\\Filters\\' . $filter_type);
     $response = $filter->make($filter_params);
     assertThat($response, identicalTo($expected_response));
 }
コード例 #22
0
ファイル: MessageFactoryTest.php プロジェクト: traxo/queue
 public function testCreateMessageWithValidator()
 {
     $message = $this->factory->createMessage('bar', ['validator' => function ($msg) {
         return false;
     }]);
     assertThat($message, is(anInstanceOf('Graze\\Queue\\Message\\MessageInterface')));
     assertThat($message->getBody(), is(identicalTo('bar')));
     assertThat($message->isValid(), is(identicalTo(false)));
 }
 public function testMakeReturnsNoFacetDivisionsWhenIndexReturnsOnlyOneDivision()
 {
     $term_facet_generator = $this->app->make('Ryanrobertsname\\LaravelElasticsearchRepository\\FacetsGenerator\\Term\\ESTermGenerator');
     $filter_field_name_stub = 'testfield';
     $buckets_stub = [['key' => 'value1', 'doc_count' => 3]];
     $expected_response = [];
     $response = $term_facet_generator->make($filter_field_name_stub, $buckets_stub);
     assertThat($response, identicalTo($expected_response));
 }
コード例 #24
0
ファイル: MessageTest.php プロジェクト: traxo/queue
 public function testIsValidIsCalledWithMessage()
 {
     $seen = null;
     $message = new Message('foo', $this->metadata, function ($msg) use(&$seen) {
         $seen = $msg;
     });
     $message->isValid();
     assertThat($seen, is(identicalTo($message)));
 }
 public function testMakeReturnsExpectedFilter()
 {
     $filter_type = 'NumberRangeFilter';
     $filter_params = ['field' => 'min_price', 'min' => 0, 'max' => 100];
     //$expected_response_in_json = '{"range":{"price":{"gte":0,"lte":100}}}';
     $expected_response = ['range' => ['min_price' => ['gte' => 0, 'lte' => 100]]];
     $filter = $this->app->make('Ryanrobertsname\\LaravelElasticsearchRepository\\ParamsGenerator\\Search\\Filters\\' . $filter_type);
     $response = $filter->make($filter_params, $this->config);
     assertThat($response, identicalTo($expected_response));
 }
コード例 #26
0
ファイル: RedirectorTest.php プロジェクト: lionar/http
 /**
  * @test
  */
 public function back__callsSessionGetMethod()
 {
     $request = Mockery::mock('HTTP\\Request');
     $request->referrer = '/previous/page';
     ob_start();
     $redirect = new Redirector($request);
     $redirect->back();
     $crawler = new Crawler(ob_get_clean());
     $node = $crawler->filter('title')->eq(0);
     assertThat($node->text(), is(identicalTo('Redirecting to /previous/page')));
 }
 public function testGetUnfulfilledRequestsReturnsFalseWhenAllRequestsAreFulfilled()
 {
     Factory::create('Giftertipster\\Entity\\Eloquent\\User', ['permissions' => []]);
     Factory::create('Giftertipster\\Entity\\Eloquent\\Product');
     Factory::create('Giftertipster\\Entity\\Eloquent\\Product');
     $seed_request1 = Factory::create('Giftertipster\\Entity\\Eloquent\\ProductDeleteRequest', ['user_id' => 1, 'product_id' => 1, 'is_fulfilled' => 1, 'delete_type' => 'delete']);
     $seed_request2 = Factory::create('Giftertipster\\Entity\\Eloquent\\ProductDeleteRequest', ['user_id' => 1, 'product_id' => 2, 'is_fulfilled' => 1, 'delete_type' => 'delete']);
     $repo = $this->app->make('Giftertipster\\Repository\\ProductDeleteRequest\\EloquentProductDeleteRequestRepository');
     $requests = $repo->getUnfulfilledRequests();
     assertThat($requests, identicalTo(false));
 }
コード例 #28
0
 public function testMakeCompilesBucketsCorrectlyAndReturnsResultWhenLowAndStdBucketsAreProvided()
 {
     $this->high_buckets = [['key' => 5000, 'doc_count' => 1], ['key' => 10000, 'doc_count' => 10], ['key' => 11000, 'doc_count' => 40], ['key' => 12000, 'doc_count' => 30], ['key' => 13000, 'doc_count' => 2], ['key' => 50000, 'doc_count' => 1]];
     $processed_std_buckets = [['label' => 'label test', 'count' => 3, 'min' => 10, 'max' => 1000, 'filter' => ['filter' => 'NumberRangeFilter', 'params' => ['field' => 'min_price', 'min' => 10, 'max' => 1000]]], ['label' => 'label test', 'count' => 2, 'min' => 1000, 'max' => 1100, 'filter' => ['filter' => 'NumberRangeFilter', 'params' => ['field' => 'min_price', 'min' => 1000, 'max' => 1100]]]];
     $compiled_low_bucket = ['label' => 'label test', 'count' => 3, 'min' => 10, 'max' => 1000, 'filter' => ['filter' => 'NumberRangeFilter', 'params' => ['field' => 'min_price', 'min' => 10, 'max' => 1000]]];
     $expected_result = ['label' => '$11 +', 'count' => 84, 'min' => 1100, 'max' => null, 'filter' => ['filter' => 'NumberRangeFilter', 'params' => ['field' => 'min_price', 'min' => 1100, 'max' => null]]];
     $this->bucket_label_mock->shouldReceive('makeBucketLabel')->with(['min' => $expected_result['min'], 'max' => $expected_result['max'], 'count' => $expected_result['count'], 'filter' => $expected_result['filter'], 'label' => ''])->andReturn($expected_result['label']);
     $processor = $this->app->make('Giftertipster\\Service\\ESIndex\\FacetsGenerator\\SmartRange\\Processor\\HighBucket\\HighBucketProcessor');
     $result = $processor->make($this->bucket_label_mock, 'min_price', $this->high_buckets, $compiled_low_bucket, $processed_std_buckets);
     assertThat($result, identicalTo($expected_result));
 }
 public function testUpdateJob()
 {
     Artisan::call('migrate');
     RangeCronJob::create(['job_name' => 'foobar job', 'last_id_processed' => 1, 'last_status' => 'fooness']);
     $job = $this->repo->findJob('foobar job');
     assertThat($job, anInstanceOf('Giftertipster\\Entity\\Eloquent\\RangeCronJob'));
     $this->repo->updateJob($job, 'test status', 0);
     $updated_job = $this->repo->findJob('foobar job');
     assertThat($updated_job->last_status, identicalTo('test status'));
     assertThat($updated_job->last_id_processed, equalTo(0));
 }
 public function testSupplementNewFormattedCartWhenThereAreNewSupplements()
 {
     $local_sub_product = ['vendor_id' => 'cart item 3 asin'];
     $response = $this->worker->parseLocalSubProductsToCart($this->new_cart_stub_with_new_items, $this->existing_cart_stub, $local_sub_product);
     //configure expected response
     $expected_response = $this->new_cart_stub_with_new_items;
     $expected_response['items'][0]['local_sub_product'] = $this->existing_cart_stub['items'][0]['local_sub_product'];
     $expected_response['items'][1]['local_sub_product'] = $this->existing_cart_stub['items'][1]['local_sub_product'];
     $expected_response['items'][2]['local_sub_product'] = $local_sub_product;
     assertThat($response, identicalTo($expected_response));
 }