/** * @Then /^(?:|I )should not reach my rate limit$/ */ public function iShouldNotReachMyRateLimit() { $remainingCalls = $this->client->getHttpClient()->remainingCalls; assertNotNull($remainingCalls); assertTrue(5000 > $remainingCalls); assertTrue(0 < $remainingCalls); }
public function testState() { assertNull($this->objMath->getFirstOperand()); assertNull($this->objMath->getSecondOperand()); assertNull($this->objMath->getFirstOperator()); assertNull($this->objMath->getSecondOperator()); assertFalse( $this->objMath->validate() ); $this->objMath->setFirstOperand('5'); $this->objMath->setFirstOperator('+'); $this->objMath->setSecondOperand('2'); assertNotNull($this->objMath->getFirstOperand()); assertNotNull($this->objMath->getSecondOperand()); assertNotNull($this->objMath->getFirstOperator()); assertNotNull($this->objMath->getSecondOperator()); assertTrue( $this->objMath->validate() ); $this->objMath->clear( ); assertNull($this->objMath->getFirstOperand()); assertNull($this->objMath->getSecondOperand()); assertNull($this->objMath->getFirstOperator()); assertNull($this->objMath->getSecondOperator()); }
/** * Checks that a file (or media) exists in database * * @param string $originalFilename * * @Then /^The file with original filename "([^"]*)" should exists in database$/ */ public function theFileShouldExistInDatabase($originalFilename) { $fileInfoRepoClass = $this->getParameter('akeneo_file_storage.model.file_info.class'); $fileInfoRepository = $this->getRepository($fileInfoRepoClass); $fileInfo = $fileInfoRepository->findOneBy(['originalFilename' => $originalFilename]); assertNotNull($fileInfo, sprintf('Unable to find file with original filename "%s" in database', $originalFilename)); }
/** * @Given /^I add the "([^"]*)" mailinglist to the "([^"]*)" page$/ */ public function iAddTheMailinglistToThePage($mailinglistTitle, $pageUrl) { $mailinglist = \MailingList::get()->filter('Title', $mailinglistTitle)->First(); assertNotNull($mailinglist, 'Could not find MailingList with ' . $mailinglistTitle); $page = \SubscriptionPage::get()->filter('URLSegment', $pageUrl)->First(); assertNotNull($page); $lists = $page->MailingLists ? explode(',', $page->MailingLists) : array(); $lists[] = $mailinglist->ID; $page->MailingLists = implode(',', $lists); $page->write(); $page->publish('Stage', 'Live'); }
/** * Loads user data via open social api * * @param string $userName * @return array $userData * @throws Exception in case user cannot be retrieved * for testing deprovisioning also */ protected function _loadUserDataViaOpenSocialApi($userName) { $url = self::TEST_OPEN_SOCIAL_API_URL . self::TEST_IDP_DOMAIN . ':' . $userName . '?fields=all'; $this->getMainContext()->getSession()->visit($url); $userDataJson = $this->getMainContext()->getSession()->getPage()->getContent(); $statusCode = $this->getMainContext()->getSession()->getStatusCode(); assertEquals($statusCode, 200, 'Connecting to Open Social API failed with status ' . $statusCode); $resultData = json_decode($userDataJson, true); $userData = current($resultData['entry']); $isUserFound = is_array($userData) && array_key_exists('id', $userData); assertNotNull($isUserFound, 'User ' . $userName . ' Could not be retrieved from via Open Social Api'); return $userData; }
/** * @Given /^I should be able to select "([^"]*)" from the WAYF$/ */ public function iShouldBeAbleToSelectFromTheWayf($guestIdp) { $button = $this->getMainContext()->getSession()->getPage()->findButton($guestIdp); assertNotNull($button); }
/** * @Then the cachecontrol header should include the shared maxage directive for shared caches */ public function theCachecontrolHeaderShouldIncludeTheSharedMaxageDirectiveForSharedCaches() { $rawCacheControl = $this->getSession()->getResponseHeader('cache-control'); assertNotNull($rawCacheControl, 'I\'m not able to find the cache-control header!'); assertContains('s-maxage', $rawCacheControl, 'The cache-control header should include the "s-maxage" directive!'); }
/** * @Given /^I should( not? |\s*)see a "([^"]*)" field$/ */ public function iShouldSeeAField($negative, $text) { $page = $this->getSession()->getPage(); $els = $page->findAll('named', array('field', "'{$text}'")); $matchedEl = null; foreach ($els as $el) { if ($el->isVisible()) { $matchedEl = $el; } } if (trim($negative)) { assertNull($matchedEl); } else { assertNotNull($matchedEl); } }
/** * @Then /^I should see (\d+) rows in the table$/ */ public function iShouldSeeRowsInTheTable($rows) { $table = $this->getPage()->find('css', '.main-content table'); assertNotNull($table, 'Cannot find a table!'); assertCount(intval($rows), $table->findAll('css', 'tbody tr')); }
<?php // Get the test nodes $node = $_ALF_MODEL["testNode"]; assertNotNull($node, "testNode model value was found to be null"); $folder = $_ALF_MODEL["testFolder"]; assertNotNull($folder, "testFolder model value was found to be null"); // Test changing the properties of the node $node->cm_name = "changed.txt"; $node->cm_author = "Mr Trouble"; // Add aspect $node->addAspect("cm_titled", array("cm_title" => "my title", "cm_description" => "my description")); // Remove aspect $node->removeAspect("cm_versionable"); // Create a child node $newNode1 = $folder->createChild("cm_content", "cm_contains", "cm_file.txt"); $newNode1->cm_name = "file.txt"; $newNode1->addAspect("sys_referenceable", array()); // Create another child node $newNode2 = $folder->createChild("cm_folder", "cm_contains", "cm_testFolder"); $newNode2->cm_name = "testFolder"; // Add a non-primary child $newNode2->addChild($node, "cm_contains", "cm_myNode"); // Associate the two nodes together $newNode1->addAssociation($newNode2, "cm_references"); // Save the changes made $_ALF_SESSION->save(); // Check the node have the correct values after the save assertEquals("changed.txt", $node->cm_name); assertEquals("Mr Trouble", $node->cm_author); assertTrue($node->hasAspect("cm_titled"));
<?php // Tests the Alfresco debug methods // TODO figure out how to test the failures .. assertEquals("value", "value"); assertEquals(1, 1); $value = new Repository(); assertNotNull($value); assertTrue(true); assertFalse(false);
/** * Scroll to a certain element by CSS selector. * Requires an "id" attribute to uniquely identify the element in the document. * * Example: Given I scroll to the ".css_element" element * * @Given /^I scroll to the "(?P<locator>(?:[^"]|\\")*)" element$/ */ public function iScrollToElement($locator) { $el = $this->getSession()->getPage()->find('css', $locator); assertNotNull($el, sprintf('The element "%s" is not found', $locator)); $id = $el->getAttribute('id'); if (empty($id)) { throw new \InvalidArgumentException('Element requires an "id" attribute'); } $js = sprintf("document.getElementById('%s').scrollIntoView(true);", $id); $this->getSession()->executeScript($js); }
/** * Workaround for chosen.js dropdowns or tree dropdowns which hide the original dropdown field. * * @When /^(?:|I )fill in the "(?P<field>(?:[^"]|\\")*)" dropdown with "(?P<value>(?:[^"]|\\")*)"$/ * @When /^(?:|I )fill in "(?P<value>(?:[^"]|\\")*)" for the "(?P<field>(?:[^"]|\\")*)" dropdown$/ */ public function theIFillInTheDropdownWith($field, $value) { $field = $this->fixStepArgument($field); $value = $this->fixStepArgument($value); $nativeField = $this->getSession()->getPage()->find('named', array('select', $this->getSession()->getSelectorsHandler()->xpathLiteral($field))); if ($nativeField && $nativeField->isVisible()) { $nativeField->selectOption($value); return; } // Given the fuzzy matching, we might get more than one matching field. $formFields = array(); // Find by label $formField = $this->getSession()->getPage()->findField($field); if ($formField && $formField->getTagName() == 'select') { $formFields[] = $formField; } // Fall back to finding by title (for dropdowns without a label) if (!$formFields) { $formFields = $this->getSession()->getPage()->findAll('xpath', sprintf('//*[self::select][(./@title="%s")]', $field)); } // Find by name (incl. hidden fields) if (!$formFields) { $formFields = $this->getSession()->getPage()->findAll('xpath', "//*[@name='{$field}']"); } // Find by label if (!$formFields) { $label = $this->getSession()->getPage()->find('xpath', "//label[.='{$field}']"); if ($label && ($for = $label->getAttribute('for'))) { $formField = $this->getSession()->getPage()->find('xpath', "//*[@id='{$for}']"); if ($formField) { $formFields[] = $formField; } } } assertGreaterThan(0, count($formFields), sprintf('Chosen.js dropdown named "%s" not found', $field)); // Traverse up to field holder $container = null; foreach ($formFields as $formField) { $container = $this->findParentByClass($formField, 'field'); if ($container) { break; } // Default to first visible container } assertNotNull($container, 'Chosen.js field container not found'); // Click on newly expanded list element, indirectly setting the dropdown value $linkEl = $container->find('xpath', './/a[./@href]'); assertNotNull($linkEl, 'Chosen.js link element not found'); $this->getSession()->wait(100); // wait for dropdown overlay to appear $linkEl->click(); if (in_array('treedropdown', explode(' ', $container->getAttribute('class')))) { // wait for ajax dropdown to load $this->getSession()->wait(5000, "window.jQuery && " . "window.jQuery('#" . $container->getAttribute('id') . " .treedropdownfield-panel li').length > 0"); } else { // wait for dropdown overlay to appear (might be animated) $this->getSession()->wait(300); } $listEl = $container->find('xpath', sprintf('.//li[contains(normalize-space(string(.)), \'%s\')]', $value)); if (null === $listEl) { throw new \InvalidArgumentException(sprintf('Chosen.js list element with title "%s" not found', $value)); } $listLinkEl = $listEl->find('xpath', './/a'); if ($listLinkEl) { $listLinkEl->click(); } else { $listEl->click(); } }
/** * @Then /^the password for "([^"]*)" should be "([^"]*)"$/ */ public function stepPasswordForEmailShouldBe($id, $password) { $member = \Member::get()->filter('Email', $id)->First(); assertNotNull($member); assertTrue($member->checkPassword($password)->valid()); }
<?php // Tests the global values set my the script/template engine, both those added by the // engine and those added from the model // Check the repository value assertNotNull($_ALF_REPOSITORY, "_ALF_REPOSITORY was found to be null"); $newSession = $_ALF_REPOSITORY->createSession(); assertNotNull($newSession, "newSession was found to be null"); // Check the session value assertNotNull($_ALF_SESSION, "_ALF_SESSION was found to be null"); assertNotNull($_ALF_SESSION->stores); assertNotNull($_ALF_SESSION->ticket); // Check that the model is present assertNotNull($_ALF_MODEL, "_ALF_MODEL was found to be null"); // Check the node value set in the model and passed through assertNotNull($_ALF_MODEL["testNode"], "testNode was found to be null"); assertEquals($_ALF_MODEL["nodeId"], $_ALF_MODEL["testNode"]->id); // Check the store ref value passed through assertNotNull($_ALF_MODEL["testStore"], "testStore was found to be null"); assertEquals($_ALF_MODEL["storeId"], $_ALF_MODEL["testStore"]->address); // Check the other values set in the model assertEquals("testString", $_ALF_MODEL["testString"]); assertEquals(1.0, $_ALF_MODEL["testNumber"]);
$node->cm_author = "Ms Sunshine"; assertEquals("test3.txt", $node->cm_name); assertEquals("Ms Sunshine", $node->cm_author); // Check add and remove aspect $node->addAspect("cm_titled", array("cm_title" => "my title", "cm_description" => "my description")); assertTrue($node->hasAspect("cm_titled")); assertTrue(in_array("{http://www.alfresco.org/model/content/1.0}titled", $node->aspects)); assertEquals("my title", $node->cm_title); assertEquals("my description", $node->cm_description); $node->removeAspect("cm_versionable"); assertFalse($node->hasAspect("cm_versionable")); assertFalse(in_array("{http://www.alfresco.org/model/content/1.0}versionable", $node->aspects)); // Check create node $newNode = $folder->createChild("cm_folder", "cm_contains", "{http://www.alfresco.org/model/content/1.0}My Test Folder"); $newNode->cm_name = "My Test Folder"; assertNotNull($newNode); assertEquals(3, count($folder->children)); assertEquals(1, count($newNode->parents)); $newChildAssoc = $folder->children[2]; assertEquals($folder->__toString(), $newChildAssoc->parent->__toString()); assertEquals($newNode->__toString(), $newChildAssoc->child->__toString()); assertEquals("{http://www.alfresco.org/model/content/1.0}contains", $newChildAssoc->type); assertEquals("{http://www.alfresco.org/model/content/1.0}My Test Folder", $newChildAssoc->name); assertTrue($newChildAssoc->isPrimary); assertEquals("{http://www.alfresco.org/model/content/1.0}folder", $newNode->type); assertEquals("My Test Folder", $newNode->cm_name); assertTrue(strpos($newNode->id, 'new_') !== false); // Add child $folder->addChild($node, "cm_contains", "cm_summertOrNuffin"); assertEquals(4, count($folder->children)); assertEquals(2, count($node->parents));
/** * @test */ public function instantiateWithLoadCreatesHandle() { $image = Image::load($this->testPath . 'empty.png'); assertNotNull($image->handle()); }
public function test_it_toggles_page_version_preview_share() { $this->PageVersionManager->togglePageVersionPreviewShare(1); $version = \DvsPageVersion::find(1); assertNotNull($version->preview_hash); }
/** * @Given /^data is not null$/ */ public function dataNotNull() { $results = $this->getResponsePayload(); assertNotNull($results->data); }
assertTrue($node->hasAspect("cm_titled")); assertNotNull($node->cm_title, "title property is null"); // Make a copy $copy = $node->copy($folder, "cm_contains", "cm_copy1", true); assertNotNull($copy); assertEquals($node->cm_title, $copy->cm_title); // Make a change and try and copy $node->cm_title = "My Other Title"; // TODO .. need to figure out how exceptions can be caught and handled if required //try //{ // $copy2 = $node->copy($folder, "cm_contains", "cm_copy2", true); // fail("Should not be allowed to copy a node if there are outstanding changes."); //} //catch (Exception $e) //{ // Expected //} // Save the changes and make sure we can now copy the node $_ALF_SESSION->save(); $copy3 = $node->copy($folder, "cm_contains", "cm_copy3", true); assertNotNull($copy3); assertEquals($node->cm_title, $copy3->cm_title); // Create another folder to move the node into $destination = $folder->createChild("cm_folder", "cm_contains", "cm_destination"); $destination->cm_name = "destination"; $_ALF_SESSION->save(); // Do the move assertEquals($folder->__toString(), $copy->primaryParent->__toString(), "Copy has unexpected initial primary parent"); $copy->move($destination, "cm_contains", "cm_move1"); assertEquals($destination->__toString(), $copy->primaryParent->__toString(), "Moved copy does not have the expected primary parent");
public function remove($o){ $this->assertClass($o); $key = $this->toHBaseKey($o); assertNotNull($key); $this->h->deleteAllRow($this->table, $key); }
/** * @Then /^I should see "([^"]+)" on page headline$/ */ public function iShouldSeeTextOnPageHeadline($text) { assertNotNull($this->find('xpath', '//h1[contains(., "' . $text . '")]'), "Text '{$text}' was not found on page headline"); }
/** * @Then /^I should see the "([^"]*)" tab$/ */ public function iShouldSeeTheTab($tab) { assertNotNull($this->getCurrentPage()->getFormTab($tab)); }
/** @test */ public function it_builds_and_persists_attributes() { $post = TestDummy::create('Post'); assertInstanceOf('Post', $post); assertNotNull($post->id); }
/** * @param string $attribute * @param string $family * @param string $channel * * @Given /^attribute "([^"]*)" should be optional in family "([^"]*)" for channel "([^"]*)"$/ */ public function attributeShouldBeOptionalInFamilyForChannel($attribute, $family, $channel) { $requirement = $this->getAttributeRequirement($attribute, $family, $channel); assertNotNull($requirement); assertFalse($requirement->isRequired()); }
<?php // Get the test nodes $folder = $_ALF_MODEL["testFolder"]; assertNotNull($folder, "testFolder model value was found to be null"); $node = $folder->createChild("cm_content", "cm_contains", "cm_myFile.txt"); $node->cm_name = "myFile.txt"; $contentData = $node->cm_content; assertNull($contentData, "No content data has been set so should be null"); $contentData2 = $node->updateContent("cm_content", "text/plain", "UTF-8", null); assertNotNull($contentData2, "The newly created content data is unexpectedly null"); assertEquals("text/plain", $contentData2->mimetype); assertEquals("UTF-8", $contentData2->encoding); assertNull($contentData2->content); $contentData2->content = "this is some content"; $contentData3 = $node->cm_content; assertNotNull($contentData3, "content data 3 was null"); assertEquals("this is some content", $contentData3->content, "content was incorrect before save"); $_ALF_SESSION->save(); $contentData4 = $node->cm_content; assertNotNull($contentData4, "content data 4 was null"); assertEquals("this is some content", $contentData4->content, "content was incorrect after save");
/** * @param int $num */ public function pageSizeIs($num) { assertContains($num, [10, 25, 50, 100], 'Only 10, 25, 50 and 100 records per page are available'); $element = $this->getElement('Grid toolbar')->find('css', '.page-size'); assertNotNull($element->find('css', sprintf('button:contains("%d")', $num))); }
/** * @Given /^the "([^"]*)" category node should not be selected/ */ public function theNodeShouldNotBeChecked($code) { $node = $this->getCurrentPage()->getElement('Category tree')->findNodeInTree($code); assertNotNull($node); assertFalse($node->isSelected()); }
/** * @Then /^I should see the comparison field "([^"]*)"$/ */ public function iShouldSeeTheComparisonField($fieldLabel) { $field = $this->getCurrentPage()->getElement('Attribute tab')->getComparisonFieldContainer($fieldLabel); assertNotNull($field); }
/** * @param int$id * * @return object */ public function getObjectById($id) { $object = $this->repository->find($id); assertNotNull($object); return $object; }