Zendesk\API\LiveTests\TicketsTest::testCreateWithAttachment PHP Méthode

testCreateWithAttachment() public méthode

Tests if the client can call and build the create ticket witch attachment endpoint and initiate the file upload headers and POST data
    public function testCreateWithAttachment()
    {
        $attachmentData = ['file' => getcwd() . '/tests/assets/UK.png', 'name' => 'UK test non-alpha chars.png'];
        $faker = factory::create();
        $ticketParams = ['subject' => $faker->sentence(5), 'comment' => ['body' => $faker->sentence(10)], 'priority' => 'normal'];
        $response = $this->client->tickets()->attach($attachmentData)->create($ticketParams);
        $this->assertNotNull($ticket = $response->ticket);
        $this->assertEquals($ticketParams['subject'], $ticket->subject);
        $this->assertEquals($ticketParams['comment']['body'], $ticket->description);
        $this->assertEquals($ticketParams['priority'], $ticket->priority);
        $attachmentFound = false;
        foreach ($response->audit->events as $event) {
            if (property_exists($event, 'attachments')) {
                $attachmentFound = true;
                break;
            }
        }
        $this->assertTrue($attachmentFound, 'Should have attachment in ticket audits.');
        return $ticket;
    }