Namespace
Drupal\Tests\queue_example\Functional
File
-
modules/queue_example/tests/src/Functional/QueueExampleTest.php
View source
<?php
namespace Drupal\Tests\queue_example\Functional;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Tests\BrowserTestBase;
class QueueExampleTest extends BrowserTestBase {
protected $defaultTheme = 'stark';
protected static $modules = [
'queue_example',
];
protected $profile = 'minimal';
public function testQueueExampleBasic() {
$this->drupalGet('examples/queue_example');
for ($i = 1; $i <= 5; $i++) {
$edit = [
'queue_name' => 'queue_example_first_queue',
'string_to_add' => 'boogie' . $i,
];
$this->submitForm($edit, 'Insert into queue');
$this->assertSession()
->pageTextContains((string) new FormattableMarkup('There are now @number items in the queue', [
'@number' => $i,
]));
}
for ($i = 1; $i <= 5; $i++) {
$edit = [
'queue_name' => 'queue_example_first_queue',
'claim_time' => 0,
];
$this->submitForm($edit, 'Claim the next item from the queue');
$this->assertSession()
->responseMatches((string) new FormattableMarkup('%Claimed item id=.*string=@string for 0 seconds.%', [
'@string' => 'boogie' . $i,
]));
}
$edit = [
'queue_name' => 'queue_example_first_queue',
'claim_time' => 0,
];
$this->submitForm($edit, 'Claim the next item from the queue');
$this->assertSession()
->pageTextContains('There were no items in the queue available to claim');
sleep(1);
$this->submitForm([], 'Run cron manually to expire claims');
for ($i = 1; $i <= 5; $i++) {
$edit = [
'queue_name' => 'queue_example_first_queue',
'claim_time' => 0,
];
$this->submitForm($edit, 'Claim the next item and delete it');
$this->assertSession()
->responseMatches((string) new FormattableMarkup('%Claimed and deleted item id=.*string=@string for 0 seconds.%', [
'@string' => 'boogie' . $i,
]));
}
$edit = [
'queue_name' => 'queue_example_first_queue',
'claim_time' => 0,
];
$this->submitForm($edit, 'Claim the next item from the queue');
$this->assertSession()
->pageTextContains('There were no items in the queue available to claim');
}
}
Classes
| Title |
Deprecated |
Summary |
| QueueExampleTest |
|
Tests that our queue_example functions properly. |