public function testMixedEncodingStartingWithLatin1IsConvertedAndCoercedToUtf8()
 {
     $inputString = iconv("UTF-8", "ISO-8859-15", $this->testString);
     $inputString .= $this->testString;
     $outputString = $this->converter->convert($inputString);
     assertThat($outputString, startsWith($this->testString));
     assertThat(strlen($outputString), is(greaterThan(2 * strlen($this->testString))));
 }
 /**
  * @expectedException Mockery\Exception
  */
 public function testGreaterThanConstraintNotMatchesArgument()
 {
     $this->mock->shouldReceive('foo')->with(greaterThan(1))->once();
     $this->mock->foo(1);
     $this->container->mockery_verify();
 }
 public function testDeleteProductAndAddsReturnsTrueOnSuccessAndDeletesDoc()
 {
     $doc_id = 100;
     $this->repo->index(['_id' => $doc_id, 'title' => 'test product', 'min_price' => 20000, 'max_price' => 20000, 'datetime' => '2014-02-14 00:01:01', 'soft_delete_status' => 0], true);
     //true to refreh index
     $this->client->index(['index' => $this->add_index, 'type' => $this->add_type, 'id' => 1, 'parent' => $doc_id, 'body' => ['gender_id' => 1], 'refresh' => true]);
     //assert that product is indexed
     $result = $this->repo->keywordSearch('test product', 0, 100);
     assertThat($result, hasKey('results'));
     assertThat($result['results'], not(emptyArray()));
     //assert that add is indexed
     $result = $this->client->search(['index' => $this->add_index, 'type' => $this->add_type, 'body' => ['query' => ['filtered' => ['filter' => ['type' => ['value' => $this->add_type]]]]]]);
     assertThat($result['hits']['total'], greaterThan(0));
     //delete product and adds
     $result = $this->repo->deleteProductAndAdds($doc_id);
     //true to refresh index
     //assert that product is no longer indexed
     $result = $this->repo->keywordSearch('test product', 0, 100);
     assertThat($result, hasKey('results'));
     assertThat($result['results'], emptyArray());
     //assert that add is no longer indexed
     $result = $this->client->search(['index' => $this->add_index, 'type' => $this->add_type, 'body' => ['query' => ['filtered' => ['filter' => ['type' => ['value' => $this->add_type]]]]]]);
     assertThat($result['hits']['total'], equalTo(0));
 }
Exemplo n.º 4
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 testSupportsDifferentTypesOfComparableValues()
 {
     assertThat(1.1, greaterThan(1.0));
     assertThat("cc", greaterThan("bb"));
 }
Exemplo n.º 6
0
 public function testAcceptsAndRejectsThreeOrs()
 {
     $orTriple = $this->_either_3_or_4->orElse(greaterThan(10));
     assertThat(11, $orTriple);
     assertThat(9, not($orTriple));
 }
 public function testUsesDescriptionOfNegatedMatcherWithPrefix()
 {
     $this->assertDescription('not a value greater than <2>', not(greaterThan(2)));
     $this->assertDescription('not "A"', not('A'));
 }
 public function testDeletePermDeletesRelatedAddsAndAddCategoryRelationships()
 {
     $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();
     //create related add
     Factory::create('Giftertipster\\Entity\\Eloquent\\AddType');
     Factory::create('Giftertipster\\Entity\\Eloquent\\Product');
     $add_repo = $this->app->make('Giftertipster\\Repository\\Add\\AddRepositoryInterface');
     $add_repo->create(['product_id' => 1, 'add_type_id' => 1, 'occasion_ids' => [1, 2], 'relation_ids' => [1], 'gender_ids' => [1], 'age_ids' => [1], 'interest_ids' => [1], 'sub_interest_ids' => [1]]);
     $add = $this->app->make('Giftertipster\\Entity\\Eloquent\\Add');
     $add_collection = $add->where('product_id', '=', 1)->get();
     $add_count = $add_collection->count();
     assertThat($add_count, greaterThan(0));
     $response = $data_repo->deletePerm(1);
     $add_collection = $add->where('product_id', '=', 1)->get();
     $add_count = $add_collection->count();
     assertThat($add_count, identicalTo(0));
     $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));
 }
Exemplo n.º 9
0
 public function testgetNumItemsPerSec()
 {
     $numSecs = 30;
     $testFilesPerSec = $this->showJobsDao->getNumItemsPerSec(5 * $numSecs, $numSecs);
     assertThat($testFilesPerSec, is(greaterThan(1)));
     $testFilesPerSec = $this->showJobsDao->getNumItemsPerSec(0.9 * $numSecs, $numSecs);
     assertThat($testFilesPerSec, is(lessThanOrEqualTo(1)));
 }
 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 testValidateSuiteAttributesForCreateReturnsFalseWhenCategoryKeywordsKeyIsMissing()
 {
     $stub = $this->suite_attributes_stub;
     unset($stub['category_keywords']);
     $response = $this->validator->validateSuiteAttributesForCreate($stub);
     assertThat($response, identicalTo(false));
     assertThat($this->validator->errors(), arrayWithSize(greaterThan(0)));
 }