/** @test */ public function itProvideAResponseDefinition() { $responseDefinition = $this->prophesize(ResponseDefinition::class); $responseDefinition->getStatusCode()->willReturn(200); $requestDefinition = new RequestDefinition('GET', 'getFoo', '/foo/{id}', new Parameters([]), ['application/json'], [$responseDefinition->reveal()]); assertThat($requestDefinition->getResponseDefinition(200), self::isInstanceOf(ResponseDefinition::class)); }
public function testMakeReturnsExpectedQueryWithPollTypeBoostAndFieldSimularitiesAndFieldValueBoost() { $this->query_params = ['gender' => 'male', 'occasion' => 'birthday']; $this->expected_query = ['has_child' => ['type' => 'add', 'score_type' => 'sum', 'query' => ['function_score' => ['query' => ['bool' => ['should' => [['term' => ['gender' => ['value' => 'male', 'boost' => 1]]], ['term' => ['occasion' => ['value' => 'anniversary', 'boost' => 2.0]]], ['term' => ['occasion' => ['value' => 'birthday', 'boost' => 4]]]]]], 'functions' => [['filter' => ['term' => ['add_type' => 'detail_view']], 'boost_factor' => 1.2]]]]]]; $result = $this->gen->make($this->query_params, $this->search_type_config); assertThat($result, equalTo($this->expected_query)); }
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)); }
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)); }
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 testRenderContentTextConvertsToUtf8() { $this->pagedTextResult->appendContentText("äöü"); $expected = htmlspecialchars("äöü", ENT_SUBSTITUTE, 'UTF-8'); assertThat($this->pagedTextResult->getText(), is(equalTo($expected))); $this->addToAssertionCount(1); }
public function testEvaluatesToTrueIfArgumentIsReferenceToASpecifiedObject() { $o1 = new stdClass(); $o2 = new stdClass(); assertThat($o1, identicalTo($o1)); assertThat($o2, not(identicalTo($o1))); }
public function testInitializeDirsAndFiles() { /** * dirs and files to create. */ $dirs = [__DIR__ . '/../../../sql', __DIR__ . '/../../../.dbup/applied', __DIR__ . '/../../../.dbup']; $files = [__DIR__ . '/../../../sql/V1__sample_select.sql', __DIR__ . '/../../../.dbup/properties.ini']; /** * cleaner the created files and dirs. */ $clean = function () use($dirs, $files) { foreach ($files as $file) { @unlink($file); } foreach ($dirs as $dir) { @rmdir($dir); } }; $clean(); $application = new Application(); $application->add(new InitCommand()); $command = $application->find('init'); $commandTester = new CommandTester($command); $commandTester->execute(['command' => $command->getName()]); foreach ($dirs as $dir) { assertThat(is_dir($dir), is(true)); } foreach ($files as $file) { assertThat(file_exists($file), is(true)); } $clean(); }
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)); }
/** * @test */ public function replace_PhraseWithTwoWordsAndAllWordsExistingInDictionary_ReturnsTranslation() { $dictionary = [$word = 'snow' => 'white watering', $wordB = 'sun' => 'hot lighting']; $this->replacer->setDictionary($dictionary); $result = $this->replacer->replace("It's \${$word}\$ outside and \${$wordB}\$"); assertThat($result, is(equalTo("It's white watering outside and hot lighting"))); }
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)); }
public function testMatchesArrayContainingKeyWithNumberKeys() { $array = array(1 => 'A', 2 => 'B'); assertThat($array, hasKey(1)); // very ugly version! assertThat($array, IsArrayContainingKey::hasKeyInArray(2)); }
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')); }
public function testIsHtmlAndNoWarningFound() { assertThat($this->pageContent, startsWith('<!DOCTYPE html>')); $this->assertCriticalStringNotfound('PHP Notice'); $this->assertCriticalStringNotfound('PHP Fatal error'); $this->assertCriticalStringNotfound('PHP Warning'); }
public function testEvaluatesToTrueIfArgumentIsReferenceToASpecifiedObject() { $o1 = new \stdClass(); $o2 = new \stdClass(); assertThat($o1, sameInstance($o1)); assertThat($o2, not(sameInstance($o1))); }
public function testCategoriesMethodSetsConditionsWhenUsingMultipleCategories() { $filter = $this->app->make('Giftertipster\\Entity\\ProductSearchFilter\\CategoriesFilter'); $filter->categories(['foo', 'bar']); $expected_conditions = [['group', '=', 'foo'], ['group', '=', 'bar']]; assertThat($filter->conditions(), equalTo($expected_conditions)); }
public function testSetHostToCreateNewGallery() { $model = new RemoteModelStub(); $model->setHost('Flickr'); $gallery = $model->newModel(); assertThat($gallery, is(anInstanceOf('PullAutomaticallyGalleries\\RemoteApi\\RemoteApiModelInterface'))); }
/** * @test */ public function Converter2() { $converter = new MorzeConverter(); $res = $converter->recursiveParse('. .-.. .-.. --- .-- --- .-. .-.. -..'); // $res = $converter->recursiveParse('twig map asdfasdf'); assertThat($res, is('elloworld')); }
/** @test */ public function itProvideARequestDefinition() { $requestDefinition = $this->prophesize(RequestDefinition::class); $requestDefinition->getOperationId()->willReturn('getFoo'); $requestDefinitions = new RequestDefinitions([$requestDefinition->reveal()]); assertThat($requestDefinitions->getRequestDefinition('getFoo'), self::isInstanceOf(RequestDefinition::class)); }
public function testAppendMetaAndContentText() { $this->pagedResult->appendMetaText(self::META_TEXT); $this->pagedResult->appendContentText(self::CONTENT_TEXT); assertThat($this->pagedResult->getCurrentOffset(), is(self::START_OFFSET + strlen(self::CONTENT_TEXT))); assertThat($this->pagedResult->getText(), is(self::META_TEXT . self::CONTENT_TEXT)); }
public function testShowFolderTreeWithContent() { $res = $this->prepareShowFolderTree($parentFolderId = 'foo'); $this->dbManager->shouldReceive('fetchArray')->with($res)->andReturn($rowTop = array('folder_pk' => 1, 'folder_name' => 'Top', 'folder_desc' => '', 'depth' => 0), $rowA = array('folder_pk' => 2, 'folder_name' => 'B', 'folder_desc' => '/A', 'depth' => 1), $rowB = array('folder_pk' => 3, 'folder_name' => 'B', 'folder_desc' => '/A/B', 'depth' => 2), $rowC = array('folder_pk' => 4, 'folder_name' => 'C', 'folder_desc' => '/C', 'depth' => 1), false); $out = $this->folderNav->showFolderTree($parentFolderId); assertThat(str_replace("\n", '', $out), equalTo('<ul id="tree"><li>' . $this->getFormattedItem($rowTop) . '<ul><li>' . $this->getFormattedItem($rowA) . '<ul><li>' . $this->getFormattedItem($rowB) . '</li></ul></li><li>' . $this->getFormattedItem($rowC) . '</li></ul></li></ul>')); }
public function testMockToStringShouldIgnoreMissingAlwaysReturnsString() { $mock = $this->container->mock('ClassWithNoToString')->shouldIgnoreMissing(); assertThat(isNonEmptyString((string) $mock)); $mock->asUndefined(); assertThat(isNonEmptyString((string) $mock)); }
public function testCreateRouterFromController() { $controller = new Fixtures\ProductController(); $router = $controller->getRouter(); assertThat($router->getStaticRoutes(), is(equalTo(['' => ['GET' => ['Rootr\\Fixtures\\ProductController', 'indexAction']]]))); assertThat($router->getVariableRoutes(), is(equalTo(['/(\\d+)' => ['GET' => [['Rootr\\Fixtures\\ProductController', 'showAction'], ['id']]], '/delete/([^/]+)' => ['DELETE' => [['Rootr\\Fixtures\\ProductController', 'deleteAction'], ['id']]]]))); }
public function testGetProfileStringwhenNullIsProvided() { $expected_keyword_string = ''; $service = $this->app->make('Giftertipster\\Service\\KeywordProfile\\KeywordProfileGenerator'); $result = $service->getProfileString(null); assertThat($result, equalTo($expected_keyword_string)); }
public function testDiffByKeyWithNonDefaultKey() { $collectionStub = ModelStub::all(); $diff = $this->collection->diffByKey($collectionStub, 'name'); $diffNames = $diff->lists('name'); assertThat($diffNames, is(equalTo(['Taylor Otwell']))); }
public function testProductDetailsAreExtractedCorrectly() { $search_results_fixture = new stdClass(); $search_results_fixture->body = ' <div id="atfResults"> <ul> <li> <fig> <article class="acs-carousel-header"></article> </fig> </li> <li> <img class="s-access-image" src="/latte-cup.jpg" /> <a href="/latte-cup" class="s-access-detail-page"> <h2>Best latte cup</h2> </a> <span class="s-price">$12.05</span> </li> </ul> </div> '; $product_page_fixture = new stdClass(); $product_page_fixture->body = "\n <div id=\"productDescription\">\n <p>\n <div><img src=\"/some/image.jpg\" /></div>\n <p style=\"margin: 1em\">\t \n </p>\n <p>The best latte cup you will ever drink latte from. Period.</p>\n </p>\n </div>\n "; $Http = m::mock('Requests_Session'); // Mock HTTP request to product page $Http->shouldReceive('get')->with('/latte-cup')->once()->andReturn($product_page_fixture); // Mock HTTP request to search results $Http->shouldReceive('get')->once()->andReturn($search_results_fixture); $Amazon = new Amazon($Http); $Product = $Amazon->findOneProductByKeyword('latte cup'); assertThat($Product->title, is('Best latte cup')); assertThat($Product->price, is('$12.05')); assertThat($Product->image_uri, is('/latte-cup.jpg')); assertThat($Product->description, is('<p>The best latte cup you will ever drink latte from. Period. </p>')); }
public function testShouldPrintInformationAboutCommunication() { $request = new Request('irrelevant url'); $response = new Response(); $response->statusCode = 200; assertThat($this->getLog($request, $response), allOf(containsString($request->method), containsString($request->url), containsString((string) $response->statusCode))); }
/** * @test */ function isApplied_() { assertThat($this->table->isApplied("987654"), isFalse()); $this->table->fixVersion("987654"); assertThat($this->table->isApplied("987654"), isTrue()); assertThat($this->table->isApplied("123456"), isFalse()); }
public function testEvaluatesToFalseIfArgumentDoesntMatchType() { assertThat(false, not(numericValue())); assertThat('foo', not(numericValue())); assertThat('foo5', not(numericValue())); assertThat('5foo', not(numericValue())); }
public function testMakeBucketLabelReturnsExpectedResponseWhenMaxIsNull() { $expected_response = '$10 +'; $bucket = ['min' => 1000, 'max' => null]; $response = $this->labeler->makeBucketLabel($bucket); assertThat($response, identicalTo($expected_response)); }