public function testGetLoggedUserIdWhenUserIsNotLogged() { $authenticator_mock = \Mockery::mock('Jacopo\\Authentication\\SentryAuthenticator'); $authenticator_mock->shouldReceive('getLoggedUser')->once()->andReturn(null); $this->app->instance('authenticator', $authenticator_mock); assertThat($this->authMgr()->getLoggedUserId(), nullValue()); }
public function testEvaluatesToTrueIfArgumentIsNull() { assertThat(null, nullValue()); assertThat(self::ANY_NON_NULL_ARGUMENT, not(nullValue())); assertThat(self::ANY_NON_NULL_ARGUMENT, notNullValue()); assertThat(null, not(notNullValue())); }
public function testFindNotFoundRetunsNull() { $stub = Mockery::mock('PullAutomaticallyGalleries\\RemoteApi\\RemoteApiModelInterface')->shouldReceive('setAuth')->with(['foo'])->once()->andReturn(Mockery::self())->shouldReceive('find')->with('1')->once()->andReturn(null)->getMock(); $mock = Test::double('RemoteGallery', ['newModel' => $stub]); $gallery = RemoteGallery::find('DummyHost', ['foo'], '1'); $mock->verifyNeverInvoked('modifyAttributes'); assertThat($gallery, is(nullValue())); }
public function testGetPreviousFull() { $this->prepareUploadTree($this->getTestFileStructure()); $entries = array_reverse($this->entries); $previousId = $entries[0]; foreach (array_slice($entries, 1) as $entry) { $previousItem = $this->uploadDao->getPreviousItem(32, $previousId); assertThat($previousItem->getId(), is($entry)); $previousId = $entry; } $previousItem = $this->uploadDao->getPreviousItem(32, $previousId); assertThat($previousItem, is(nullValue())); }
public function testDelete() { $adapter = new SqsAdapter($this->client, 'foo'); $url = $this->stubCreateQueue('foo'); $this->client->shouldReceive('deleteQueue')->once()->with(['QueueUrl' => $url])->andReturn($this->model); assertThat($adapter->delete(), is(nullValue())); }
public function testGetFolder() { $this->folderDao->ensureTopLevelFolder(); $goodFolder = $this->folderDao->getFolder(FolderDao::TOP_LEVEL); assertThat($goodFolder, is(anInstanceOf(\Fossology\Lib\Data\Folder\Folder::classname()))); assertThat($goodFolder->getId(), equalTo(FolderDao::TOP_LEVEL)); $badFolder = $this->folderDao->getFolder(987); assertThat($badFolder, is(nullValue())); }
public function testShouldIgnoreMissingCallingNonExistentMethods() { Mockery::getConfiguration()->allowMockingNonExistentMethods(true); $mock = $this->container->mock('ClassWithMethods')->shouldIgnoreMissing(); assertThat(nullValue($mock->foo())); assertThat(nullValue($mock->bar())); assertThat(nullValue($mock->nonExistentMethod())); $mock->shouldReceive(array('foo' => 'new_foo', 'nonExistentMethod' => 'result')); $mock->shouldReceive('bar')->passthru(); assertThat($mock->foo(), equalTo('new_foo')); assertThat($mock->bar(), equalTo('bar')); assertThat($mock->nonExistentMethod(), equalTo('result')); }
public function testGetUsersSalesAgentIdByEmailReturnsNullWhenInvalidUserEmailIsProvided() { //stubs $sales_agent_ids = ['*****@*****.**' => 'foobar1', '*****@*****.**' => 'foobar2']; //mocks $cache_mgr_mock = \Mockery::mock('Giftertipster\\Service\\Cache\\Users\\UsersCacheMgrInterface'); $cache_mgr_mock->shouldReceive('salesAgentIdsByEmail')->twice()->andReturn(\Mockery::self()); $cache_mgr_mock->shouldReceive('exists')->once()->andReturn(true); $cache_mgr_mock->shouldReceive('get')->once()->andReturn($sales_agent_ids); $this->app->instance('Giftertipster\\Service\\Cache\\Users\\UsersCacheMgrInterface', $cache_mgr_mock); //actions $response = $this->repo()->getUsersSalesAgentIdByEmail('*****@*****.**'); //assertions assertThat($response, nullValue()); }
public function testGetTitle() { assertThat($this->plugin->getTitle(), is(nullValue())); $title = "<title>"; $this->plugin = new TestPlugin($this->name, array(TestPlugin::TITLE => $title)); assertThat($this->plugin->getTitle(), is($title)); }
public function testDeleteDeletesAddAndRelatedCategoriesWhenNotAllCategoryTypesHaveRelations() { $this->makeRelatedModels(); $add_attributes = ['add_type_id' => 1, 'product_id' => 1, 'occasion_ids' => [1], 'relation_ids' => [1], 'gender_ids' => [], 'age_ids' => [], 'interest_ids' => [1], 'sub_interest_ids' => [1]]; $this->add_repo->create($add_attributes); $add = $this->eloquent_add->find(1); assertThat($add['add_type_id'], equalTo(1)); $response = $this->add_repo->delete(1); $add = $this->eloquent_add->find(1); assertThat($add, nullValue()); $occasion_count = $this->app->make('Giftertipster\\Entity\\Eloquent\\Category\\OccasionCategory')->get()->count(); $relation_count = $this->app->make('Giftertipster\\Entity\\Eloquent\\Category\\RelationCategory')->get()->count(); $gender_count = $this->app->make('Giftertipster\\Entity\\Eloquent\\Category\\GenderCategory')->get()->count(); $age_count = $this->app->make('Giftertipster\\Entity\\Eloquent\\Category\\AgeCategory')->get()->count(); $interest_count = $this->app->make('Giftertipster\\Entity\\Eloquent\\Category\\InterestCategory')->get()->count(); $sub_interest_count = $this->app->make('Giftertipster\\Entity\\Eloquent\\Category\\SubInterestCategory')->get()->count(); $categories_pivot_count = count(\DB::table('add_categories')->get()); assertThat($occasion_count, greaterThan(0)); assertThat($relation_count, greaterThan(0)); assertThat($gender_count, greaterThan(0)); assertThat($age_count, greaterThan(0)); assertThat($interest_count, greaterThan(0)); assertThat($sub_interest_count, greaterThan(0)); assertThat($categories_pivot_count, equalTo(0)); }
public function testRandomFeaturedListingProductsReturnsEmptyArrayWithThereAreNoFeaturedListings() { $product_1 = Factory::create('Giftertipster\\Entity\\Eloquent\\Product'); $product_2 = Factory::create('Giftertipster\\Entity\\Eloquent\\Product'); $product_3 = Factory::create('Giftertipster\\Entity\\Eloquent\\Product'); $image_1 = Factory::create('Giftertipster\\Entity\\Eloquent\\Image', ['imageable_type' => 'Giftertipster\\Entity\\Eloquent\\Product', 'imageable_id' => 1]); $image_2 = Factory::create('Giftertipster\\Entity\\Eloquent\\Image', ['imageable_type' => 'Giftertipster\\Entity\\Eloquent\\Product', 'imageable_id' => 2]); $image_3 = Factory::create('Giftertipster\\Entity\\Eloquent\\Image', ['imageable_type' => 'Giftertipster\\Entity\\Eloquent\\Product', 'imageable_id' => 3]); $repo = $this->app->make('Giftertipster\\Repository\\ProductSuite\\EloquentProductSuiteRepository'); $listing = $repo->randomFeatureListingProducts(); assertThat($listing, nullValue()); }
public function testFinderCreateLogsNoticeWhenSomeSubProductVariationsAttributesAreInvalid() { Factory::create('Giftertipster\\Entity\\Eloquent\\Idea', ['user_id' => 1, 'is_fulfilled' => 0]); $suite_attributes = ['vendor' => 'amazon', 'vendor_id' => 'b000000', 'binding' => 'testbinding', 'brand' => 'testbrand', 'manufacturer' => 'test manufacturer', 'model' => 'test model', 'group' => 'test group', 'type' => 'test type', 'size' => 'testsize', 'clothing_size' => 'test clothing size', 'color' => 'testcolor', 'title' => 'test title', 'department' => 'test department', 'min_price_amount' => 4000, 'min_price_currency' => 'USD', 'min_price_formatted' => '$40.00', 'max_price_amount' => 4000, 'max_price_currency' => 'USD', 'max_price_formatted' => '$40.00', 'reviews_url' => 'reviewsurl.com', 'detail_url' => 'detailurl.com']; $suite_attributes['images'] = []; $suite_attributes['features'] = []; $suite_attributes['descriptions'] = []; $suite_attributes['sub_products'][] = ['vendor' => 'amazon', 'vendor_id' => 'b000001', 'parent_vendor_id' => 'b000000', 'binding' => 'testbinding', 'brand' => 'testbrand', 'manufacturer' => 'test manufacturer', 'model' => 'test model', 'group' => 'test group', 'type' => 'test type', 'size' => 'testsize', 'clothing_size' => 'test clothing size', 'color' => 'testcolor', 'title' => 'test title', 'condition' => 'test condition', 'department' => 'test department', 'list_price_amount' => 4000, 'list_price_currency' => 'USD', 'list_price_formatted' => '$40.00', 'price_amount' => 4000, 'price_currency' => 'USD', 'price_formatted' => '$40.00', 'availability' => 'test avail', 'availability_type' => 'test avail type', 'availability_max_hours' => 'test avail max hours', 'availability_min_hours' => 'test avail min hours', 'availability_ship' => 'test avail ship', 'availability_ss_ship' => 1, 'offer_listing_id' => 'foo1', 'images' => [], 'descriptions' => [], 'features' => []]; $suite_attributes['sub_products'][0]['variations'][] = ['type' => 'variationtype', 'value' => 'variation1']; $suite_attributes['sub_products'][0]['variations'][] = ['type' => '', 'value' => 'variation2']; $suite_attributes['keyword_profile']['profile'] = []; $suite_attributes['category_keywords'] = []; $expected_index_attributes = ['vendor' => 'amazon', 'vendor_id' => 'b000000', 'binding' => 'testbinding', 'brand' => 'testbrand', 'manufacturer' => 'test manufacturer', 'model' => 'test model', 'group' => 'test group', 'type' => 'test type', 'size' => 'testsize', 'clothing_size' => 'test clothing size', 'color' => 'testcolor', 'title' => 'test title', 'department' => 'test department', 'min_price_amount' => 4000, 'min_price_currency' => 'USD', 'min_price_formatted' => '$40.00', 'max_price_amount' => 4000, 'max_price_currency' => 'USD', 'max_price_formatted' => '$40.00', 'reviews_url' => 'reviewsurl.com', 'detail_url' => 'detailurl.com']; $expected_index_attributes['images'] = []; $expected_index_attributes['features'] = []; $expected_index_attributes['descriptions'] = []; $expected_index_attributes['sub_products'][] = ['vendor' => 'amazon', 'vendor_id' => 'b000001', 'parent_vendor_id' => 'b000000', 'binding' => 'testbinding', 'brand' => 'testbrand', 'manufacturer' => 'test manufacturer', 'model' => 'test model', 'group' => 'test group', 'type' => 'test type', 'size' => 'testsize', 'clothing_size' => 'test clothing size', 'color' => 'testcolor', 'title' => 'test title', 'condition' => 'test condition', 'department' => 'test department', 'list_price_amount' => 4000, 'list_price_currency' => 'USD', 'list_price_formatted' => '$40.00', 'price_amount' => 4000, 'price_currency' => 'USD', 'price_formatted' => '$40.00', 'availability' => 'test avail', 'availability_type' => 'test avail type', 'availability_max_hours' => 'test avail max hours', 'availability_min_hours' => 'test avail min hours', 'availability_ship' => 'test avail ship', 'availability_ss_ship' => 1, 'offer_listing_id' => 'foo1', 'images' => [], 'descriptions' => [], 'features' => []]; $expected_index_attributes['sub_products'][0]['variations'][] = ['type' => 'variationtype', 'value' => 'variation1']; $expected_index_attributes['keyword_profile']['profile'] = []; $expected_index_attributes['category_keywords'] = []; \Log::shouldReceive('notice')->once(); //mock ProductSuiteIndexer $expected_product_suite = $expected_index_attributes; $indexer = Mockery::mock('Giftertipster\\Service\\ProductSuite\\ProductSuiteIndexerInterface'); $indexer->shouldReceive('queueIndex')->with(Mockery::on(function ($product_suite) use($expected_product_suite) { if (!empty($this->arrayRecursiveDiff($expected_product_suite, $product_suite))) { return false; } return true; }), false, false)->once()->andReturn(true); $this->app->instance('Giftertipster\\Service\\ProductSuite\\ProductSuiteIndexerInterface', $indexer); $repo = $this->app->make('Giftertipster\\Repository\\ProductSuite\\EloquentProductSuiteRepository'); $response = $repo->finderCreate($suite_attributes, 'Idea', 1, 2); $errors = $repo->errors(); assertThat($response, equalTo(true)); $eloquent_product = $this->app->make('Giftertipster\\Entity\\Eloquent\\Product'); $product = $eloquent_product->find(1); $eloquent_variation = $this->app->make('Giftertipster\\Entity\\Eloquent\\Variation'); $sub_product_variation = $eloquent_variation->where('sub_product_id', '=', 1)->get()->toArray(); assertThat($errors, nullValue()); assertThat($product, notNullValue()); assertThat($sub_product_variation, arrayWithSize(1)); }
/** @dataProvider provideLevels */ public function testSetAndGetValue($key) { assertThat($this->events->get($key), is(nullValue())); $this->events->set($key, 'value'); assertThat($this->events->get($key), is('value')); }
public function testUpdateLogsNoticeWhenAllOfMultipleSubProductUpdatesFailDueToVariations() { $update_attributes = ['vendor' => 'amazon', 'vendor_id' => 'b000000', 'binding' => 'testbinding', 'brand' => 'testbrand', 'manufacturer' => 'test manufacturer', 'model' => 'test model', 'group' => 'test group', 'type' => 'test type', 'size' => 'testsize', 'clothing_size' => 'test clothing size', 'color' => 'testcolor', 'title' => 'updated test title', 'department' => 'test department', 'min_price_amount' => 4000, 'min_price_currency' => 'USD', 'min_price_formatted' => '$40.00', 'max_price_amount' => 4000, 'max_price_currency' => 'USD', 'max_price_formatted' => '$40.00', 'reviews_url' => 'reviewsurl.com', 'detail_url' => 'detailurl.com', 'images' => [['category' => 'image1', 'swatch_url' => 'testurl.com', 'swatch_height' => '100', 'swatch_width' => '200', 'small_url' => 'testurl.com', 'small_height' => '100', 'small_width' => '200', 'thumb_url' => 'testurl.com', 'thumb_height' => '100', 'thumb_width' => '200', 'tiny_url' => 'testurl.com', 'tiny_height' => '100', 'tiny_width' => '200', 'medium_url' => 'testurl.com', 'medium_height' => '100', 'medium_width' => '200', 'large_url' => 'testurl.com', 'large_height' => '100', 'large_width' => '200']], 'features' => [['description' => 'updated description']], 'descriptions' => [['type' => 'updated type', 'value' => 'updated value']], 'sub_products' => [['vendor' => 'amazon', 'vendor_id' => 'b000001', 'parent_vendor_id' => 'b000000', 'binding' => 'testbinding', 'brand' => 'testbrand', 'manufacturer' => 'test manufacturer', 'model' => 'test model', 'group' => 'test group', 'type' => 'test type', 'size' => 'testsize', 'clothing_size' => 'test clothing size', 'color' => 'testcolor', 'title' => 'updated sub product title', 'condition' => 'test condition', 'department' => 'test department', 'list_price_amount' => 4000, 'list_price_currency' => 'USD', 'list_price_formatted' => '$40.00', 'price_amount' => 4000, 'price_currency' => 'USD', 'price_formatted' => '$40.00', 'availability' => 'test avail', 'availability_type' => 'test avail type', 'availability_max_hours' => 'test avail max hours', 'availability_min_hours' => 'test avail min hours', 'availability_ship' => 'test avail ship', 'availability_ss_ship' => 1, 'offer_listing_id' => 'foo1', 'images' => [['category' => 'updated sub product image', 'swatch_url' => 'testurl.com', 'swatch_height' => '100', 'swatch_width' => '200', 'small_url' => 'testurl.com', 'small_height' => '100', 'small_width' => '200', 'thumb_url' => 'testurl.com', 'thumb_height' => '100', 'thumb_width' => '200', 'tiny_url' => 'testurl.com', 'tiny_height' => '100', 'tiny_width' => '200', 'medium_url' => 'testurl.com', 'medium_height' => '100', 'medium_width' => '200', 'large_url' => 'testurl.com', 'large_height' => '100', 'large_width' => '200']], 'features' => [['description' => 'updated sub product feature']], 'descriptions' => [['type' => 'updated sub product description type', 'value' => 'updated sub product description value']], 'variations' => [['foobar' => 'updated sub product variation type', 'value' => 'updated sub product variation value']]], ['vendor' => 'amazon', 'vendor_id' => 'b000001', 'parent_vendor_id' => 'b000000', 'binding' => 'testbinding', 'brand' => 'testbrand', 'manufacturer' => 'test manufacturer', 'model' => 'test model', 'group' => 'test group', 'type' => 'test type', 'size' => 'testsize', 'clothing_size' => 'test clothing size', 'color' => 'testcolor', 'title' => 'updated sub product title', 'condition' => 'test condition', 'department' => 'test department', 'list_price_amount' => 4000, 'list_price_currency' => 'USD', 'list_price_formatted' => '$40.00', 'price_amount' => 4000, 'price_currency' => 'USD', 'price_formatted' => '$40.00', 'availability' => 'test avail', 'availability_type' => 'test avail type', 'availability_max_hours' => 'test avail max hours', 'availability_min_hours' => 'test avail min hours', 'availability_ship' => 'test avail ship', 'availability_ss_ship' => 1, 'offer_listing_id' => 'foo1', 'images' => [['category' => 'updated sub product image', 'swatch_url' => 'testurl.com', 'swatch_height' => '100', 'swatch_width' => '200', 'small_url' => 'testurl.com', 'small_height' => '100', 'small_width' => '200', 'thumb_url' => 'testurl.com', 'thumb_height' => '100', 'thumb_width' => '200', 'tiny_url' => 'testurl.com', 'tiny_height' => '100', 'tiny_width' => '200', 'medium_url' => 'testurl.com', 'medium_height' => '100', 'medium_width' => '200', 'large_url' => 'testurl.com', 'large_height' => '100', 'large_width' => '200']], 'features' => [['description' => 'updated sub product feature']], 'descriptions' => [['type' => 'updated sub product description type', 'value' => 'updated sub product description value']], 'variations' => [['foobar' => 'updated sub product variation type', 'value' => 'updated sub product variation value']]]], 'keyword_profile' => []]; $expected_index_attributes = ['vendor' => 'amazon', 'vendor_id' => 'b000000', 'binding' => 'testbinding', 'brand' => 'testbrand', 'manufacturer' => 'test manufacturer', 'model' => 'test model', 'group' => 'test group', 'type' => 'test type', 'size' => 'testsize', 'clothing_size' => 'test clothing size', 'color' => 'testcolor', 'title' => 'updated test title', 'department' => 'test department', 'min_price_amount' => 0, 'min_price_currency' => 'USD', 'min_price_formatted' => '$0.00', 'max_price_amount' => 0, 'max_price_currency' => 'USD', 'max_price_formatted' => '$0.00', 'reviews_url' => 'reviewsurl.com', 'detail_url' => 'detailurl.com', 'is_refreshed' => 1]; $data_repo = $this->dataRepoSetup(); \DB::shouldReceive('beginTransaction')->twice(); \DB::shouldReceive('commit')->twice(); \DB::shouldReceive('rollback')->never(); $add_repo_mock = \Mockery::mock('Giftertipster\\Repository\\Add\\AddRepositoryInterface'); $add_repo_mock->shouldReceive('getAdminAddCategoryKeywords')->once()->with(1)->andReturn(['category', 'keywords']); $this->app->instance('Giftertipster\\Repository\\Add\\AddRepositoryInterface', $add_repo_mock); //mock ProductSuiteIndexer $expected_product_suite = $expected_index_attributes; $indexer = Mockery::mock('Giftertipster\\Service\\ProductSuite\\ProductSuiteIndexerInterface'); $indexer->shouldReceive('queueIndex')->with(Mockery::on(function ($product_suite) use($expected_product_suite) { if (!empty($this->arrayRecursiveDiff($expected_product_suite, $product_suite))) { return false; } return true; }), true, false)->once()->andReturn(true); $this->app->instance('Giftertipster\\Service\\ProductSuite\\ProductSuiteIndexerInterface', $indexer); \Log::shouldReceive('notice')->times(3); $repo = $this->app->make('Giftertipster\\Repository\\ProductSuite\\EloquentProductSuiteRepository'); $response = $repo->update(1, $update_attributes, true); $this->getDataRepoData(); assertThat($response, equalTo(true)); assertThat($repo->errors(), nullValue()); }
public function testSetUserAddSelfProfile() { $this->add_profile_mgr->setUserAddSelfProfile(['add profile stub']); assertThat(\Session::get('Giftertipster\\Service\\Add\\AddProfileMgr.user_add_profile'), nullValue()); assertThat(\Session::get('Giftertipster\\Service\\Add\\AddProfileMgr.user_add_self_profile'), identicalTo(['add profile stub'])); }
public function testDeletePermBlacklistsProductAndCallsIndexDelete() { $index_repo = Mockery::mock('Giftertipster\\Repository\\ProductsIndex\\Product\\ProductsIndexProductRepositoryInterface'); $index_repo->shouldReceive('deleteProductAndAdds')->with(1, true)->once()->andReturn(true); $this->app->instance('Giftertipster\\Repository\\ProductsIndex\\Product\\ProductsIndexProductRepositoryInterface', $index_repo); $data_repo = $this->dataRepoSetup(); $response = $data_repo->deletePerm(1); $blacklisted_product = $this->app->make('Giftertipster\\Entity\\Eloquent\\BlacklistedProduct'); $blacklisted_product = $blacklisted_product->find(1); assertThat($blacklisted_product, not(nullValue())); }
public function testGetCurrentClearingsWithAgentDecisionsOnly() { list($scannerResults, $licenseRef) = $this->createScannerDetectedLicenses(); $this->agentLicenseEventProcessor->shouldReceive("getScannerEvents")->with($this->itemTreeBounds, LicenseMap::TRIVIAL)->andReturn($scannerResults); $this->clearingDao->shouldReceive("getRelevantClearingEvents")->with($this->itemTreeBounds, $this->groupId)->andReturn(array()); list($licenseDecisions, $removedClearings) = $this->clearingDecisionProcessor->getCurrentClearings($this->itemTreeBounds, $this->groupId); assertThat($licenseDecisions, is(arrayWithSize(1))); /** @var ClearingResult $result */ $result = $licenseDecisions[$licenseRef->getId()]; assertThat($result->getLicenseRef(), is($licenseRef)); assertThat($result->getClearingEvent(), is(nullValue())); assertThat($result->getAgentDecisionEvents(), is(arrayWithSize(1))); assertThat($removedClearings, is(emptyArray())); }