Issue #3418182 by longwave: Remove withConsecutive() in ViewsDataTest
parent
8f2d6063dd
commit
0ce407c41d
|
@ -220,23 +220,33 @@ class ViewsDataTest extends UnitTestCase {
|
||||||
|
|
||||||
// The cache should only be called once (before the clear() call) as get
|
// The cache should only be called once (before the clear() call) as get
|
||||||
// will get all table data in the first get().
|
// will get all table data in the first get().
|
||||||
$this->cacheBackend->expects($this->exactly(4))
|
$gets = [
|
||||||
|
'views_data:en',
|
||||||
|
"views_data:$random_table_name:en",
|
||||||
|
'views_data:en',
|
||||||
|
"views_data:$random_table_name:en",
|
||||||
|
];
|
||||||
|
$this->cacheBackend->expects($this->exactly(count($gets)))
|
||||||
->method('get')
|
->method('get')
|
||||||
->withConsecutive(
|
->with($this->callback(function (string $key) use (&$gets): bool {
|
||||||
['views_data:en'],
|
return $key === array_shift($gets);
|
||||||
["views_data:$random_table_name:en"],
|
}))
|
||||||
['views_data:en'],
|
|
||||||
["views_data:$random_table_name:en"],
|
|
||||||
)
|
|
||||||
->willReturn(FALSE);
|
->willReturn(FALSE);
|
||||||
$this->cacheBackend->expects($this->exactly(4))
|
|
||||||
|
$sets = [
|
||||||
|
'views_data:en', $expected_views_data,
|
||||||
|
"views_data:$random_table_name:en", [],
|
||||||
|
'views_data:en', $expected_views_data,
|
||||||
|
"views_data:$random_table_name:en", [],
|
||||||
|
];
|
||||||
|
$this->cacheBackend->expects($this->exactly(count($sets) / 2))
|
||||||
->method('set')
|
->method('set')
|
||||||
->withConsecutive(
|
->with($this->callback(function (string $key) use (&$sets): bool {
|
||||||
['views_data:en', $expected_views_data],
|
return $key === array_shift($sets);
|
||||||
["views_data:$random_table_name:en", []],
|
}), $this->callback(function (array $data) use (&$sets): bool {
|
||||||
['views_data:en', $expected_views_data],
|
return $data === array_shift($sets);
|
||||||
["views_data:$random_table_name:en", []],
|
}));
|
||||||
);
|
|
||||||
$this->cacheTagsInvalidator->expects($this->once())
|
$this->cacheTagsInvalidator->expects($this->once())
|
||||||
->method('invalidateTags')
|
->method('invalidateTags')
|
||||||
->with(['views_data']);
|
->with(['views_data']);
|
||||||
|
@ -303,12 +313,12 @@ class ViewsDataTest extends UnitTestCase {
|
||||||
->method('alter')
|
->method('alter')
|
||||||
->with('views_data', $this->viewsDataWithProvider());
|
->with('views_data', $this->viewsDataWithProvider());
|
||||||
|
|
||||||
$this->cacheBackend->expects($this->exactly(2))
|
$gets = ["views_data:$table_name:en", 'views_data:en'];
|
||||||
|
$this->cacheBackend->expects($this->exactly(count($gets)))
|
||||||
->method('get')
|
->method('get')
|
||||||
->withConsecutive(
|
->with($this->callback(function (string $key) use (&$gets): bool {
|
||||||
["views_data:$table_name:en"],
|
return $key === array_shift($gets);
|
||||||
['views_data:en'],
|
}))
|
||||||
)
|
|
||||||
->willReturn(FALSE);
|
->willReturn(FALSE);
|
||||||
|
|
||||||
$views_data = $this->viewsData->get($table_name);
|
$views_data = $this->viewsData->get($table_name);
|
||||||
|
@ -337,12 +347,12 @@ class ViewsDataTest extends UnitTestCase {
|
||||||
->method('alter')
|
->method('alter')
|
||||||
->with('views_data', $this->viewsDataWithProvider());
|
->with('views_data', $this->viewsDataWithProvider());
|
||||||
|
|
||||||
$this->cacheBackend->expects($this->exactly(2))
|
$gets = ["views_data:$random_table_name:en", 'views_data:en'];
|
||||||
|
$this->cacheBackend->expects($this->exactly(count($gets)))
|
||||||
->method('get')
|
->method('get')
|
||||||
->withConsecutive(
|
->with($this->callback(function (string $key) use (&$gets): bool {
|
||||||
["views_data:$random_table_name:en"],
|
return $key === array_shift($gets);
|
||||||
['views_data:en'],
|
}))
|
||||||
)
|
|
||||||
->willReturn(FALSE);
|
->willReturn(FALSE);
|
||||||
|
|
||||||
// All views data should be requested on the first try.
|
// All views data should be requested on the first try.
|
||||||
|
@ -362,18 +372,24 @@ class ViewsDataTest extends UnitTestCase {
|
||||||
|
|
||||||
$this->setupMockedModuleHandler();
|
$this->setupMockedModuleHandler();
|
||||||
|
|
||||||
$this->cacheBackend->expects($this->exactly(2))
|
$gets = ['views_data:views_test_data:en', 'views_data:en'];
|
||||||
|
$this->cacheBackend->expects($this->exactly(count($gets)))
|
||||||
->method('get')
|
->method('get')
|
||||||
->withConsecutive(
|
->with($this->callback(function (string $key) use (&$gets): bool {
|
||||||
['views_data:views_test_data:en'],
|
return $key === array_shift($gets);
|
||||||
['views_data:en'],
|
}));
|
||||||
);
|
|
||||||
$this->cacheBackend->expects($this->exactly(2))
|
$sets = [
|
||||||
|
'views_data:en', $expected_views_data,
|
||||||
|
'views_data:views_test_data:en', $expected_views_data['views_test_data'],
|
||||||
|
];
|
||||||
|
$this->cacheBackend->expects($this->exactly(count($sets) / 2))
|
||||||
->method('set')
|
->method('set')
|
||||||
->withConsecutive(
|
->with($this->callback(function (string $key) use (&$sets): bool {
|
||||||
['views_data:en', $expected_views_data],
|
return $key === array_shift($sets);
|
||||||
['views_data:views_test_data:en', $expected_views_data['views_test_data']],
|
}), $this->callback(function (array $data) use (&$sets): bool {
|
||||||
);
|
return $data === array_shift($sets);
|
||||||
|
}));
|
||||||
|
|
||||||
// Request the same table 5 times. The caches are empty at this point, so
|
// Request the same table 5 times. The caches are empty at this point, so
|
||||||
// what will happen is that it will first check for a cache entry for the
|
// what will happen is that it will first check for a cache entry for the
|
||||||
|
@ -430,12 +446,12 @@ class ViewsDataTest extends UnitTestCase {
|
||||||
->method('invokeAllWith');
|
->method('invokeAllWith');
|
||||||
|
|
||||||
// Setup a warm cache backend for a single table.
|
// Setup a warm cache backend for a single table.
|
||||||
$this->cacheBackend->expects($this->exactly(2))
|
$gets = ['views_data:views_test_data_2:en', 'views_data:en'];
|
||||||
|
$this->cacheBackend->expects($this->exactly(count($gets)))
|
||||||
->method('get')
|
->method('get')
|
||||||
->withConsecutive(
|
->with($this->callback(function (string $key) use (&$gets): bool {
|
||||||
['views_data:views_test_data_2:en'],
|
return $key === array_shift($gets);
|
||||||
['views_data:en'],
|
}))
|
||||||
)
|
|
||||||
->willReturnOnConsecutiveCalls(
|
->willReturnOnConsecutiveCalls(
|
||||||
FALSE,
|
FALSE,
|
||||||
(object) ['data' => $expected_views_data],
|
(object) ['data' => $expected_views_data],
|
||||||
|
@ -469,12 +485,12 @@ class ViewsDataTest extends UnitTestCase {
|
||||||
->method('invokeAllWith');
|
->method('invokeAllWith');
|
||||||
|
|
||||||
// Setup a warm cache backend for a single table.
|
// Setup a warm cache backend for a single table.
|
||||||
$this->cacheBackend->expects($this->exactly(2))
|
$gets = ["views_data:$non_existing_table:en", 'views_data:en'];
|
||||||
|
$this->cacheBackend->expects($this->exactly(count($gets)))
|
||||||
->method('get')
|
->method('get')
|
||||||
->withConsecutive(
|
->with($this->callback(function (string $key) use (&$gets): bool {
|
||||||
["views_data:$non_existing_table:en"],
|
return $key === array_shift($gets);
|
||||||
['views_data:en'],
|
}))
|
||||||
)
|
|
||||||
->willReturnOnConsecutiveCalls(
|
->willReturnOnConsecutiveCalls(
|
||||||
FALSE,
|
FALSE,
|
||||||
(object) ['data' => $expected_views_data],
|
(object) ['data' => $expected_views_data],
|
||||||
|
@ -587,24 +603,29 @@ class ViewsDataTest extends UnitTestCase {
|
||||||
$table_name_2 = 'views_test_data_2';
|
$table_name_2 = 'views_test_data_2';
|
||||||
|
|
||||||
// Setup a warm cache backend for all table data, but not single tables.
|
// Setup a warm cache backend for all table data, but not single tables.
|
||||||
$this->cacheBackend->expects($this->exactly(3))
|
$gets = ["views_data:$table_name:en", 'views_data:en', "views_data:$table_name_2:en"];
|
||||||
|
$this->cacheBackend->expects($this->exactly(count($gets)))
|
||||||
->method('get')
|
->method('get')
|
||||||
->withConsecutive(
|
->with($this->callback(function (string $key) use (&$gets): bool {
|
||||||
["views_data:$table_name:en"],
|
return $key === array_shift($gets);
|
||||||
['views_data:en'],
|
}))
|
||||||
["views_data:$table_name_2:en"],
|
|
||||||
)
|
|
||||||
->willReturnOnConsecutiveCalls(
|
->willReturnOnConsecutiveCalls(
|
||||||
FALSE,
|
FALSE,
|
||||||
(object) ['data' => $expected_views_data],
|
(object) ['data' => $expected_views_data],
|
||||||
FALSE,
|
FALSE,
|
||||||
);
|
);
|
||||||
$this->cacheBackend->expects($this->exactly(2))
|
|
||||||
|
$sets = [
|
||||||
|
"views_data:$table_name:en", $expected_views_data[$table_name],
|
||||||
|
"views_data:$table_name_2:en", $expected_views_data[$table_name_2],
|
||||||
|
];
|
||||||
|
$this->cacheBackend->expects($this->exactly(count($sets) / 2))
|
||||||
->method('set')
|
->method('set')
|
||||||
->withConsecutive(
|
->with($this->callback(function (string $key) use (&$sets): bool {
|
||||||
["views_data:$table_name:en", $expected_views_data[$table_name]],
|
return $key === array_shift($sets);
|
||||||
["views_data:$table_name_2:en", $expected_views_data[$table_name_2]],
|
}), $this->callback(function (array $data) use (&$sets): bool {
|
||||||
);
|
return $data === array_shift($sets);
|
||||||
|
}));
|
||||||
|
|
||||||
$this->assertSame($expected_views_data[$table_name], $this->viewsData->get($table_name));
|
$this->assertSame($expected_views_data[$table_name], $this->viewsData->get($table_name));
|
||||||
$this->assertSame($expected_views_data[$table_name_2], $this->viewsData->get($table_name_2));
|
$this->assertSame($expected_views_data[$table_name_2], $this->viewsData->get($table_name_2));
|
||||||
|
|
|
@ -2819,11 +2819,6 @@ parameters:
|
||||||
count: 2
|
count: 2
|
||||||
path: modules/views/tests/src/Kernel/RenderCacheIntegrationTest.php
|
path: modules/views/tests/src/Kernel/RenderCacheIntegrationTest.php
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Call to deprecated method withConsecutive\\(\\) of class PHPUnit\\\\Framework\\\\MockObject\\\\Builder\\\\InvocationMocker\\.$#"
|
|
||||||
count: 10
|
|
||||||
path: modules/views/tests/src/Unit/ViewsDataTest.php
|
|
||||||
|
|
||||||
-
|
-
|
||||||
message: "#^Variable \\$relationship_handler in empty\\(\\) always exists and is not falsy\\.$#"
|
message: "#^Variable \\$relationship_handler in empty\\(\\) always exists and is not falsy\\.$#"
|
||||||
count: 1
|
count: 1
|
||||||
|
|
Loading…
Reference in New Issue