Example #1
0
 public function test_it_gets_route_list()
 {
     $this->createTestPage([]);
     $this->Config->shouldReceive('get')->times(1)->andReturn(45);
     $list = $this->PagesRepository->getRouteList();
     assertContains(' Test', array_keys($list));
 }
Example #2
0
 public function testReturnsErrorCodeWhenSymbolsCountIsInvalid()
 {
     $validator = $this->createValidator();
     $validator->setMinSymbols(1);
     $validator->isValid('foo');
     assertContains($validator::INVALID_COUNT_SYMBOLS, $validator->getErrors());
 }
 /**
  * @Given /^"([^"]*)" should be subscribed to "([^"]*)"$/
  */
 public function thenEmailShouldBeSubscribedToMailinglist($email, $mailinglistTitle)
 {
     $recipient = \Recipient::get()->filter('Email', $email)->First();
     assertNotNull($recipient, 'Could not find Recipient with ' . $email);
     $mailinglist = \MailingList::get()->filter('Title', $mailinglistTitle)->First();
     assertNotNull($mailinglist, 'Could not find MailingList with ' . $mailinglistTitle);
     assertContains($mailinglistTitle, $recipient->MailingLists()->column('Title'));
 }
Example #4
0
 public function test_it_can_create_devise_docs_for_view()
 {
     $content = 'some content';
     $this->Creator->View = m::mock('SomeViewObj');
     $this->Creator->View->shouldReceive('make')->twice()->andReturnSelf();
     $this->Creator->View->shouldReceive('render')->twice()->andReturn($content);
     $this->CommonMarkConverter->shouldReceive('convertToHtml')->once()->with($content)->andReturn($content);
     $this->LiveSpan->shouldReceive('replace')->once()->with($content)->andReturn($content);
     assertContains($content, $this->Creator->deviseDocs('devise::some.view.path'));
 }
 public function testPublishActivities()
 {
     // DATE_ISO8601 gives us 2008-07-15T15:42:47-0700
     // DATE_ATOM    gives us 2008-07-15T15:43:46-07:00
     $atString = date_create()->format(DATE_ATOM);
     $activity = new Services_Gnip_Activity($atString, 'added_friend', 'foo/bob1');
     $this->gnip->publish($this->publisher, array($activity));
     $activities = $this->gnip->getActivities($this->publisher);
     assertContains($activity, $activities);
 }
 /**
  * Test to make sure that if the FormGenerator class returns false the correct feedback is provided
  */
 public function testTheConsoleCommandReturnsWithError()
 {
     // Arrange
     $formGenerator = m::mock('Grandadevans\\GenerateForm\\FormGenerator\\FormGenerator');
     $formGenerator->shouldReceive('generate')->andReturn(['path' => 'app/Forms/FooForm.php', 'status' => 'fail']);
     // Act
     $tester = new CommandTester(new FormGeneratorCommand($formGenerator, new UserFeedbackHandler()));
     $tester->execute(['name' => 'Foo']);
     // Assert
     assertContains('The form could not be saved to', $tester->getDisplay());
 }
