PHP Classes

File: tests/api/Create/AndFindArticleCept.php

Recommend this page to a friend!
  Classes of Gjero Krsteski  >  PHP Nuclear Reactor  >  tests/api/Create/AndFindArticleCept.php  >  Download  
File: tests/api/Create/AndFindArticleCept.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Nuclear Reactor
Asynchronous RESTful API using ReactPHP and PIMF
Author: By
Last change: Update of tests/api/Create/AndFindArticleCept.php
Date: 2 years ago
Size: 680 bytes
 

Contents

Class file image Download
<?php
$I
= new ApiTester($scenario);
$I->wantTo('create a article via API and find a article via api');
$I->haveHttpHeader('Content-Type', 'application/x-www-form-urlencoded');
$I->sendPOST('/articles', ['title' => 'test title', 'content' => 'test content']);
$I->seeResponseCodeIs(201);
$I->seeResponseIsJson();
$I->seeResponseContains('newId');
$I->seeResponseMatchesJsonType(['newId' => 'integer']);

$body = json_decode($I->grabResponse());

$I->sendGET('/articles/'.$body->newId);
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseMatchesJsonType(
    [
       
'id' => 'integer',
       
'title' => 'string',
       
'content' => 'string',
    ]
);

For more information send a message to info at phpclasses dot org.