Esempio n. 1
0
 /**
  * @test
  */
 public function add_withObject_addsObjectToDirectoryObjects()
 {
     $object = Mockery::mock('FileSystem\\Tests\\Assets\\Object')->shouldIgnoreMissing();
     $object->name = $name = 'name';
     $this->directory->add($object);
     assertThat($this->directory->objects, hasKeyValuePair($name, $object));
 }
Esempio n. 2
0
 function it_generates_time_inputs($html)
 {
     // Expect
     $html->attributes(hasKeyValuePair('type', 'time'));
     // When
     $this->time('time');
 }
 public function testGetAdminAddTypes()
 {
     Factory::create('Giftertipster\\Entity\\Eloquent\\AddType', ['label' => 'foobar']);
     Factory::create('Giftertipster\\Entity\\Eloquent\\AddType', ['label' => 'admin-foobar']);
     $response = $this->repo->getAdminAddTypes();
     assertThat($response[0], hasKeyValuePair('label', 'admin-foobar'));
     assertThat($response[0], hasKeyValuePair('id', 2));
 }
 public function testModelHasDefaultAttributes()
 {
     $gallery = new Gallery();
     $attributes = $gallery->getAttributes();
     assertThat($attributes, hasKeyValuePair('post_type', 'gallery'));
     assertThat($attributes, hasKeyValuePair('post_status', 'publish'));
     assertThat($attributes, hasKeyValuePair('post_author', 1));
 }
 public function testCreateUserAnalytic()
 {
     Factory::create('Giftertipster\\Entity\\Eloquent\\User', ['permissions' => []]);
     $response = $this->repo->createUserAnalytic(1, 10);
     $saved_analytic = UserAnalytic::find(1)->toArray();
     assertThat($response, equalTo(true));
     assertThat($saved_analytic, hasKeyValuePair('quantity', 10));
     assertThat($saved_analytic, hasKeyValuePair('user_id', 1));
 }
 public function testOperation()
 {
     $CartGetOperation = $this->app->make('Giftertipster\\Service\\Api\\AmzProductApi\\ApaiIO\\Operations\\CartGetOperation');
     $CartGetOperation->setCartId('cart id stub');
     $CartGetOperation->setHMAC('hmac stub');
     $params = $CartGetOperation->getOperationParameter();
     assertThat($CartGetOperation->getName(), equalTo('CartGet'));
     assertThat($params, arrayWithSize(2));
     assertThat($params, hasKeyValuePair('CartId', 'cart id stub'));
     assertThat($params, hasKeyValuePair('HMAC', 'hmac stub'));
 }
 public function testOperation()
 {
     $CartCreateOperation = $this->app->make('Giftertipster\\Service\\Api\\AmzProductApi\\ApaiIO\\Operations\\CartCreateOperation');
     $CartCreateOperation->addItem('foo bar', 1);
     $CartCreateOperation->addItem('foo bar2', 2);
     $params = $CartCreateOperation->getOperationParameter();
     assertThat($CartCreateOperation->getName(), equalTo('CartCreate'));
     assertThat($params, arrayWithSize(4));
     assertThat($params, hasKeyValuePair('Item.1.OfferListingId', 'foo bar'));
     assertThat($params, hasKeyValuePair('Item.1.Quantity', 1));
     assertThat($params, hasKeyValuePair('Item.2.OfferListingId', 'foo bar2'));
     assertThat($params, hasKeyValuePair('Item.2.Quantity', 2));
 }
 public function testGetUnfulfilledRequests()
 {
     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' => 0, 'delete_type' => 'delete']);
     $repo = $this->app->make('Giftertipster\\Repository\\ProductDeleteRequest\\EloquentProductDeleteRequestRepository');
     $requests = $repo->getUnfulfilledRequests();
     assertThat($requests, not(emptyArray()));
     assertThat($requests[0], hasKeyValuePair('id', 2));
     assertThat($requests[0], hasKeyValuePair('is_fulfilled', 0));
 }
 public function testSubProductForCartAddWorks()
 {
     $sub_product = Factory::create('Giftertipster\\Entity\\Eloquent\\SubProduct', ['id' => 1, 'vendor_id' => 'asin stub', 'offer_listing_id' => 'offer listing id stub']);
     $image = Factory::make('Giftertipster\\Entity\\Eloquent\\Image', ['category' => 'variation']);
     $image2 = Factory::make('Giftertipster\\Entity\\Eloquent\\Image', ['category' => 'primary']);
     $sub_product->images()->save($image);
     $sub_product->images()->save($image2);
     $sub_product2 = Factory::create('Giftertipster\\Entity\\Eloquent\\SubProduct');
     $sub_product_repo = $this->app->make('Giftertipster\\Repository\\SubProduct\\EloquentSubProductRepository');
     $result_sub_product = $sub_product_repo->subProductDataForCartAdd(1);
     assertThat($result_sub_product, hasKeyValuePair('id', 1));
     assertThat($result_sub_product, hasKey('images'));
     assertThat($result_sub_product['images'], not(emptyArray()));
 }
 public function testOperation()
 {
     $CartModifyOperation = $this->app->make('Giftertipster\\Service\\Api\\AmzProductApi\\ApaiIO\\Operations\\CartModifyOperation');
     $CartModifyOperation->setCartId('cart id stub');
     $CartModifyOperation->setHMAC('hmac stub');
     $CartModifyOperation->modifyItem('foo bar', 1);
     $CartModifyOperation->modifyItem('foo bar2', 2);
     $params = $CartModifyOperation->getOperationParameter();
     assertThat($CartModifyOperation->getName(), equalTo('CartModify'));
     assertThat($params, arrayWithSize(6));
     assertThat($params, hasKeyValuePair('CartId', 'cart id stub'));
     assertThat($params, hasKeyValuePair('HMAC', 'hmac stub'));
     assertThat($params, hasKeyValuePair('Item.1.CartItemId', 'foo bar'));
     assertThat($params, hasKeyValuePair('Item.1.Quantity', 1));
     assertThat($params, hasKeyValuePair('Item.2.CartItemId', 'foo bar2'));
     assertThat($params, hasKeyValuePair('Item.2.Quantity', 2));
 }
 public function testMltSearchReturnsResultOnSuccessWithLimit()
 {
     $this->client->index(['index' => $this->product_index, 'type' => $this->product_type, 'id' => 100, 'body' => ['id' => 100, 'title' => 'test product', 'min_price' => 20000, 'max_price' => 20000, 'datetime' => '2014-02-14 00:01:01', 'soft_delete_status' => 0], 'refresh' => true]);
     $this->client->index(['index' => $this->product_index, 'type' => $this->product_type, 'id' => 200, 'body' => ['id' => 200, 'title' => 'test product', 'min_price' => 20000, 'max_price' => 20000, 'datetime' => '2014-02-14 00:01:01', 'soft_delete_status' => 0], 'refresh' => true]);
     $this->client->index(['index' => $this->product_index, 'type' => $this->product_type, 'id' => 300, 'body' => ['id' => 300, 'title' => 'test product', 'min_price' => 20000, 'max_price' => 20000, 'datetime' => '2014-02-14 00:01:01', 'soft_delete_status' => 0], 'refresh' => true]);
     $result = $this->repo->mltSearch(100, 1, ['min_term_freq' => 1, 'min_doc_freq' => 1]);
     assertThat($result, hasKey('results'));
     assertThat($result['results'], not(emptyArray()));
     assertThat($result['results'], not(hasKey(1)));
     assertThat($result['results'][0], not(hasKey('_source')));
     assertThat($result['facets'], emptyArray());
     assertThat($result['results'][0], hasKeyValuePair('_id', 200));
     assertThat($result['meta']['total_hits'], equalTo(2));
 }