Example #7
0
 /**
  * Checks, that element with specified CSS contains specified text.
  *
  * @Then /^(?:|I )should see "(?P<text>(?:[^"]|\\")*)" in any "(?P<element>[^"]*)" element$/
  */
 public function assertAnyElementContainsText($element, $text)
 {
     $text = str_replace('\\"', '"', $text);
     $elementsText = $this->getAllElementsText($element);
     try {
         assertContains($text, $elementsText);
     } catch (AssertException $e) {
         $message = sprintf('The text "%s" was not found in the text of any element matching css "%s"', $text, $element);
         throw new \Behat\Mink\Exception\ExpectationException($message, $this->getSession(), $e);
     }
 }
 public function testGetActivitiesWithPayload()
 {
     $pub = $this->gnip->getPublisher($this->publisher->name, $this->scope);
     $this->assertEquals($pub, $this->publisher);
     $place = array(new Services_Gnip_Place("38.2638886 -106.126131", 5280, null, "city", "Boulder", null));
     $payload = new Services_Gnip_Payload("raw", "title", "body", array(array("mediaURL" => "http://www.flickr.com/tour", "type" => "image", "mimeType" => "image/png"), array("mediaURL" => "http://www.gnipcentral.com/login", "type" => "movie", "mimeType" => "video/quicktime")));
     $activity = new Services_Gnip_Activity("2008-07-02T11:16:16+00:00", "upload", strval(rand(0, 9999999)), "http://www.gnipcentral.com", array(array('source' => 'sms')), array(array('keyword' => 'ping'), array('keyword' => 'pong')), $place, array(array('actor' => 'bob')), array(array("destinationURL" => "http://somewhere.com", "metaURL" => "http://somewhere.com/someplace")), array(array('tag' => 'pong')), array(array('to' => 'sally', 'metaURL' => 'http://gnipcentral.com/users/sally')), null, $payload);
     $this->gnip->publish($this->publisher, array($activity), $this->scope);
     $activities = $this->gnip->getPublisherActivities($this->publisher, time(), $this->scope);
     assertContains($activity, $activities);
     $this->assertEquals($activity->payload->decodedRaw(), $activities[1]->payload->decodedRaw());
 }
Example #9
0
 public function test_it_renames_devise_tags()
 {
     $parser = new DeviseParser();
     $traverser = new NodeTraverser();
     $traverser->addVisitor(new RegisterDeviseTags($parser));
     $nodes = $parser->parse($this->fixture('devise-views.interpret3'));
     $nodes = $traverser->traverse($nodes);
     assertContains('<body>', $nodes[9]->value);
     assertInstanceOf('PhpParser\\Node\\Stmt\\Foreach_', $nodes[10]);
     assertContains('<div data-devise-<?php echo devise_tag_cid(\'key1\', "field", null, "key1", "type", "Human name 1", null, null, null, null, null) ?>="key1">Hello there #1</div>', $nodes[10]->stmts[0]->value);
     assertContains('<div data-devise-<?php echo devise_tag_cid(\'key2\', "field", null, "key2", "type", "Human name 2", null, null, null, null, null) ?>="key2">Hello there #2</div>', $nodes[10]->stmts[1]->stmts[0]->value);
     assertContains('<p data-devise-<?php echo devise_tag_cid(\'outside\', "field", null, "outside", "type", "Outside Key", null, null, null, null, null) ?>="outside">', $nodes[11]->value);
 }
 /**
  * @Then お知らせに以下の内容が表示されていること:
  */
 public function お知らせに以下の内容が表示されていること(PyStringNode $markdown)
 {
     $page = $this->getSession()->getPage();
     $notices = $page->find('css', '.movieviewer-notices');
     assertContains($markdown->getRaw(), $notices->getText());
 }
Example #11
0
 /**
  * @Then /^(?:|I )should be able to find an element "(?P<element>[^"]*)" with following texts:$/
  */
 public function assertThereIsElementContainingTexts($element, TableNode $table)
 {
     $nodes = $this->getSession()->getPage()->findAll('css', $element);
     $texts = array();
     foreach ($table->getRows() as $row) {
         $texts[] = $row[0];
     }
     if (count($nodes) == 0) {
         throw new ElementNotFoundException($this->getSession(), 'element', 'css', $element);
     }
     foreach ($nodes as $node) {
         try {
             foreach ($texts as $text) {
                 assertContains($text, $node->getText());
             }
             return;
         } catch (AssertException $e) {
             // search in next node
         }
     }
     $message = sprintf('The texts "%s" was not found in any element matching css "%s"', implode('", "', $texts), $element);
     throw new ElementTextException($message, $this->getSession(), $node);
 }
