/** * @Then /^I should have a "([^"]*)" field as a "([^"]*)" type, has a "([^"]*)" widget, (not required|required), and allows (\d+|(?i)unlimited) value[s]?[.]?$/ */ public function iShouldHaveAFieldAsTypeHasAWidgetRequiredAndAllowsValue($name, $type, $widget, $required, $cardinality) { if (strcasecmp($cardinality, 'unlimited') == 0) { $cardinality = '-1'; } $fields = field_info_instances("node", $this->contentType->type); $wantedField = NULL; foreach ($fields as $field) { if ($field['label'] == $name) { $wantedField = $field; } } assertNotEmpty($wantedField, "Field with the label {$name} doesn't exist"); $fieldInfo = field_info_field($wantedField['field_name']); $widgetInfo = field_info_widget_types(); $fieldTypeInfo = field_info_field_types(); $wantedField['widget']['info'] = $widgetInfo[$wantedField['widget']['type']]; $wantedField['type'] = $fieldTypeInfo[$fieldInfo['type']]; assertEquals($type, $wantedField['type']['label'], "{$name} doesn't have the type {$type}. Instead it has " . $wantedField['type']['label'] . '.'); assertEquals($widget, $wantedField['widget']['info']['label'], "{$name} doesn't have the widget type {$widget}. Instead it has " . $wantedField['widget']['info']['label'] . '.'); $fieldRequired = $wantedField['required'] ? 'required' : 'not required'; assertEquals($required, $fieldRequired, "{$name} is marked '{$fieldRequired}'. It should be '{$required}'."); assertEquals($cardinality, $fieldInfo['cardinality'], "{$name} allows " . $fieldInfo['cardinality'] . " values. It should only allow {$cardinality} values."); $this->fieldList[] = $wantedField['field_name']; }
public function testGetStream() { $twitterClient = new TwitterClient($this->token, $this->consumerKey, $this->consumerSecret, $this->accessKey, $this->accessSecret); $twitterClient->getStream(['track' => "cheese"], function ($tweet) { assertNotEmpty($tweet); }); }
function getParameter($parameterName, $options = null) { $parameter = $_REQUEST[$parameterName]; debug("Parameter {$parameterName}={$parameter}"); if ($options == PARAMETER_REQUIRED) { assertNotEmpty($parameter, "missing parameter {$parameterName}"); } return $parameter; }
/** * @Then /^I should get these and more:$/ */ public function iShouldGetTheseAndMore(TableNode $table) { foreach ($table->getHash() as $row) { assertArrayHasKey($row['lang'], $this->languages, 'Language ' . $row['lang'] . ' must be among available languages.'); assertEquals($row['title'], $this->languages[$row['lang']]); } foreach ($this->languages as $code => $title) { assertNotEmpty($title); } assertGreaterThan(10, count($this->languages), 'There are missing languages for sure!'); }
function getData() { $tmpName = $_FILES['file']['tmp_name']; assertNotEmpty($tmpName, "missing file"); $imageWidth = getParameter("imageWidth"); $imageHeight = getParameter("imageHeight"); $contentType = getContentType(); debug($contentType); if (($contentType == "image/jpeg" || $contentType == "image/x-png" || $contentType == "image/png" || $contentType == "image/gif") && !empty($imageWidth) && !empty($imageHeight)) { resizeImage($tmpName, $imageWidth, $imageHeight); } $fp = fopen($tmpName, 'r'); $length = filesize($tmpName); debug("File size: {$length}"); $content = fread($fp, $length); fclose($fp); return $content; }
/** * @Then /^all roles should have the permission "(?P<permission>[^"]*)"$/ */ public function allRolesShouldHaveThePermission($permission) { $rolesWithPermission = user_roles(FALSE, $permission); assertNotEmpty($rolesWithPermission); }
/** * @Given /^the "([^"]*)" property is not empty$/ */ public function thePropertyIsNotEmpty($arg) { $results = $this->getResponsePayload(); assertNotEmpty($results->data->{$arg}); }
/** * @test(expectedFail=true) * @profile(fork) */ public function testAssertNotEmptyFailed() { assertNotEmpty([]); }
/** * @Given I request :url */ public function iRequest($url) { $this->response = $this->client->get("http://127.0.0.1:8000" . $url, ["exceptions" => false]); assertNotEmpty($this->response->getBody(), "Service active"); }
function TestMessagingCycle() { $msgs = newTestMessagingSystem(); $id = givenExistingQueue($msgs); $pushMessageResp = $msgs->pushMessage(array('queue_id' => $id, 'content_type' => 'text/plain', 'body' => 'Hello World!')); assertNotNull($pushMessageResp); assertNotEmpty($pushMessageResp['message_id']); $status = $msgs->describeQueueStatus(array('queue_id' => $id)); assert($status['message_count'] == 1, "Expected message count to be 1"); // Pop the message $popMessageResponse = $msgs->popMessage(array('queue_id' => $id)); assertNotNull($popMessageResponse); assertEquals($pushMessageResp['id'], $popMessageResponse['message_id']); assertEquals("Hello World!", $popMessageResponse['body']); assertEquals('text/plain', $popMessageResponse['content_type']); assertNotEmpty($popMessageResponse['created_at']); // Ensure the message is gone $status = $msgs->describeQueueStatus(array('queue_id' => $id)); assert($status['message_count'] === 0, "Expected message count to be 0"); // Pop another message $popMessageResponse = $msgs->popMessage(array('queue_id' => $id)); assertNull($popMessageResponse); }
/** * @Then /([^\s]+) should start with ([^\s]+)/ */ public function shouldStartWith($key, $value) { if (property_exists($this, 'error')) { throw $this->error; } $this->result ?: array(); assertNotEmpty($this->result, 'No results received.'); $result = array_reduce(explode('.', $key), function ($o, $k) { if (property_exists($o, $k)) { return $o->{$k}; } else { return ''; } }, $this->result[0]); assertStringStartsWith($value, $result); }
}); $steps->Then('/([^\\s]+) should be (.+)$/', function ($world, $key, $value) { if (property_exists($world, 'error')) { throw $world->error; } $world->result ?: array(); assertNotEmpty($world->result, 'No results received.'); $results = array_map(function ($o) use($key) { if (property_exists($o, $key)) { return $o->{$key}; } else { return ''; } }, $world->result); assertEquals(implode(',', $results), $value); }); $steps->Then('/([^\\s]+) should start with ([^\\s]+)/', function ($world, $key, $value) { if (property_exists($world, 'error')) { throw $world->error; } $world->result ?: array(); assertNotEmpty($world->result, 'No results received.'); $result = array_reduce(explode('.', $key), function ($o, $k) { if (property_exists($o, $k)) { return $o->{$k}; } else { return ''; } }, $world->result[0]); assertStringStartsWith($value, $result); });
/** * @Then Assert the value :arg1 is not empty * @param $actualValue */ public function assertNotEmpty($actualValue) { assertNotEmpty($actualValue, sprintf("Assert the value [%s] is not empty", $actualValue)); }