示例#1
0
文件: TaskTest.php 项目: weew/interop
 public function test_create_from_request()
 {
     $request = new HttpRequest();
     $request->setContent('foo');
     $task = FakeTask::fromHttpRequest($request);
     $this->assertEquals('foo', $task->getContent());
 }
示例#2
0
 public function test_getters_and_setters()
 {
     $request = new HttpRequest();
     $data = new JsonData($request, ['foo' => 'bar']);
     $this->assertEquals('bar', $data->get('foo'));
     $this->assertNull($data->get('bar'));
     $data->set('bar', 'foo');
     $this->assertEquals('foo', $data->get('bar'));
     $this->assertFalse($data->has('yolo'));
     $data->set('yolo', 'swag');
     $this->assertTrue($data->has('yolo'));
     $data->remove('yolo');
     $this->assertFalse($data->has('yolo'));
     $data->extend(['foo' => 'foo', 'yolo' => 'swag']);
     $this->assertEquals(['foo' => 'foo', 'bar' => 'foo', 'yolo' => 'swag'], $data->getData());
     $this->assertTrue($data->hasData());
     $request->setContent(null);
     $this->assertFalse($data->hasData());
 }
示例#3
0
 public function test_set_complex_content()
 {
     $response = new HttpRequest();
     $response->setContent([new ArrayableItem('foo'), new ArrayableItem('bar')]);
     $this->assertEquals([['id' => 'foo'], ['id' => 'bar']], $response->getData()->toArray());
 }