Example #12
0
 /**
  * Checks, that element with specified CSS contains specified HTML.
  *
  * @Then /^the "(?P<element>[^"]*)" element should contain "(?P<value>(?:[^"]|\\")*)"$/
  */
 public function assertElementContains($element, $value)
 {
     $node = $this->getSession()->getPage()->find('css', $element);
     $value = str_replace('\\"', '"', $value);
     if (null === $node) {
         throw new ElementNotFoundException($this->getSession(), 'element', 'css', $element);
     }
     try {
         assertContains($value, $node->getHtml());
     } catch (AssertException $e) {
         $message = sprintf('The string "%s" was not found in the contents of the element matching css "%s"', $value, $element);
         throw new ElementHtmlException($message, $this->getSession(), $node, $e);
     }
 }
 /**
  * @Given /^I should get an email on "([^"]*)" with "([^"]*)"$/
  */
 public function iShouldGetAnEmail($email, $text)
 {
     $error = sprintf('No message sent to "%s"', $email);
     $profile = $this->getSymfonyProfile();
     $collector = $profile->getCollector('swiftmailer');
     foreach ($collector->getMessages() as $message) {
         // Checking the recipient email and the X-Swift-To
         // header to handle the RedirectingPlugin.
         // If the recipient is not the expected one, check
         // the next mail.
         $correctRecipient = array_key_exists($email, $message->getTo());
         $headers = $message->getHeaders();
         $correctXToHeader = false;
         if ($headers->has('X-Swift-To')) {
             $correctXToHeader = array_key_exists($email, $headers->get('X-Swift-To')->getFieldBodyModel());
         }
         if (!$correctRecipient && !$correctXToHeader) {
             continue;
         }
         $GLOBALS['email_body'] = $message->getBody();
         try {
             // checking the content
             return assertContains($text, $message->getBody());
         } catch (AssertException $e) {
             $error = sprintf('An email has been found for "%s" but without ' . 'the text "%s".', $email, $text);
         }
     }
     throw new ExpectationException($error, $this->getSession());
 }
Example #14
0
 /**
  * @param int $num
  */
 public function changePageSize($num)
 {
     assertContains($num, array(10, 25, 50, 100), 'Only 10, 25, 50 and 100 records per page are available');
     $element = $this->getElement('Grid toolbar')->find('css', '.page-size');
     $element->find('css', 'button')->click();
     $element->find('css', sprintf('ul.dropdown-menu li a:contains("%d")', $num))->click();
 }
 /**
  * @param $content_string
  *
  * @param $page_url
  *
  * @internal param $CiviCrm
  */
 private function ConfirmTextOnPage($content_string, $page_url)
 {
     $this->VisitPage($page_url);
     $page = $this->session->getPage();
     if (!isset($page)) {
         throw new PendingException("cannot retrieve the page!");
     }
     $page_content = $page->getContent();
     assertContains($content_string, $page_content);
 }
 /**
  * @param string    $attribute
  * @param string    $products
  * @param TableNode $table
  *
  *
  * @Given /^the options "([^"]*)" of products? (.*) should be:$/
  */
 public function theOptionsOfProductsShouldBe($attribute, $products, TableNode $table)
 {
     $this->clearUOW();
     foreach ($this->listToArray($products) as $identifier) {
         $productValue = $this->getProductValue($identifier, strtolower($attribute));
         $options = $productValue->getOptions();
         $optionCodes = $options->map(function ($option) {
             return $option->getCode();
         });
         $values = array_map(function ($row) {
             return $row['value'];
         }, $table->getHash());
         $values = array_filter($values);
         assertEquals(count($values), $options->count());
         foreach ($values as $value) {
             assertContains($value, $optionCodes, sprintf('"%s" does not contain "%s"', implode(', ', $optionCodes->toArray()), $value));
         }
     }
 }
