Exemplo n.º 1
0
 public function testWatchuser()
 {
     $obj = new BlockOptions();
     $this->assertEquals(false, $obj->getWatchuser());
     $this->assertEquals($obj, $obj->setWatchuser(true));
     $this->assertEquals(true, $obj->getWatchuser());
 }
Exemplo n.º 2
0
 /**
  * @since 0.3
  *
  * @param User|string $user
  * @param BlockOptions $options
  *
  * @throws InvalidArgumentException
  * @return bool
  */
 public function block($user, BlockOptions $options = null)
 {
     if (!$user instanceof User && !is_string($user)) {
         throw new InvalidArgumentException('$user must be either a string or User object');
     }
     if ($user instanceof User) {
         $user = $user->getName();
     }
     $params = array('user' => $user, 'token' => $this->api->getToken('block'));
     if ($options->getExpiry() !== 'never') {
         $params['expiry'] = $options->getExpiry();
     }
     $reason = $options->getReason();
     if (!empty($reason)) {
         $params['reason'] = $reason;
     }
     if ($options->getAllowusertalk()) {
         $params['allowusertalk'] = '';
     }
     if ($options->getAnononly()) {
         $params['allowusertalk'] = '';
     }
     if ($options->getAutoblock()) {
         $params['allowusertalk'] = '';
     }
     if ($options->getHidename()) {
         $params['allowusertalk'] = '';
     }
     if ($options->getNocreate()) {
         $params['allowusertalk'] = '';
     }
     if ($options->getNoemail()) {
         $params['allowusertalk'] = '';
     }
     if ($options->getReblock()) {
         $params['allowusertalk'] = '';
     }
     if ($options->getWatchuser()) {
         $params['allowusertalk'] = '';
     }
     $this->api->postRequest(new SimpleRequest('block', $params));
     return true;
 }