function MigrateExecutableMemoryExceededTest::runMemoryExceededTest
Same name in other branches
- 9 core/modules/migrate/tests/src/Unit/MigrateExecutableMemoryExceededTest.php \Drupal\Tests\migrate\Unit\MigrateExecutableMemoryExceededTest::runMemoryExceededTest()
- 8.9.x core/modules/migrate/tests/src/Unit/MigrateExecutableMemoryExceededTest.php \Drupal\Tests\migrate\Unit\MigrateExecutableMemoryExceededTest::runMemoryExceededTest()
- 10 core/modules/migrate/tests/src/Unit/MigrateExecutableMemoryExceededTest.php \Drupal\Tests\migrate\Unit\MigrateExecutableMemoryExceededTest::runMemoryExceededTest()
Runs the actual test.
Parameters
string $message: The second message to assert.
bool $memory_exceeded: Whether to test the memory exceeded case.
int|null $memory_usage_first: (optional) The first memory usage value. Defaults to NULL.
int|null $memory_usage_second: (optional) The fake amount of memory usage reported after memory reclaim. Defaults to NULL.
int|null $memory_limit: (optional) The memory limit. Defaults to NULL.
3 calls to MigrateExecutableMemoryExceededTest::runMemoryExceededTest()
- MigrateExecutableMemoryExceededTest::testMemoryExceededClearedEnough in core/
modules/ migrate/ tests/ src/ Unit/ MigrateExecutableMemoryExceededTest.php - Tests memoryExceeded method when enough is cleared.
- MigrateExecutableMemoryExceededTest::testMemoryExceededNewBatch in core/
modules/ migrate/ tests/ src/ Unit/ MigrateExecutableMemoryExceededTest.php - Tests memoryExceeded method when a new batch is needed.
- MigrateExecutableMemoryExceededTest::testMemoryNotExceeded in core/
modules/ migrate/ tests/ src/ Unit/ MigrateExecutableMemoryExceededTest.php - Tests memoryExceeded when memory usage is not exceeded.
File
-
core/
modules/ migrate/ tests/ src/ Unit/ MigrateExecutableMemoryExceededTest.php, line 80
Class
- MigrateExecutableMemoryExceededTest
- Tests the \Drupal\migrate\MigrateExecutable::memoryExceeded() method.
Namespace
Drupal\Tests\migrate\UnitCode
protected function runMemoryExceededTest($message, $memory_exceeded, $memory_usage_first = NULL, $memory_usage_second = NULL, $memory_limit = NULL) : void {
$this->executable
->setMemoryLimit($memory_limit ?: $this->memoryLimit);
$this->executable
->setMemoryUsage($memory_usage_first ?: $this->memoryLimit, $memory_usage_second ?: $this->memoryLimit);
$this->executable
->setMemoryThreshold(0.85);
if ($message) {
$this->message
->display(Argument::that(fn(string $subject) => str_contains($subject, 'reclaiming memory')), 'warning')
->shouldBeCalledOnce();
$this->message
->display(Argument::that(fn(string $subject) => str_contains($subject, $message)), 'warning')
->shouldBeCalledOnce();
}
else {
$this->message
->display(Argument::cetera())
->shouldNotBeCalled();
}
$result = $this->executable
->memoryExceeded();
$this->assertEquals($memory_exceeded, $result);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.