Example #17
0
 /**
  * @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)));
 }
 /**
  * @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!');
 }
 /**
  * @test(expectedFail=true)
  * @profile(fork)
  */
 public function testAssertContainsFailed()
 {
     assertContains('needleinhaystack', 'bar');
     assertContains('hayaroundneedleinstack', 'bar');
     assertContains('haystackinfrontofneedle', 'bar');
     assertContains(array('foo' => array('key' => 'needle')), 'bar');
     assertContains(array('foo' => array('needle' => 'value')), 'bar');
 }
Example #20
0
 /**
  * @Then /^the "([^"]*)" value in the table should be "([^"]*)"$/
  */
 public function theValueInTheTableShouldBe($column, $value)
 {
     $tbl = $this->getSession()->getPage()->find('css', 'table.table');
     assertNotNull($tbl, 'Cannot find a table.table!');
     $row = $tbl->find('css', sprintf('tr:contains("%s")', $column));
     assertNotNull($row, 'Cannot find the row with the text ' . $column);
     assertContains($value, $row->getText());
 }
 /**
  * @Given /^data is string and contains "([^"]*)"$/
  */
 public function dataIsStringAndContains($arg)
 {
     $results = $this->getResponsePayload();
     assertContains($arg, $results->data, sprintf("String %s Not found in results", $arg));
 }
Example #22
0
 /**
  * @test
  */
 function migrate_error()
 {
     $this->manager->setScriptDirectory($this->env->files('err'));
     try {
         $this->manager->migrate();
         $this->fail();
     } catch (\Doctrine\DBAL\DBALException $ex) {
         assertContains('Duplicate entry', $ex->getMessage());
     }
     $rows = $this->pdo->query("select * from tt")->fetchAll(PDO::FETCH_COLUMN);
     assertEquals(array(1000), $rows);
     // エラーの直前までのバージョンが適用済
     $list = $this->fetch_migrate_versions();
     assertEquals(array("0000.sql", "1000.sql"), $list);
 }
