X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fsimpletest%2Fsrc%2FCache%2FContext%2FTestDiscoveryCacheContext.php;fp=web%2Fcore%2Fmodules%2Fsimpletest%2Fsrc%2FCache%2FContext%2FTestDiscoveryCacheContext.php;h=e3d5cf351d62b47326afc790282ec25fd1ebc56f;hp=0000000000000000000000000000000000000000;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hpb=74df008bdbb3a11eeea356744f39b802369bda3c diff --git a/web/core/modules/simpletest/src/Cache/Context/TestDiscoveryCacheContext.php b/web/core/modules/simpletest/src/Cache/Context/TestDiscoveryCacheContext.php new file mode 100644 index 000000000..e3d5cf351 --- /dev/null +++ b/web/core/modules/simpletest/src/Cache/Context/TestDiscoveryCacheContext.php @@ -0,0 +1,94 @@ +testDiscovery = $test_discovery; + $this->privateKey = $private_key; + } + + /** + * {@inheritdoc} + */ + public static function getLabel() { + return t('Test discovery'); + } + + /** + * {@inheritdoc} + */ + public function getContext() { + if (empty($this->hash)) { + $tests = $this->testDiscovery->getTestClasses(); + $this->hash = $this->hash(serialize($tests)); + } + return $this->hash; + } + + /** + * {@inheritdoc} + */ + public function getCacheableMetadata() { + return new CacheableMetadata(); + } + + /** + * Hashes the given string. + * + * @param string $identifier + * The string to be hashed. + * + * @return string + * The hash. + */ + protected function hash($identifier) { + return hash('sha256', $this->privateKey->get() . Settings::getHashSalt() . $identifier); + } + +}