Chris@0: assertNotEquals(Crypt::randomBytes($count), Crypt::randomBytes($count)); Chris@0: // Check the length. Chris@0: $this->assertEquals($count, strlen(Crypt::randomBytes($count))); Chris@0: } Chris@0: $this->assertEquals(30, static::$functionCalled, 'The namespaced function was called the expected number of times.'); Chris@0: } Chris@0: Chris@0: } Chris@0: Chris@0: namespace Drupal\Component\Utility; Chris@0: Chris@0: use Drupal\Tests\Component\Utility\CryptRandomFallbackTest; Chris@0: Chris@0: /** Chris@0: * Defines a function in same namespace as Drupal\Component\Utility\Crypt. Chris@0: * Chris@0: * Forces throwing an exception in this test environment because the function Chris@0: * in the namespace is used in preference to the global function. Chris@0: * Chris@0: * @param int $count Chris@0: * Matches the global function definition. Chris@0: * Chris@0: * @throws \Exception Chris@0: */ Chris@0: function random_bytes($count) { Chris@0: CryptRandomFallbackTest::functionCalled(); Chris@0: throw new \Exception($count); Chris@0: }