+ protected function mockHttpClient(array $responses = []): HttpClientHistory
+ {
+ return $this->app->make(HttpRequestService::class)->mockClient($responses);
+ }
+
+ /**
+ * Run a set test with the given env variable.
+ * Remembers the original and resets the value after test.
+ * Database config is juggled so the value can be restored when
+ * parallel testing are used, where multiple databases exist.
+ */
+ protected function runWithEnv(array $valuesByKey, callable $callback, bool $handleDatabase = true): void
+ {
+ Env::disablePutenv();
+ $originals = [];
+ foreach ($valuesByKey as $key => $value) {
+ $originals[$key] = $_SERVER[$key] ?? null;
+
+ if (is_null($value)) {
+ unset($_SERVER[$key]);
+ } else {
+ $_SERVER[$key] = $value;
+ }
+ }
+
+ $database = config('database.connections.mysql_testing.database');
+ $this->refreshApplication();
+
+ if ($handleDatabase) {
+ DB::purge();
+ config()->set('database.connections.mysql_testing.database', $database);
+ DB::beginTransaction();
+ }
+
+ $callback();
+
+ if ($handleDatabase) {
+ DB::rollBack();
+ }
+
+ foreach ($originals as $key => $value) {
+ if (is_null($value)) {
+ unset($_SERVER[$key]);
+ } else {
+ $_SERVER[$key] = $value;
+ }
+ }
+ }
+
+ /**
+ * Check the keys and properties in the given map to include
+ * exist, albeit not exclusively, within the map to check.
+ */
+ protected function assertArrayMapIncludes(array $mapToInclude, array $mapToCheck, string $message = ''): void