Example #23
0
        $world->fillFields(new \Behat\Gherkin\Node\TableNode('| code  | ' . $row['name'] . ' |
             | value | 50           |'));
        $world->pressButton("Create");
    }
    toggleCoupons($world, $table);
});
$steps->Given('/^I should see coupons:$/', function (FeatureContext $world, TableNode $table) {
    $hash = $table->getHash();
    foreach ($hash as $row) {
        // $row['name'], $row['email'], $row['phone']
        new Given('I should see "' . $row['name'] . '" in any "a.link" element');
        if (isset($row['enabled'])) {
            $switcher = $world->find('xpath', '//a[text()="' . $row['name'] . '"]/ancestor::tr//span[contains(@class, "input-checkbox-switcher")]');
            $class = $switcher->getAttribute('class');
            try {
                assertContains($row['enabled'], $class);
            } catch (Exception $e) {
                throw new \Behat\Mink\Exception\ExpectationException('Coupon is not ' . $row['enabled'], $world->getSession(), $e);
            }
        }
    }
});
function toggleCoupons(FeatureContext $world, TableNode $table)
{
    $hash = $table->getHash();
    foreach ($hash as $row) {
        if (isset($row['enabled'])) {
            $switcher = $world->find('xpath', '//a[text()="' . $row['name'] . '"]/ancestor::tr//span[contains(@class, "input-checkbox-switcher")]');
            $class = $switcher->getAttribute('class');
            if (strpos($class, $row['enabled']) === false) {
                $switcher->find('css', '.widget')->click();
Example #24
0
 /**
  * @Then /^the "([^"]*)" property should contain "([^"]*)"$/
  */
 public function thePropertyShouldContain($property, $expectedValue)
 {
     $payload = $this->getScopePayload();
     $actualValue = $this->arrayGet($payload, $property);
     // if the property is actually an array, use JSON so we look in it deep
     $actualValue = is_array($actualValue) ? json_encode($actualValue, JSON_PRETTY_PRINT) : $actualValue;
     assertContains($expectedValue, $actualValue, "Asserting the [{$property}] property in current scope contains [{$expectedValue}]: " . json_encode($payload));
 }
Example #25
0
 /**
  * Checks whether last command output contains provided string.
  *
  * @Then the output should contain:
  *
  * @param   Behat\Gherkin\Node\PyStringNode $text   PyString text instance
  */
 public function theOutputShouldContain(PyStringNode $text)
 {
     $text = strtr($text, array('\'\'\'' => '"""', '%PATH%' => realpath(getcwd())));
     // windows path fix
     if ('/' !== DIRECTORY_SEPARATOR) {
         $text = preg_replace_callback('/ features\\/[^\\n ]+/', function ($matches) {
             return str_replace('/', DIRECTORY_SEPARATOR, $matches[0]);
         }, (string) $text);
         $text = preg_replace_callback('/\\<span class\\="path"\\>features\\/[^\\<]+/', function ($matches) {
             return str_replace('/', DIRECTORY_SEPARATOR, $matches[0]);
         }, (string) $text);
         $text = preg_replace_callback('/\\+[fd] [^ ]+/', function ($matches) {
             return str_replace('/', DIRECTORY_SEPARATOR, $matches[0]);
         }, (string) $text);
     }
     try {
         assertContains((string) $text, $this->output);
     } catch (Exception $e) {
         $diff = PHPUnit_Framework_TestFailure::exceptionToString($e);
         throw new Exception($diff, $e->getCode(), $e);
     }
 }
 /**
  * Example: Then the email should contain the following data:
  * | row1 |
  * | row2 |
  * Assumes an email has been identified by a previous step.
  * @Then /^the email should (not |)contain the following data:$/
  */
 public function theEmailContainFollowingData($negate, TableNode $table)
 {
     if (!$this->lastMatchedEmail) {
         throw new \LogicException('No matched email found from previous step');
     }
     $email = $this->lastMatchedEmail;
     $emailContent = null;
     if ($email->Content) {
         $emailContent = $email->Content;
     } else {
         $emailContent = $email->PlainContent;
     }
     // Convert html content to plain text
     $emailContent = strip_tags($emailContent);
     $rows = $table->getRows();
     // For "should not contain"
     if (trim($negate)) {
         foreach ($rows as $row) {
             assertNotContains($row[0], $emailContent);
         }
     } else {
         foreach ($rows as $row) {
             assertContains($row[0], $emailContent);
         }
     }
 }
 /**
  * @Then /^the "(?P<role>[^"]*)" role should have the permission "(?P<permission>[^"]*)"$/
  */
 public function theRoleShouldHaveThePermission($role, $permission)
 {
     $rolesWithPermission = user_roles(FALSE, $permission);
     assertContains(strtolower($role), $rolesWithPermission);
 }
Example #28
0
 public function test_it_changes_email_config_file()
 {
     $this->DeviseInstallCommand->changeEmailConfigFile();
     $contents = file_get_contents('vfs://basedir/config/auth.php');
     assertContains("'email' => 'devise::emails.recover-password',", $contents);
 }
Example #29
0
 /**
  * @Then /^I should see "([^"]*)" in the output$/
  */
 public function iShouldSeeInTheOutput($string)
 {
     assertContains($string, $this->output, sprintf('Did not see "%s" in the output', $string));
 }
Example #30
0
 /**
  * @Given /^the response body (contains|is|matches):$/
  */
 public function assertResponseBody($match, PyStringNode $expected)
 {
     $expected = trim((string) $expected);
     $actual = trim((string) $this->getLastResponse()->getBody());
     if ($match === 'is') {
         assertSame($expected, $actual, sprintf('Expected %s, got %s', $expected, $actual));
     } else {
         if ($match === 'matches') {
             assertRegExp($expected, $actual);
         } else {
             assertContains($expected, $actual);
         }
     }
 }