Skip to content

Commit

Permalink
Rename contracts.
Browse files Browse the repository at this point in the history
  • Loading branch information
overtrue committed Aug 2, 2017
1 parent bf06955 commit f9e5df6
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
File renamed without changes.
37 changes: 37 additions & 0 deletions tests/Kernel/Http/ResponseTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php


namespace EasyWeChat\Tests\Kernel\Http;


use EasyWeChat\Kernel\Http\Response;
use EasyWeChat\Kernel\Support\Collection;
use EasyWeChat\Tests\TestCase;


class ResponseTest extends TestCase
{
public function testBasicFeatures()
{
$response = new Response(200, ['content-type:application/json'], '{"name": "easywechat"}');

$this->assertInstanceOf(\GuzzleHttp\Psr7\Response::class, $response);

$this->assertSame('{"name": "easywechat"}', (string)$response);
$this->assertSame('{"name": "easywechat"}', $response->getBodyContents());
$this->assertSame('{"name":"easywechat"}', $response->toJson());
$this->assertSame(['name' => 'easywechat'], $response->toArray());
$this->assertSame('easywechat', $response->toObject()->name);
$this->assertInstanceOf(Collection::class, $response->toCollection());
$this->assertSame(['name' => 'easywechat'], $response->toCollection()->all());
}

public function testInvalidArrayableContents()
{
$response = new Response(200, [], 'not json string');

$this->assertInstanceOf(\GuzzleHttp\Psr7\Response::class, $response);

$this->assertSame([], $response->toArray());
}
}

0 comments on commit f9e5df6

Please sign in to comment.