Esempio n. 1
0
 public function test_after_call_notifies_friends()
 {
     $twilio = M::spy(TwilioClient::class);
     App::instance(TwilioClient::class, $twilio);
     $user = factory(User::class)->create();
     $number = new PhoneNumber(['number' => TwilioClient::formatNumberFromTwilio($this->afterCallPost['Caller'])]);
     $user->phoneNumbers()->save($number);
     $friend1 = factory(Friend::class)->make();
     $friend2 = factory(Friend::class)->make();
     $friend3 = factory(Friend::class)->make();
     $user->friends()->saveMany([$friend1, $friend2, $friend3]);
     $someoneElse = factory(User::class)->create();
     $someoneElsesFriend = factory(Friend::class)->make();
     $someoneElse->friends()->save($someoneElsesFriend);
     $this->post(route('hook.after-call'), $this->afterCallPost);
     // Awkward, must include text to the owner...
     $twilio->shouldHaveReceived('text')->times(4)->with(M::anyOf($number->number, $friend1->number, $friend2->number, $friend3->number), M::on(function ($message) {
         return strpos($message, $this->afterCallPost['RecordingUrl']) !== false;
     }));
 }
Esempio n. 2
0
 private function notifyOwnerOfRecording($request)
 {
     $this->twilio->text(TwilioClient::formatNumberFromTwilio($request->get("From")), sprintf("New Pulledover.us recording. Number: %s\nFrom: %s %s\nURL: %s\n", $request->get("From"), $request->get("CallerCity"), $request->get("CallerState"), $request->get("RecordingUrl")));
 }