66
77/**
88 * @method static \GuzzleHttp\Promise\PromiseInterface response($body = null, $status = 200, $headers = [])
9- * @method static \Illuminate\Http\Client\Factory fake($callback = null)
109 * @method static \Illuminate\Http\Client\PendingRequest accept(string $contentType)
1110 * @method static \Illuminate\Http\Client\PendingRequest acceptJson()
1211 * @method static \Illuminate\Http\Client\PendingRequest asForm()
4342 * @method static \Illuminate\Http\Client\Response post(string $url, array $data = [])
4443 * @method static \Illuminate\Http\Client\Response put(string $url, array $data = [])
4544 * @method static \Illuminate\Http\Client\Response send(string $method, string $url, array $options = [])
46- * @method static \Illuminate\Http\Client\ResponseSequence fakeSequence(string $urlPattern = '*')
4745 * @method static void assertSent(callable $callback)
4846 * @method static void assertSentInOrder(array $callbacks)
4947 * @method static void assertNotSent(callable $callback)
@@ -64,4 +62,46 @@ protected static function getFacadeAccessor()
6462 {
6563 return Factory::class;
6664 }
65+
66+ /**
67+ * Register a stub callable that will intercept requests and be able to return stub responses.
68+ *
69+ * @param \Closure|array $callback
70+ * @return \Illuminate\Http\Client\Factory
71+ */
72+ public static function fake ($ callback = null )
73+ {
74+ return tap (static ::getFacadeRoot (), function ($ fake ) use ($ callback ) {
75+ static ::swap ($ fake ->fake ($ callback ));
76+ });
77+ }
78+
79+ /**
80+ * Register a response sequence for the given URL pattern.
81+ *
82+ * @param string $urlPattern
83+ * @return \Illuminate\Http\Client\ResponseSequence
84+ */
85+ public static function fakeSequence (string $ urlPattern = '* ' )
86+ {
87+ $ fake = tap (static ::getFacadeRoot (), function ($ fake ) {
88+ static ::swap ($ fake );
89+ });
90+
91+ return $ fake ->fakeSequence ($ urlPattern );
92+ }
93+
94+ /**
95+ * Stub the given URL using the given callback.
96+ *
97+ * @param string $url
98+ * @param \Illuminate\Http\Client\Response|\GuzzleHttp\Promise\PromiseInterface|callable $callback
99+ * @return \Illuminate\Http\Client\Factory
100+ */
101+ public static function stubUrl ($ url , $ callback )
102+ {
103+ return tap (static ::getFacadeRoot (), function ($ fake ) use ($ url , $ callback ) {
104+ static ::swap ($ fake ->stubUrl ($ url , $ callback ));
105+ });
106+ }
67107}
0 commit comments