Example #1
0
function TestDeleteQueueReturnsTrueForExistingQueue()
{
    $msgs = newTestMessagingSystem();
    $queueId = givenExistingQueue($msgs);
    $response = $msgs->deleteQueue(array('queue_id' => $queueId));
    assertEmpty($response);
}
Example #2
0
 /**
  * @test
  */
 function execute_php_dryrun()
 {
     $this->config->dryRun = true;
     $this->executor = new Executor($this->config, $this->env->logger());
     $fn = $this->env->files('/ok/3000.php');
     $this->executor->execute($fn);
     assertEmpty($this->fetch_list());
 }
Example #3
0
 /**
  * @test
  */
 function migrate_dryRun()
 {
     $this->config->dryRun = true;
     $this->manager = new Manager($this->config, $this->env->logger());
     $this->manager->migrate();
     $rows = $this->pdo->query("show tables like 'tt'")->fetchAll();
     assertEmpty($rows);
     $rows = $this->pdo->query("show tables like 'migrate'")->fetchAll();
     assertEmpty($rows);
 }
 /**
  * The X-Frame-Options HTTP header (with a value of "DENY") should be included by default
  * on all pages. Only the chipin widgets themselves should exclude this option, as they will
  * be embedded in iframes on other websites.
  */
 function testInclusionOfFrameOptionsHeader()
 {
     foreach (array('/about/', '/account/signup', '/widget-wiz/step-one') as $uri) {
         $r = $this->get($uri);
         $hs = $r->getValuesForHeader('X-Frame-Options');
         $value = strtolower(head($hs));
         assertTrue($value == 'deny' || $value == 'sameorigin');
     }
     $w = getWidget();
     $r = $this->get("/widgets/by-id/{$w->id}");
     assertEmpty($r->getValuesForHeader('X-Frame-Options'));
 }
 /**
  * @test
  */
 function fix_()
 {
     $fn = $this->env->files();
     ///
     $this->tester->run('fix', '--all', '--config', $fn);
     $sql = "select version from db_migrate order by version";
     $list = $this->pdo->query($sql)->fetchAll(\PDO::FETCH_COLUMN);
     assertEquals(array("1000.sql", "2000.sql", "3000.php", "9999.sql"), $list);
     ///
     $this->tester->run('fix', '--clear', '--config', $fn);
     $rows = $this->pdo->query("show tables like 'migrate'")->fetchAll();
     assertEmpty($rows);
     ///
     $this->tester->run('fix', '2000.sql', '--config', $fn);
     $version = $this->pdo->query("select * from db_migrate")->fetchColumn();
     assertEquals('2000.sql', $version);
 }
 /**
  * @param string    $code
  * @param TableNode $expectedLines
  *
  * @Then /^exported xlsx files of "([^"]*)" should contain:$/
  */
 public function exportedXlsxFilesOfShouldContain($code, TableNode $expectedLines)
 {
     $filePaths = $this->getMainContext()->getSubcontext('job')->getAllJobInstancePaths($code);
     $expectedLines = $expectedLines->getRows();
     unset($expectedLines[0]);
     $reader = ReaderFactory::create(Type::XLSX);
     foreach ($filePaths as $path) {
         $reader->open($path);
         $sheet = current(iterator_to_array($reader->getSheetIterator()));
         $actualLines = iterator_to_array($sheet->getRowIterator());
         foreach ($actualLines as $actualLine) {
             $expectedLines = array_filter($expectedLines, function ($expected) use($actualLine) {
                 return count(array_diff($expected, $actualLine)) > 0;
             });
         }
         $reader->close();
     }
     assertEmpty($expectedLines, sprintf('Could not find an expected line: %s', implode(' | ', current($expectedLines))));
 }
 /**
  * Verifies user data can not be retrieved via open social api
  *
  * @Then /^I should not be able to retrieve user "([^"]*)" via open social api$/
  * @param string $userName
  * @return void
  * @throws \Exception if data is retrievable
  */
 public function iShouldNotBeAbleToRetrieveUserViaOpenSocialApi($userName)
 {
     $userData = $this->_loadUserDataViaOpenSocialApi($userName);
     assertEmpty($userData);
 }
 /**
  * @Given /^I click button "([^"]*)"$/
  */
 public function iClickButton($button_text)
 {
     $button = $this->session->getPage()->find('xpath', '//*/input[@type="submit"]');
     assert($button->getValue() == $button_text);
     $button->press();
     $response_content = $this->session->getResponseHeaders();
     $page = $this->session->getCurrentUrl();
     $response_content = $this->session->getResponseHeaders();
     $response_string = '';
     foreach ($response_content as $response) {
         $response_string = $response_string . '  ' . implode($response);
     }
     //check for required field errors on the form
     $error_span = $this->session->getPage()->find('xpath', '//*[@id="wpbody-content"]/span');
     if (isset($error_span)) {
         assertEmpty($error_span->getText(), 'Failed submitting the new Association Rule form due to failed form field validations: ' . $error_span->getText() . " Response headers: " . $response_string);
     }
 }