Esempio n. 12
0
 public function runAndTestReport($uploadId = 1)
 {
     list($success, $output, $retCode) = $this->runnerCli->run($uploadId, $this->userId, $this->groupId, $jobId = 7);
     assertThat('cannot run runner', $success, equalTo(true));
     assertThat('report failed: "' . $output . '"', $retCode, equalTo(0));
     assertThat($this->getHeartCount($output), greaterThan(0));
     $row = $this->dbManager->getSingleRow("SELECT upload_fk,job_fk,filepath FROM reportgen WHERE job_fk = \$1", array($jobId), "reportFileName");
     assertThat($row, hasKeyValuePair('upload_fk', $uploadId));
     assertThat($row, hasKeyValuePair('job_fk', $jobId));
     $filepath = $row['filepath'];
     assertThat($filepath, endsWith('.rdf'));
     assertThat(file_exists($filepath), equalTo(true));
     $copyrightStatement = '*****@*****.**';
     assertThat(file_get_contents($filepath), stringContainsInOrder($copyrightStatement));
     $this->addToAssertionCount(\Hamcrest\MatcherAssert::getCount() - $this->assertCountBefore);
     $this->verifyRdf($filepath);
     unlink($filepath);
     $this->rmRepo();
 }
 public function testFilterEffectiveEventsOppositeIdenticalEventsOverwriteInOtherOrder()
 {
     $events = array();
     $licenseRef1 = M::mock(ClearingLicense::classname());
     $licenseRef1->shouldReceive("getLicenseId")->withNoArgs()->andReturn("fortyTwo");
     $events[] = $this->createEvent($this->timestamp, $licenseRef1);
     $licenseRef2 = M::mock(ClearingLicense::classname());
     $licenseRef2->shouldReceive("getLicenseId")->withNoArgs()->andReturn("fortyTwo");
     $events[] = $this->createEvent($this->timestamp + 60, $licenseRef2);
     $filteredEvents = $this->clearingEventProcessor->filterEffectiveEvents($events);
     assertThat($filteredEvents, is(arrayWithSize(1)));
     assertThat($filteredEvents, hasKeyValuePair('fortyTwo', $events[1]));
 }
