/**
  * @vcr users/test-edit-profile-vcr.yml
  */
 public function testEditProfile()
 {
     $result = $this->client->editProfile(array('nickname' => 'JD'));
     $this->assertTrue($result);
     $user = $this->client->getProfile();
     $this->assertSame('JD', $user['nickname']);
 }
 /**
  * @vcr posts/test-new-post-with-utf8-content-vcr.yml
  */
 public function testNewPostWithUtf8Content()
 {
     $postId = (int) $this->client->newPost('Đây là một tiêu đề ở định dạng UTF-8', 'Lorem Ipsum chỉ đơn giản là một đoạn văn bản giả, được dùng vào việc trình bày và dàn trang phục vụ cho in ấn');
     $this->assertGreaterThan(0, $postId);
     $post = $this->client->getPost($postId);
     $this->assertSame('Đây là một tiêu đề ở định dạng UTF-8', $post['post_title']);
     $this->assertSame('Lorem Ipsum chỉ đơn giản là một đoạn văn bản giả, được dùng vào việc trình bày và dàn trang phục vụ cho in ấn', $post['post_content']);
 }
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     // Validate given parameters
     $className = self::className();
     $urlValidator = new UrlValidator(['enableIDN' => extension_loaded('intl')]);
     if (empty($this->endpoint) || !$urlValidator->validate($this->endpoint)) {
         throw new InvalidConfigException("Class \"{$className}\" requires a valid URL to Wordpress XML-RPC API endpoint to be set in \"\$endpoint\" attribute.");
     }
     if (empty($this->username) || empty($this->password)) {
         throw new InvalidConfigException("Class \"{$className}\" requires a valid Wordpress credentials to be set in \"\$username\" and \"\$password\" attributes.");
     }
     if (!is_array($this->proxyConfig)) {
         throw new InvalidConfigException("Class \"{$className}\" requires \"\$proxyConfig\" to be given in array format.");
     }
     if (!is_array($this->httpAuthConfig)) {
         throw new InvalidConfigException("Class \"{$className}\" requires \"\$httpAuthConfig\" to be given in array format.");
     }
     // Create API client
     $this->_clientInstance = new WordpressClient($this->endpoint, $this->username, $this->password);
     $this->_clientInstance->setProxy($this->proxyConfig);
     $this->_clientInstance->setAuth($this->httpAuthConfig);
 }