BrokenCacheUpdateTest.php in Drupal 8
File
core/modules/system/tests/src/Functional/UpdateSystem/BrokenCacheUpdateTest.php
View source
<?php
namespace Drupal\Tests\system\Functional\UpdateSystem;
use Drupal\Core\Database\Database;
use Drupal\Tests\BrowserTestBase;
use Drupal\Tests\UpdatePathTestTrait;
class BrokenCacheUpdateTest extends BrowserTestBase {
use UpdatePathTestTrait;
protected $defaultTheme = 'stark';
protected function setUp() {
parent::setUp();
$this
->ensureUpdatesToRun();
}
public function testUpdate() {
$connection = Database::getConnection();
$connection
->delete('key_value')
->condition('collection', 'state')
->condition('name', 'system.theme.data')
->execute();
$insert = $connection
->upsert('cache_discovery');
$insert
->key('cid');
$fields = [
'cid' => 'element_info',
'data' => 'BROKEN',
'expire' => -1,
'created' => '1549505157.144',
'serialized' => 1,
'tags' => '',
'checksum' => 0,
];
$insert
->fields($fields);
$fields['cid'] = 'element_info_build:seven';
$fields['tags'] = 'element_info_build';
$insert
->values(array_values($fields));
$fields['cid'] = 'element_info_build:stark';
$insert
->values(array_values($fields));
$insert
->execute();
$this
->runUpdates();
$count = (int) $connection
->select('cache_discovery')
->condition('cid', [
'element_info',
'element_info_build:seven',
'element_info_build:stark',
], 'IN')
->countQuery()
->execute()
->fetchField();
$this
->assertSame(0, $count);
}
}