Esempio n. 14
0
 public function testUpdateTable()
 {
     $this->setUpClearingTables();
     $item = new ItemTreeBounds(6, 'uploadtree_a', 1, 17, 18);
     $hash2 = '0x3a910990f114f12f';
     $ctPk = 2;
     $uploadDao = M::mock('Fossology\\Lib\\Dao\\UploadDao');
     $copyrightDao = new CopyrightDao($this->dbManager, $uploadDao);
     $copyrightDao->updateTable($item, $hash2, $content = 'foo', $userId = 55);
     $audit = $this->dbManager->getSingleRow('SELECT * FROM copyright_audit WHERE ct_fk=$1', array($ctPk), __METHOD__ . '.audit');
     assertThat($audit, hasKeyValuePair('ct_fk', $ctPk));
     assertThat($audit, hasKeyValuePair('oldtext', 'modified versions of this software. you must, however, include this copyright statement along with any code built using doc software that you release. no copyright statement needs to be provided if you'));
     assertThat($audit, hasKeyValuePair('user_fk', $userId));
     $updatedCp = $this->dbManager->getSingleRow('SELECT * FROM copyright WHERE ct_pk=$1', array($ctPk), __METHOD__ . '.cp');
     assertThat($updatedCp['content'], is(equalTo($content)));
 }
 public function testGetAdminAddWhenAdminAddTypeIsAdminIdea()
 {
     $this->makeRelatedModels();
     $add = $this->add_repo->create(['product_id' => 1, 'add_type_id' => 1, 'occasion_ids' => [1], 'relation_ids' => [1], 'gender_ids' => [1], 'age_ids' => [1], 'interest_ids' => [1], 'sub_interest_ids' => [1]]);
     $admin_add = $this->add_repo->getAdminAdd(1);
     assertThat($admin_add, hasKeyValuePair('id', 1));
     assertThat($admin_add['occasion_categories'], not(emptyArray()));
     assertThat($admin_add['relation_categories'], not(emptyArray()));
     assertThat($admin_add['gender_categories'], not(emptyArray()));
     assertThat($admin_add['age_categories'], not(emptyArray()));
     assertThat($admin_add['interest_categories'], not(emptyArray()));
     assertThat($admin_add['sub_interest_categories'], not(emptyArray()));
 }
 public function testUpdate()
 {
     $occasion = $this->repo->create('occasion', 'new occasion', 4, 'o, keywords');
     $relation = $this->repo->create('relation', 'new relation', 2, 'r, keywords', null, ['occasion' => [1]]);
     $gender = $this->repo->create('gender', 'new gender', 1, 'g, keywords', null, [], ['relation' => [1]]);
     $interest = $this->repo->create('interest', 'new interest', 1, 'i, keywords');
     $update_relation = $this->repo->update(1, 'relation', 'updated relation', 1, 'ur, keywords', 'ur icon');
     //update
     $update_interest = $this->repo->update(1, 'interest', 'updated interest', 2, 'ui, keywords', 'ui icon', ['gender' => [1]], ['relation' => [1]]);
     //update
     $categories = $this->repo->getCategories();
     assertThat($update_relation, not(identicalTo(false)));
     assertThat($update_interest, not(identicalTo(false)));
     assertThat($categories['occasion_categories'][0], hasKeyValuePair('label', 'new occasion'));
     assertThat($categories['occasion_categories'][0], hasKeyValuePair('priority', 4));
     assertThat($categories['occasion_categories'][0], hasKeyValuePair('keywords', 'o, keywords'));
     assertThat($categories['relation_categories'][0], hasKeyValuePair('label', 'updated relation'));
     assertThat($categories['relation_categories'][0], hasKeyValuePair('priority', 1));
     assertThat($categories['relation_categories'][0], hasKeyValuePair('icon_name', 'ur icon'));
     assertThat($categories['relation_categories'][0]['category_dependency_profile']['categories']['occasion_categories'], emptyArray());
     assertThat($categories['relation_categories'][0], hasKeyValuePair('keywords', 'ur, keywords'));
     assertThat($categories['gender_categories'][0], hasKeyValuePair('label', 'new gender'));
     assertThat($categories['gender_categories'][0], hasKeyValuePair('priority', 1));
     assertThat($categories['gender_categories'][0]['category_exclusion_profile']['categories']['relation_categories'][0], hasKeyValuePair('id', 1));
     assertThat($categories['gender_categories'][0], hasKeyValuePair('keywords', 'g, keywords'));
     assertThat($categories['interest_categories'][0], hasKeyValuePair('label', 'updated interest'));
     assertThat($categories['interest_categories'][0], hasKeyValuePair('priority', 2));
     assertThat($categories['interest_categories'][0], hasKeyValuePair('keywords', 'ui, keywords'));
     assertThat($categories['interest_categories'][0], hasKeyValuePair('icon_name', 'ui icon'));
     assertThat($categories['interest_categories'][0]['category_dependency_profile']['categories']['gender_categories'][0], hasKeyValuePair('id', 1));
     assertThat($categories['interest_categories'][0]['category_exclusion_profile']['categories']['relation_categories'][0], hasKeyValuePair('id', 1));
 }
 public function testFinderCreateReturnsFalseWithErrorsAndRollsbackTransactionWhenAllSubProductsAttributesAreInvalid()
 {
     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' => '', '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' => [], 'features' => [], 'descriptions' => [], 'variations' => [['type' => 'foobar', 'value' => 'foobar']]];
     $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' => '', 'condition' => 'test condition', 'department' => 'test department', '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' => [], 'features' => [], 'descriptions' => [], 'variations' => [['type' => 'foobar', 'value' => 'foobar']]];
     $suite_attributes['keyword_profile']['profile'] = [];
     $repo = $this->app->make('Giftertipster\\Repository\\ProductSuite\\EloquentProductSuiteRepository');
     $response = $repo->finderCreate($suite_attributes, 'Idea', 1, 2);
     $errors = $repo->errors();
     assertThat($response, identicalTo(false));
     $eloquent_product = $this->app->make('Giftertipster\\Entity\\Eloquent\\Product');
     $product = $eloquent_product->find(1);
     $eloquent_sub_product = $this->app->make('Giftertipster\\Entity\\Eloquent\\SubProduct');
     $sub_product = $eloquent_sub_product->where('product_id', '=', 1)->get()->toArray();
     assertThat($errors, notNullValue());
     assertThat($errors, anInstanceOf('\\Illuminate\\Support\\MessageBag'));
     assertThat($errors->all(), arrayWithSize(2));
     assertThat($errors->get('sub_products_failure_product_id'), hasKeyValuePair(0, 1));
     assertThat($product, nullValue());
     assertThat($sub_product, arrayWithSize(0));
 }
 public function testGetAdminsWithProfile()
 {
     \Artisan::call('db:seed');
     //user 1 comes from db:seed
     $user1 = \Giftertipster\Entity\Eloquent\User::find(1);
     $user2 = Factory::create('Giftertipster\\Entity\\Eloquent\\User', ['permissions' => ['test']]);
     $user3 = Factory::create('Giftertipster\\Entity\\Eloquent\\User', ['permissions' => ['test']]);
     //seed user profile for user 1
     $user1_profile = $user1->user_profile()->get()->first();
     $user1_profile->first_name = 'foobar';
     $user1_profile->save();
     $result = $this->repo()->getAdminsWithProfile();
     assertThat($result, arrayWithSize(3));
     assertThat($result[0], hasKeyValuePair('id', 1));
     assertThat($result[0]['user_profile'][0]['first_name'], equalTo('foobar'));
     assertThat($result[1], hasKeyValuePair('id', 2));
     assertThat($result[1]['user_profile'], identicalTo([]));
     assertThat($result[2], hasKeyValuePair('id', 3));
     assertThat($result[2]['user_profile'], identicalTo([]));
 }
 public function testGetRefreshedIdRange()
 {
     $seed_product = Factory::create('Giftertipster\\Entity\\Eloquent\\Product', ['group' => 'bar1', 'is_refreshed' => 0]);
     $seed_product2 = Factory::create('Giftertipster\\Entity\\Eloquent\\Product', ['group' => 'bar2', 'is_refreshed' => 1]);
     $product = $this->app->make('Giftertipster\\Repository\\Product\\EloquentProductRepository');
     $products = $product->getRefreshedIdRange(1, null, 2);
     assertThat($products[0], hasKeyValuePair('id', 2));
 }
 public function testHasReadableDescription()
 {
     $this->assertDescription('array containing ["a" => <2>]', hasKeyValuePair(equalTo('a'), equalTo(2)));
 }
 public function testFilteredProductsWithAllFiltersWorks()
 {
     $seed_product = Factory::create('Giftertipster\\Entity\\Eloquent\\Product', ['group' => 'foo', 'min_price_amount' => 50, 'max_price_amount' => 50]);
     $seed_product2 = Factory::create('Giftertipster\\Entity\\Eloquent\\Product', ['group' => 'bar', 'min_price_amount' => 150, 'max_price_amount' => 150]);
     $seed_product3 = Factory::create('Giftertipster\\Entity\\Eloquent\\Product', ['group' => 'foobar']);
     $seed_image1 = Factory::create('Giftertipster\\Entity\\Eloquent\\Image', ['imageable_id' => 1, 'imageable_type' => 'Giftertipster\\Entity\\Eloquent\\Product']);
     $seed_image2 = Factory::create('Giftertipster\\Entity\\Eloquent\\Image', ['imageable_id' => 2, 'imageable_type' => 'Giftertipster\\Entity\\Eloquent\\Product']);
     $categories_filter = new CategoriesFilter();
     $categories_filter->categories(['foo', 'bar']);
     $price_range_filter = new PriceRangeFilter();
     $price_range_filter->minPrice(5)->maxPrice(100);
     $product = $this->app->make('Giftertipster\\Repository\\ProductSuite\\EloquentProductSuiteRepository');
     $products = $product->filteredProducts([$categories_filter, $price_range_filter]);
     assertThat($products, arrayWithSize(1));
     assertThat($products[0], hasKeyValuePair('id', 1));
     assertThat($products[0]['images'], not(emptyArray()));
 }