Example #9
0
 /**
  * @Given /^the response body should be empty$/
  */
 public function assertEmptyResponseBody()
 {
     $response = $this->getLastResponse();
     assertEmpty((string) $response->getBody());
 }
 /**
  * @Then Assert the value :arg1 is empty
  * @param $actualValue
  */
 public function assertEmpty($actualValue)
 {
     assertEmpty($actualValue, sprintf("Assert the [%s] is empty", $actualValue));
 }
 /**
  * @test(expectedFail=true)
  * @profile(fork)
  */
 public function testAssertEmptyFailed()
 {
     assertEmpty(false);
 }
 /**
  * @param string    $identifier
  * @param TableNode $table
  *
  * @Given /^the product "([^"]*)" should have the following values?:$/
  */
 public function theProductShouldHaveTheFollowingValues($identifier, TableNode $table)
 {
     $this->clearUOW();
     $product = $this->getProduct($identifier);
     foreach ($table->getRowsHash() as $code => $value) {
         $productValue = $product->getValue($code);
         if ('media' === $this->getAttribute($code)->getBackendType()) {
             // media filename is auto generated during media handling and cannot be guessed
             // (it contains a timestamp)
             if ('**empty**' === $value) {
                 assertEmpty((string) $productValue);
             } else {
                 assertTrue(false !== strpos((string) $productValue, $value));
             }
         } else {
             assertEquals($value, (string) $productValue);
         }
     }
 }
Example #13
0
 public function assertActivated()
 {
     $player = $this->response->getPlayer();
     assertInstanceOf('\\OpenTribes\\Core\\Player\\Activate\\Response', $this->response);
     assertEmpty($player->getActivationCode());
 }
 /**
  * @param TableNode $table
  *
  * @throws \Exception
  *
  * @Then /^there should be the following attributes:$/
  */
 public function thereShouldBeTheFollowingAttributes(TableNode $table)
 {
     foreach ($table->getHash() as $data) {
         /** @var AttributeInterface $attribute */
         $attribute = $this->getFixturesContext()->getAttribute($data['code']);
         $this->getFixturesContext()->refresh($attribute);
         foreach ($data as $method => $value) {
             $matches = null;
             switch ($method) {
                 case 'code':
                     // Untestable method
                     break;
                 case preg_match('/^label-(?<locale>.*)$/', $method, $matches) ? true : false:
                     assertEquals($value, $attribute->getTranslation($matches['locale'])->getLabel());
                     break;
                 case 'type':
                     assertEquals($this->getFixturesContext()->getAttributeType($value), $attribute->getAttributeType());
                     break;
                 case 'localizable':
                     assertEquals('1' === $value, $attribute->isLocalizable());
                     break;
                 case 'scopable':
                     assertEquals('1' === $value, $attribute->isScopable());
                     break;
                 case 'wysiwyg_enabled':
                     assertEquals('1' === $value, $attribute->isWysiwygEnabled());
                     break;
                 case 'decimals_allowed':
                     assertEquals('1' === $value, $attribute->isDecimalsAllowed());
                     break;
                 case 'negative_allowed':
                     assertEquals('1' === $value, $attribute->isNegativeAllowed());
                     break;
                 case 'useable_as_grid_filter':
                     assertEquals('1' === $value, $attribute->isUseableAsGridFilter());
                     break;
                 case 'unique':
                     assertEquals('1' === $value, $attribute->isUnique());
                     break;
                 case 'group':
                     assertEquals($value, $attribute->getGroup()->getCode());
                     break;
                 case 'allowed_extensions':
                     if ('' === $value) {
                         assertEmpty($attribute->getAllowedExtensions());
                     } else {
                         assertEquals(explode(',', $value), $attribute->getAllowedExtensions());
                     }
                     break;
                 case 'available_locales':
                     assertEquals(explode(',', $value), $attribute->getAvailableLocales()->toArray());
                     break;
                 case 'reference_data_name':
                     if ('' === $value) {
                         assertNull($attribute->getReferenceDataName());
                     } else {
                         assertEquals($value, $attribute->getReferenceDataName());
                     }
                     break;
                 case 'number_min':
                     if ('' === $value) {
                         assertNull($attribute->getNumberMin());
                     } else {
                         assertEquals($value, $attribute->getNumberMin());
                     }
                     break;
                 case 'number_max':
                     if ('' === $value) {
                         assertNull($attribute->getNumberMax());
                     } else {
                         assertEquals($value, $attribute->getNumberMax());
                     }
                     break;
                 case 'metric_family':
                     assertEquals($value, $attribute->getMetricFamily());
                     break;
                 case 'default_metric_unit':
                     assertEquals($value, $attribute->getDefaultMetricUnit());
                     break;
                 case 'sort_order':
                     assertEquals($value, $attribute->getSortOrder());
                     break;
                 case 'max_characters':
                     assertEquals($value, $attribute->getMaxCharacters());
                     break;
                 case 'validation_rule':
                     assertEquals($value, $attribute->getValidationRule());
                     break;
                 case 'validation_regexp':
                     assertEquals($value, $attribute->getValidationRegexp());
                     break;
                 case 'max_file_size':
                     assertEquals($value, $attribute->getMaxFileSize());
                     break;
                 case 'date_min':
                     assertEquals($value, $attribute->getDateMin()->format('Y-m-d'));
                     break;
                 case 'date_max':
                     assertEquals($value, $attribute->getDateMax()->format('Y-m-d'));
                     break;
                 case 'is_read_only':
                     assertEquals($data['is_read_only'] == 1, $attribute->getProperty('is_read_only'));
                     break;
                 default:
                     throw new \Exception(sprintf("The attribute method '%s' is not testable, please add it in %s", $method, get_class($this)));
             }
         }
     }
 }
 /**
  * @param string    $identifier
  * @param TableNode $table
  *
  * @Given /^the product "([^"]*)" should have the following values?:$/
  */
 public function theProductShouldHaveTheFollowingValues($identifier, TableNode $table)
 {
     $this->clearUOW();
     $product = $this->getProduct($identifier);
     foreach ($table->getRowsHash() as $rawCode => $value) {
         $infos = $this->getFieldExtractor()->extractColumnInfo($rawCode);
         $attribute = $infos['attribute'];
         $attributeCode = $attribute->getCode();
         $localeCode = $infos['locale_code'];
         $scopeCode = $infos['scope_code'];
         $priceCurrency = isset($infos['price_currency']) ? $infos['price_currency'] : null;
         $productValue = $product->getValue($attributeCode, $localeCode, $scopeCode);
         if ('' === $value) {
             assertEmpty((string) $productValue);
         } elseif ('media' === $attribute->getBackendType()) {
             // media filename is auto generated during media handling and cannot be guessed
             // (it contains a timestamp)
             if ('**empty**' === $value) {
                 assertEmpty((string) $productValue);
             } else {
                 assertTrue(false !== strpos((string) $productValue, $value));
             }
         } elseif ('prices' === $attribute->getBackendType() && null !== $priceCurrency) {
             // $priceCurrency can be null if we want to test all the currencies at the same time
             // in this case, it's a simple string comparison
             // example: 180.00 EUR, 220.00 USD
             $price = $productValue->getPrice($priceCurrency);
             assertEquals($value, $price->getData());
         } elseif ('date' === $attribute->getBackendType()) {
             assertEquals($value, $productValue->getDate()->format('Y-m-d'));
         } else {
             assertEquals($value, (string) $productValue);
         }
     }
 }
 /**
  * @param string $code
  *
  * @Then /^exported file of "([^"]*)" should be empty$/
  *
  * @throws \PHPUnit_Framework_AssertionFailedError
  */
 public function exportedFileOfShouldBeEmpty($code)
 {
     $path = $this->getExportedFile($code);
     $content = trim(file_get_contents($path));
     assertEmpty($content);
 }
 /**
  * @Then /^all roles should not have the permission "(?P<permission>[^"]*)"$/
  */
 public function allRolesShouldNotHaveThePermission($permission)
 {
     $rolesWithPermission = user_roles(FALSE, $permission);
     assertEmpty($rolesWithPermission);
 }
 /**
  * @Then /^I should not have other fields in this Content Type$/
  */
 public function iShouldNotHaveOtherFields()
 {
     $fields = field_info_instances('node', $this->contentType->type);
     $oddFields = array_diff(array_keys($fields), $this->fieldList);
     assertEmpty($oddFields, 'Following fields should not be in this Content Type: ' . implode(', ', $oddFields));
 }