Best Atoum code snippet using writer.clear
user_service_pb.php
Source:user_service_pb.php
...32 }33}34namespace google\appengine {35 class UserServiceError extends \google\net\ProtocolMessage {36 public function clear() {37 }38 public function byteSizePartial() {39 $res = 0;40 return $res;41 }42 public function outputPartial($out) {43 }44 public function tryMerge($d) {45 while($d->avail() > 0) {46 $tt = $d->getVarInt32();47 switch ($tt) {48 case 0:49 throw new \google\net\ProtocolBufferDecodeError();50 break;51 default:52 $d->skipData($tt);53 }54 };55 }56 public function checkInitialized() {57 return null;58 }59 public function mergeFrom($x) {60 if ($x === $this) { throw new \IllegalArgumentException('Cannot copy message to itself'); }61 }62 public function equals($x) {63 if ($x === $this) { return true; }64 return true;65 }66 public function shortDebugString($prefix = "") {67 $res = '';68 return $res;69 }70 }71}72namespace google\appengine {73 class CreateLoginURLRequest extends \google\net\ProtocolMessage {74 public function getDestinationUrl() {75 if (!isset($this->destination_url)) {76 return '';77 }78 return $this->destination_url;79 }80 public function setDestinationUrl($val) {81 $this->destination_url = $val;82 return $this;83 }84 public function clearDestinationUrl() {85 unset($this->destination_url);86 return $this;87 }88 public function hasDestinationUrl() {89 return isset($this->destination_url);90 }91 public function getAuthDomain() {92 if (!isset($this->auth_domain)) {93 return '';94 }95 return $this->auth_domain;96 }97 public function setAuthDomain($val) {98 $this->auth_domain = $val;99 return $this;100 }101 public function clearAuthDomain() {102 unset($this->auth_domain);103 return $this;104 }105 public function hasAuthDomain() {106 return isset($this->auth_domain);107 }108 public function getFederatedIdentity() {109 if (!isset($this->federated_identity)) {110 return '';111 }112 return $this->federated_identity;113 }114 public function setFederatedIdentity($val) {115 $this->federated_identity = $val;116 return $this;117 }118 public function clearFederatedIdentity() {119 unset($this->federated_identity);120 return $this;121 }122 public function hasFederatedIdentity() {123 return isset($this->federated_identity);124 }125 public function clear() {126 $this->clearDestinationUrl();127 $this->clearAuthDomain();128 $this->clearFederatedIdentity();129 }130 public function byteSizePartial() {131 $res = 0;132 if (isset($this->destination_url)) {133 $res += 1;134 $res += $this->lengthString(strlen($this->destination_url));135 }136 if (isset($this->auth_domain)) {137 $res += 1;138 $res += $this->lengthString(strlen($this->auth_domain));139 }140 if (isset($this->federated_identity)) {141 $res += 1;142 $res += $this->lengthString(strlen($this->federated_identity));143 }144 return $res;145 }146 public function outputPartial($out) {147 if (isset($this->destination_url)) {148 $out->putVarInt32(10);149 $out->putPrefixedString($this->destination_url);150 }151 if (isset($this->auth_domain)) {152 $out->putVarInt32(18);153 $out->putPrefixedString($this->auth_domain);154 }155 if (isset($this->federated_identity)) {156 $out->putVarInt32(26);157 $out->putPrefixedString($this->federated_identity);158 }159 }160 public function tryMerge($d) {161 while($d->avail() > 0) {162 $tt = $d->getVarInt32();163 switch ($tt) {164 case 10:165 $length = $d->getVarInt32();166 $this->setDestinationUrl(substr($d->buffer(), $d->pos(), $length));167 $d->skip($length);168 break;169 case 18:170 $length = $d->getVarInt32();171 $this->setAuthDomain(substr($d->buffer(), $d->pos(), $length));172 $d->skip($length);173 break;174 case 26:175 $length = $d->getVarInt32();176 $this->setFederatedIdentity(substr($d->buffer(), $d->pos(), $length));177 $d->skip($length);178 break;179 case 0:180 throw new \google\net\ProtocolBufferDecodeError();181 break;182 default:183 $d->skipData($tt);184 }185 };186 }187 public function checkInitialized() {188 if (!isset($this->destination_url)) return 'destination_url';189 return null;190 }191 public function mergeFrom($x) {192 if ($x === $this) { throw new \IllegalArgumentException('Cannot copy message to itself'); }193 if ($x->hasDestinationUrl()) {194 $this->setDestinationUrl($x->getDestinationUrl());195 }196 if ($x->hasAuthDomain()) {197 $this->setAuthDomain($x->getAuthDomain());198 }199 if ($x->hasFederatedIdentity()) {200 $this->setFederatedIdentity($x->getFederatedIdentity());201 }202 }203 public function equals($x) {204 if ($x === $this) { return true; }205 if (isset($this->destination_url) !== isset($x->destination_url)) return false;206 if (isset($this->destination_url) && $this->destination_url !== $x->destination_url) return false;207 if (isset($this->auth_domain) !== isset($x->auth_domain)) return false;208 if (isset($this->auth_domain) && $this->auth_domain !== $x->auth_domain) return false;209 if (isset($this->federated_identity) !== isset($x->federated_identity)) return false;210 if (isset($this->federated_identity) && $this->federated_identity !== $x->federated_identity) return false;211 return true;212 }213 public function shortDebugString($prefix = "") {214 $res = '';215 if (isset($this->destination_url)) {216 $res .= $prefix . "destination_url: " . $this->debugFormatString($this->destination_url) . "\n";217 }218 if (isset($this->auth_domain)) {219 $res .= $prefix . "auth_domain: " . $this->debugFormatString($this->auth_domain) . "\n";220 }221 if (isset($this->federated_identity)) {222 $res .= $prefix . "federated_identity: " . $this->debugFormatString($this->federated_identity) . "\n";223 }224 return $res;225 }226 }227}228namespace google\appengine {229 class CreateLoginURLResponse extends \google\net\ProtocolMessage {230 public function getLoginUrl() {231 if (!isset($this->login_url)) {232 return '';233 }234 return $this->login_url;235 }236 public function setLoginUrl($val) {237 $this->login_url = $val;238 return $this;239 }240 public function clearLoginUrl() {241 unset($this->login_url);242 return $this;243 }244 public function hasLoginUrl() {245 return isset($this->login_url);246 }247 public function clear() {248 $this->clearLoginUrl();249 }250 public function byteSizePartial() {251 $res = 0;252 if (isset($this->login_url)) {253 $res += 1;254 $res += $this->lengthString(strlen($this->login_url));255 }256 return $res;257 }258 public function outputPartial($out) {259 if (isset($this->login_url)) {260 $out->putVarInt32(10);261 $out->putPrefixedString($this->login_url);262 }263 }264 public function tryMerge($d) {265 while($d->avail() > 0) {266 $tt = $d->getVarInt32();267 switch ($tt) {268 case 10:269 $length = $d->getVarInt32();270 $this->setLoginUrl(substr($d->buffer(), $d->pos(), $length));271 $d->skip($length);272 break;273 case 0:274 throw new \google\net\ProtocolBufferDecodeError();275 break;276 default:277 $d->skipData($tt);278 }279 };280 }281 public function checkInitialized() {282 return null;283 }284 public function mergeFrom($x) {285 if ($x === $this) { throw new \IllegalArgumentException('Cannot copy message to itself'); }286 if ($x->hasLoginUrl()) {287 $this->setLoginUrl($x->getLoginUrl());288 }289 }290 public function equals($x) {291 if ($x === $this) { return true; }292 if (isset($this->login_url) !== isset($x->login_url)) return false;293 if (isset($this->login_url) && $this->login_url !== $x->login_url) return false;294 return true;295 }296 public function shortDebugString($prefix = "") {297 $res = '';298 if (isset($this->login_url)) {299 $res .= $prefix . "login_url: " . $this->debugFormatString($this->login_url) . "\n";300 }301 return $res;302 }303 }304}305namespace google\appengine {306 class CreateLogoutURLRequest extends \google\net\ProtocolMessage {307 public function getDestinationUrl() {308 if (!isset($this->destination_url)) {309 return '';310 }311 return $this->destination_url;312 }313 public function setDestinationUrl($val) {314 $this->destination_url = $val;315 return $this;316 }317 public function clearDestinationUrl() {318 unset($this->destination_url);319 return $this;320 }321 public function hasDestinationUrl() {322 return isset($this->destination_url);323 }324 public function getAuthDomain() {325 if (!isset($this->auth_domain)) {326 return '';327 }328 return $this->auth_domain;329 }330 public function setAuthDomain($val) {331 $this->auth_domain = $val;332 return $this;333 }334 public function clearAuthDomain() {335 unset($this->auth_domain);336 return $this;337 }338 public function hasAuthDomain() {339 return isset($this->auth_domain);340 }341 public function clear() {342 $this->clearDestinationUrl();343 $this->clearAuthDomain();344 }345 public function byteSizePartial() {346 $res = 0;347 if (isset($this->destination_url)) {348 $res += 1;349 $res += $this->lengthString(strlen($this->destination_url));350 }351 if (isset($this->auth_domain)) {352 $res += 1;353 $res += $this->lengthString(strlen($this->auth_domain));354 }355 return $res;356 }357 public function outputPartial($out) {358 if (isset($this->destination_url)) {359 $out->putVarInt32(10);360 $out->putPrefixedString($this->destination_url);361 }362 if (isset($this->auth_domain)) {363 $out->putVarInt32(18);364 $out->putPrefixedString($this->auth_domain);365 }366 }367 public function tryMerge($d) {368 while($d->avail() > 0) {369 $tt = $d->getVarInt32();370 switch ($tt) {371 case 10:372 $length = $d->getVarInt32();373 $this->setDestinationUrl(substr($d->buffer(), $d->pos(), $length));374 $d->skip($length);375 break;376 case 18:377 $length = $d->getVarInt32();378 $this->setAuthDomain(substr($d->buffer(), $d->pos(), $length));379 $d->skip($length);380 break;381 case 0:382 throw new \google\net\ProtocolBufferDecodeError();383 break;384 default:385 $d->skipData($tt);386 }387 };388 }389 public function checkInitialized() {390 if (!isset($this->destination_url)) return 'destination_url';391 return null;392 }393 public function mergeFrom($x) {394 if ($x === $this) { throw new \IllegalArgumentException('Cannot copy message to itself'); }395 if ($x->hasDestinationUrl()) {396 $this->setDestinationUrl($x->getDestinationUrl());397 }398 if ($x->hasAuthDomain()) {399 $this->setAuthDomain($x->getAuthDomain());400 }401 }402 public function equals($x) {403 if ($x === $this) { return true; }404 if (isset($this->destination_url) !== isset($x->destination_url)) return false;405 if (isset($this->destination_url) && $this->destination_url !== $x->destination_url) return false;406 if (isset($this->auth_domain) !== isset($x->auth_domain)) return false;407 if (isset($this->auth_domain) && $this->auth_domain !== $x->auth_domain) return false;408 return true;409 }410 public function shortDebugString($prefix = "") {411 $res = '';412 if (isset($this->destination_url)) {413 $res .= $prefix . "destination_url: " . $this->debugFormatString($this->destination_url) . "\n";414 }415 if (isset($this->auth_domain)) {416 $res .= $prefix . "auth_domain: " . $this->debugFormatString($this->auth_domain) . "\n";417 }418 return $res;419 }420 }421}422namespace google\appengine {423 class CreateLogoutURLResponse extends \google\net\ProtocolMessage {424 public function getLogoutUrl() {425 if (!isset($this->logout_url)) {426 return '';427 }428 return $this->logout_url;429 }430 public function setLogoutUrl($val) {431 $this->logout_url = $val;432 return $this;433 }434 public function clearLogoutUrl() {435 unset($this->logout_url);436 return $this;437 }438 public function hasLogoutUrl() {439 return isset($this->logout_url);440 }441 public function clear() {442 $this->clearLogoutUrl();443 }444 public function byteSizePartial() {445 $res = 0;446 if (isset($this->logout_url)) {447 $res += 1;448 $res += $this->lengthString(strlen($this->logout_url));449 }450 return $res;451 }452 public function outputPartial($out) {453 if (isset($this->logout_url)) {454 $out->putVarInt32(10);455 $out->putPrefixedString($this->logout_url);456 }457 }458 public function tryMerge($d) {459 while($d->avail() > 0) {460 $tt = $d->getVarInt32();461 switch ($tt) {462 case 10:463 $length = $d->getVarInt32();464 $this->setLogoutUrl(substr($d->buffer(), $d->pos(), $length));465 $d->skip($length);466 break;467 case 0:468 throw new \google\net\ProtocolBufferDecodeError();469 break;470 default:471 $d->skipData($tt);472 }473 };474 }475 public function checkInitialized() {476 return null;477 }478 public function mergeFrom($x) {479 if ($x === $this) { throw new \IllegalArgumentException('Cannot copy message to itself'); }480 if ($x->hasLogoutUrl()) {481 $this->setLogoutUrl($x->getLogoutUrl());482 }483 }484 public function equals($x) {485 if ($x === $this) { return true; }486 if (isset($this->logout_url) !== isset($x->logout_url)) return false;487 if (isset($this->logout_url) && $this->logout_url !== $x->logout_url) return false;488 return true;489 }490 public function shortDebugString($prefix = "") {491 $res = '';492 if (isset($this->logout_url)) {493 $res .= $prefix . "logout_url: " . $this->debugFormatString($this->logout_url) . "\n";494 }495 return $res;496 }497 }498}499namespace google\appengine {500 class GetOAuthUserRequest extends \google\net\ProtocolMessage {501 private $scopes = array();502 public function getScope() {503 if (!isset($this->scope)) {504 return '';505 }506 return $this->scope;507 }508 public function setScope($val) {509 $this->scope = $val;510 return $this;511 }512 public function clearScope() {513 unset($this->scope);514 return $this;515 }516 public function hasScope() {517 return isset($this->scope);518 }519 public function getScopesSize() {520 return sizeof($this->scopes);521 }522 public function getScopesList() {523 return $this->scopes;524 }525 public function getScopes($idx) {526 return $this->scopes[$idx];527 }528 public function setScopes($idx, $val) {529 $this->scopes[$idx] = $val;530 return $this;531 }532 public function addScopes($val) {533 $this->scopes[] = $val;534 return $this;535 }536 public function clearScopes() {537 $this->scopes = array();538 }539 public function getRequestWriterPermission() {540 if (!isset($this->request_writer_permission)) {541 return false;542 }543 return $this->request_writer_permission;544 }545 public function setRequestWriterPermission($val) {546 $this->request_writer_permission = $val;547 return $this;548 }549 public function clearRequestWriterPermission() {550 unset($this->request_writer_permission);551 return $this;552 }553 public function hasRequestWriterPermission() {554 return isset($this->request_writer_permission);555 }556 public function clear() {557 $this->clearScope();558 $this->clearScopes();559 $this->clearRequestWriterPermission();560 }561 public function byteSizePartial() {562 $res = 0;563 if (isset($this->scope)) {564 $res += 1;565 $res += $this->lengthString(strlen($this->scope));566 }567 $this->checkProtoArray($this->scopes);568 $res += 1 * sizeof($this->scopes);569 foreach ($this->scopes as $value) {570 $res += $this->lengthString(strlen($value));571 }572 if (isset($this->request_writer_permission)) {573 $res += 2;574 }575 return $res;576 }577 public function outputPartial($out) {578 if (isset($this->scope)) {579 $out->putVarInt32(10);580 $out->putPrefixedString($this->scope);581 }582 $this->checkProtoArray($this->scopes);583 foreach ($this->scopes as $value) {584 $out->putVarInt32(18);585 $out->putPrefixedString($value);586 }587 if (isset($this->request_writer_permission)) {588 $out->putVarInt32(24);589 $out->putBoolean($this->request_writer_permission);590 }591 }592 public function tryMerge($d) {593 while($d->avail() > 0) {594 $tt = $d->getVarInt32();595 switch ($tt) {596 case 10:597 $length = $d->getVarInt32();598 $this->setScope(substr($d->buffer(), $d->pos(), $length));599 $d->skip($length);600 break;601 case 18:602 $length = $d->getVarInt32();603 $this->addScopes(substr($d->buffer(), $d->pos(), $length));604 $d->skip($length);605 break;606 case 24:607 $this->setRequestWriterPermission($d->getBoolean());608 break;609 case 0:610 throw new \google\net\ProtocolBufferDecodeError();611 break;612 default:613 $d->skipData($tt);614 }615 };616 }617 public function checkInitialized() {618 return null;619 }620 public function mergeFrom($x) {621 if ($x === $this) { throw new \IllegalArgumentException('Cannot copy message to itself'); }622 if ($x->hasScope()) {623 $this->setScope($x->getScope());624 }625 foreach ($x->getScopesList() as $v) {626 $this->addScopes($v);627 }628 if ($x->hasRequestWriterPermission()) {629 $this->setRequestWriterPermission($x->getRequestWriterPermission());630 }631 }632 public function equals($x) {633 if ($x === $this) { return true; }634 if (isset($this->scope) !== isset($x->scope)) return false;635 if (isset($this->scope) && $this->scope !== $x->scope) return false;636 if (sizeof($this->scopes) !== sizeof($x->scopes)) return false;637 foreach (array_map(null, $this->scopes, $x->scopes) as $v) {638 if ($v[0] !== $v[1]) return false;639 }640 if (isset($this->request_writer_permission) !== isset($x->request_writer_permission)) return false;641 if (isset($this->request_writer_permission) && $this->request_writer_permission !== $x->request_writer_permission) return false;642 return true;643 }644 public function shortDebugString($prefix = "") {645 $res = '';646 if (isset($this->scope)) {647 $res .= $prefix . "scope: " . $this->debugFormatString($this->scope) . "\n";648 }649 foreach ($this->scopes as $value) {650 $res .= $prefix . "scopes: " . $this->debugFormatString($value) . "\n";651 }652 if (isset($this->request_writer_permission)) {653 $res .= $prefix . "request_writer_permission: " . $this->debugFormatBool($this->request_writer_permission) . "\n";654 }655 return $res;656 }657 }658}659namespace google\appengine {660 class GetOAuthUserResponse extends \google\net\ProtocolMessage {661 private $scopes = array();662 public function getEmail() {663 if (!isset($this->email)) {664 return '';665 }666 return $this->email;667 }668 public function setEmail($val) {669 $this->email = $val;670 return $this;671 }672 public function clearEmail() {673 unset($this->email);674 return $this;675 }676 public function hasEmail() {677 return isset($this->email);678 }679 public function getUserId() {680 if (!isset($this->user_id)) {681 return '';682 }683 return $this->user_id;684 }685 public function setUserId($val) {686 $this->user_id = $val;687 return $this;688 }689 public function clearUserId() {690 unset($this->user_id);691 return $this;692 }693 public function hasUserId() {694 return isset($this->user_id);695 }696 public function getAuthDomain() {697 if (!isset($this->auth_domain)) {698 return '';699 }700 return $this->auth_domain;701 }702 public function setAuthDomain($val) {703 $this->auth_domain = $val;704 return $this;705 }706 public function clearAuthDomain() {707 unset($this->auth_domain);708 return $this;709 }710 public function hasAuthDomain() {711 return isset($this->auth_domain);712 }713 public function getUserOrganization() {714 if (!isset($this->user_organization)) {715 return '';716 }717 return $this->user_organization;718 }719 public function setUserOrganization($val) {720 $this->user_organization = $val;721 return $this;722 }723 public function clearUserOrganization() {724 unset($this->user_organization);725 return $this;726 }727 public function hasUserOrganization() {728 return isset($this->user_organization);729 }730 public function getIsAdmin() {731 if (!isset($this->is_admin)) {732 return false;733 }734 return $this->is_admin;735 }736 public function setIsAdmin($val) {737 $this->is_admin = $val;738 return $this;739 }740 public function clearIsAdmin() {741 unset($this->is_admin);742 return $this;743 }744 public function hasIsAdmin() {745 return isset($this->is_admin);746 }747 public function getClientId() {748 if (!isset($this->client_id)) {749 return '';750 }751 return $this->client_id;752 }753 public function setClientId($val) {754 $this->client_id = $val;755 return $this;756 }757 public function clearClientId() {758 unset($this->client_id);759 return $this;760 }761 public function hasClientId() {762 return isset($this->client_id);763 }764 public function getScopesSize() {765 return sizeof($this->scopes);766 }767 public function getScopesList() {768 return $this->scopes;769 }770 public function getScopes($idx) {771 return $this->scopes[$idx];772 }773 public function setScopes($idx, $val) {774 $this->scopes[$idx] = $val;775 return $this;776 }777 public function addScopes($val) {778 $this->scopes[] = $val;779 return $this;780 }781 public function clearScopes() {782 $this->scopes = array();783 }784 public function getIsProjectWriter() {785 if (!isset($this->is_project_writer)) {786 return false;787 }788 return $this->is_project_writer;789 }790 public function setIsProjectWriter($val) {791 $this->is_project_writer = $val;792 return $this;793 }794 public function clearIsProjectWriter() {795 unset($this->is_project_writer);796 return $this;797 }798 public function hasIsProjectWriter() {799 return isset($this->is_project_writer);800 }801 public function clear() {802 $this->clearEmail();803 $this->clearUserId();804 $this->clearAuthDomain();805 $this->clearUserOrganization();806 $this->clearIsAdmin();807 $this->clearClientId();808 $this->clearScopes();809 $this->clearIsProjectWriter();810 }811 public function byteSizePartial() {812 $res = 0;813 if (isset($this->email)) {814 $res += 1;815 $res += $this->lengthString(strlen($this->email));816 }817 if (isset($this->user_id)) {818 $res += 1;819 $res += $this->lengthString(strlen($this->user_id));820 }821 if (isset($this->auth_domain)) {822 $res += 1;823 $res += $this->lengthString(strlen($this->auth_domain));824 }825 if (isset($this->user_organization)) {826 $res += 1;827 $res += $this->lengthString(strlen($this->user_organization));828 }829 if (isset($this->is_admin)) {830 $res += 2;831 }832 if (isset($this->client_id)) {833 $res += 1;834 $res += $this->lengthString(strlen($this->client_id));835 }836 $this->checkProtoArray($this->scopes);837 $res += 1 * sizeof($this->scopes);838 foreach ($this->scopes as $value) {839 $res += $this->lengthString(strlen($value));840 }841 if (isset($this->is_project_writer)) {842 $res += 2;843 }844 return $res;845 }846 public function outputPartial($out) {847 if (isset($this->email)) {848 $out->putVarInt32(10);849 $out->putPrefixedString($this->email);850 }851 if (isset($this->user_id)) {852 $out->putVarInt32(18);853 $out->putPrefixedString($this->user_id);854 }855 if (isset($this->auth_domain)) {856 $out->putVarInt32(26);857 $out->putPrefixedString($this->auth_domain);858 }859 if (isset($this->user_organization)) {860 $out->putVarInt32(34);861 $out->putPrefixedString($this->user_organization);862 }863 if (isset($this->is_admin)) {864 $out->putVarInt32(40);865 $out->putBoolean($this->is_admin);866 }867 if (isset($this->client_id)) {868 $out->putVarInt32(50);869 $out->putPrefixedString($this->client_id);870 }871 $this->checkProtoArray($this->scopes);872 foreach ($this->scopes as $value) {873 $out->putVarInt32(58);874 $out->putPrefixedString($value);875 }876 if (isset($this->is_project_writer)) {877 $out->putVarInt32(64);878 $out->putBoolean($this->is_project_writer);879 }880 }881 public function tryMerge($d) {882 while($d->avail() > 0) {883 $tt = $d->getVarInt32();884 switch ($tt) {885 case 10:886 $length = $d->getVarInt32();887 $this->setEmail(substr($d->buffer(), $d->pos(), $length));888 $d->skip($length);889 break;890 case 18:891 $length = $d->getVarInt32();892 $this->setUserId(substr($d->buffer(), $d->pos(), $length));893 $d->skip($length);894 break;895 case 26:896 $length = $d->getVarInt32();897 $this->setAuthDomain(substr($d->buffer(), $d->pos(), $length));898 $d->skip($length);899 break;900 case 34:901 $length = $d->getVarInt32();902 $this->setUserOrganization(substr($d->buffer(), $d->pos(), $length));903 $d->skip($length);904 break;905 case 40:906 $this->setIsAdmin($d->getBoolean());907 break;908 case 50:909 $length = $d->getVarInt32();910 $this->setClientId(substr($d->buffer(), $d->pos(), $length));911 $d->skip($length);912 break;913 case 58:914 $length = $d->getVarInt32();915 $this->addScopes(substr($d->buffer(), $d->pos(), $length));916 $d->skip($length);917 break;918 case 64:919 $this->setIsProjectWriter($d->getBoolean());920 break;921 case 0:922 throw new \google\net\ProtocolBufferDecodeError();923 break;924 default:925 $d->skipData($tt);926 }927 };928 }929 public function checkInitialized() {930 return null;931 }932 public function mergeFrom($x) {933 if ($x === $this) { throw new \IllegalArgumentException('Cannot copy message to itself'); }934 if ($x->hasEmail()) {935 $this->setEmail($x->getEmail());936 }937 if ($x->hasUserId()) {938 $this->setUserId($x->getUserId());939 }940 if ($x->hasAuthDomain()) {941 $this->setAuthDomain($x->getAuthDomain());942 }943 if ($x->hasUserOrganization()) {944 $this->setUserOrganization($x->getUserOrganization());945 }946 if ($x->hasIsAdmin()) {947 $this->setIsAdmin($x->getIsAdmin());948 }949 if ($x->hasClientId()) {950 $this->setClientId($x->getClientId());951 }952 foreach ($x->getScopesList() as $v) {953 $this->addScopes($v);954 }955 if ($x->hasIsProjectWriter()) {956 $this->setIsProjectWriter($x->getIsProjectWriter());957 }958 }959 public function equals($x) {960 if ($x === $this) { return true; }961 if (isset($this->email) !== isset($x->email)) return false;962 if (isset($this->email) && $this->email !== $x->email) return false;963 if (isset($this->user_id) !== isset($x->user_id)) return false;964 if (isset($this->user_id) && $this->user_id !== $x->user_id) return false;965 if (isset($this->auth_domain) !== isset($x->auth_domain)) return false;966 if (isset($this->auth_domain) && $this->auth_domain !== $x->auth_domain) return false;967 if (isset($this->user_organization) !== isset($x->user_organization)) return false;968 if (isset($this->user_organization) && $this->user_organization !== $x->user_organization) return false;969 if (isset($this->is_admin) !== isset($x->is_admin)) return false;970 if (isset($this->is_admin) && $this->is_admin !== $x->is_admin) return false;971 if (isset($this->client_id) !== isset($x->client_id)) return false;972 if (isset($this->client_id) && $this->client_id !== $x->client_id) return false;973 if (sizeof($this->scopes) !== sizeof($x->scopes)) return false;974 foreach (array_map(null, $this->scopes, $x->scopes) as $v) {975 if ($v[0] !== $v[1]) return false;976 }977 if (isset($this->is_project_writer) !== isset($x->is_project_writer)) return false;978 if (isset($this->is_project_writer) && $this->is_project_writer !== $x->is_project_writer) return false;979 return true;980 }981 public function shortDebugString($prefix = "") {982 $res = '';983 if (isset($this->email)) {984 $res .= $prefix . "email: " . $this->debugFormatString($this->email) . "\n";985 }986 if (isset($this->user_id)) {987 $res .= $prefix . "user_id: " . $this->debugFormatString($this->user_id) . "\n";988 }989 if (isset($this->auth_domain)) {990 $res .= $prefix . "auth_domain: " . $this->debugFormatString($this->auth_domain) . "\n";991 }992 if (isset($this->user_organization)) {993 $res .= $prefix . "user_organization: " . $this->debugFormatString($this->user_organization) . "\n";994 }995 if (isset($this->is_admin)) {996 $res .= $prefix . "is_admin: " . $this->debugFormatBool($this->is_admin) . "\n";997 }998 if (isset($this->client_id)) {999 $res .= $prefix . "client_id: " . $this->debugFormatString($this->client_id) . "\n";1000 }1001 foreach ($this->scopes as $value) {1002 $res .= $prefix . "scopes: " . $this->debugFormatString($value) . "\n";1003 }1004 if (isset($this->is_project_writer)) {1005 $res .= $prefix . "is_project_writer: " . $this->debugFormatBool($this->is_project_writer) . "\n";1006 }1007 return $res;1008 }1009 }1010}1011namespace google\appengine {1012 class CheckOAuthSignatureRequest extends \google\net\ProtocolMessage {1013 public function clear() {1014 }1015 public function byteSizePartial() {1016 $res = 0;1017 return $res;1018 }1019 public function outputPartial($out) {1020 }1021 public function tryMerge($d) {1022 while($d->avail() > 0) {1023 $tt = $d->getVarInt32();1024 switch ($tt) {1025 case 0:1026 throw new \google\net\ProtocolBufferDecodeError();1027 break;1028 default:1029 $d->skipData($tt);1030 }1031 };1032 }1033 public function checkInitialized() {1034 return null;1035 }1036 public function mergeFrom($x) {1037 if ($x === $this) { throw new \IllegalArgumentException('Cannot copy message to itself'); }1038 }1039 public function equals($x) {1040 if ($x === $this) { return true; }1041 return true;1042 }1043 public function shortDebugString($prefix = "") {1044 $res = '';1045 return $res;1046 }1047 }1048}1049namespace google\appengine {1050 class CheckOAuthSignatureResponse extends \google\net\ProtocolMessage {1051 public function getOauthConsumerKey() {1052 if (!isset($this->oauth_consumer_key)) {1053 return '';1054 }1055 return $this->oauth_consumer_key;1056 }1057 public function setOauthConsumerKey($val) {1058 $this->oauth_consumer_key = $val;1059 return $this;1060 }1061 public function clearOauthConsumerKey() {1062 unset($this->oauth_consumer_key);1063 return $this;1064 }1065 public function hasOauthConsumerKey() {1066 return isset($this->oauth_consumer_key);1067 }1068 public function clear() {1069 $this->clearOauthConsumerKey();1070 }1071 public function byteSizePartial() {1072 $res = 0;1073 if (isset($this->oauth_consumer_key)) {1074 $res += 1;1075 $res += $this->lengthString(strlen($this->oauth_consumer_key));1076 }1077 return $res;1078 }1079 public function outputPartial($out) {1080 if (isset($this->oauth_consumer_key)) {1081 $out->putVarInt32(10);1082 $out->putPrefixedString($this->oauth_consumer_key);1083 }...
script.php
Source:script.php
...26 $defaultInfoWriter = new writers\std\out(),27 $defaultInfoWriter28 ->addDecorator(new writer\decorators\rtrim())29 ->addDecorator(new writer\decorators\eol())30 ->addDecorator(new atoum\cli\clear()),31 $defaultWarningWriter = new writers\std\err(),32 $defaultWarningWriter33 ->addDecorator(new writer\decorators\trim())34 ->addDecorator(new writer\decorators\prompt('Warning: '))35 ->addDecorator(new writer\decorators\eol())36 ->addDecorator(new atoum\cli\clear()),37 $defaultErrorWriter = new writers\std\err(),38 $defaultErrorWriter39 ->addDecorator(new writer\decorators\trim())40 ->addDecorator(new writer\decorators\prompt('Error: '))41 ->addDecorator(new writer\decorators\eol())42 ->addDecorator(new atoum\cli\clear()),43 $defaultHelpWriter = new writers\std\out(),44 $defaultHelpWriter45 ->addDecorator($labelColorizer)46 ->addDecorator($valueColorizer)47 ->addDecorator($argumentColorizer)48 ->addDecorator(new writer\decorators\rtrim())49 ->addDecorator(new writer\decorators\eol())50 ->addDecorator(new atoum\cli\clear())51 )52 ->if($script = new mock\script($name = uniqid()))53 ->then54 ->string($script->getName())->isEqualTo($name)55 ->object($script->getAdapter())->isInstanceOf(atoum\adapter::class)56 ->object($script->getLocale())->isInstanceOf(atoum\locale::class)57 ->object($script->getArgumentsParser())->isInstanceOf(atoum\script\arguments\parser::class)58 ->object($script->getOutputWriter())->isEqualTo($defaultOutputWriter)59 ->object($script->getInfoWriter())->isEqualTo($defaultInfoWriter)60 ->object($script->getErrorWriter())->isEqualTo($defaultErrorWriter)61 ->object($script->getWarningWriter())->isEqualTo($defaultWarningWriter)62 ->object($script->getHelpWriter())->isEqualTo($defaultHelpWriter)63 ->array($script->getHelp())->isEmpty()64 ->object($script->getCli())->isEqualTo(new atoum\cli())65 ->integer($script->getVerbosityLevel())->isZero()66 ->and($script = new mock\script($name = uniqid(), $adapter = new atoum\adapter()))67 ->then68 ->string($script->getName())->isEqualTo($name)69 ->object($script->getAdapter())->isIdenticalTo($adapter)70 ->object($script->getLocale())->isInstanceOf(atoum\locale::class)71 ->object($script->getArgumentsParser())->isInstanceOf(atoum\script\arguments\parser::class)72 ->object($script->getOutputWriter())->isEqualTo($defaultOutputWriter)73 ->object($script->getInfoWriter())->isEqualTo($defaultInfoWriter)74 ->object($script->getErrorWriter())->isEqualTo($defaultErrorWriter)75 ->object($script->getWarningWriter())->isEqualTo($defaultWarningWriter)76 ->object($script->getHelpWriter())->isEqualTo($defaultHelpWriter)77 ->array($script->getHelp())->isEmpty()78 ->object($script->getCli())->isEqualTo(new atoum\cli())79 ->integer($script->getVerbosityLevel())->isZero()80 ->if($adapter = new atoum\test\adapter())81 ->and($adapter->php_sapi_name = uniqid())82 ->then83 ->exception(function () use ($adapter, & $name) {84 new mock\script($name = uniqid(), $adapter);85 })86 ->isInstanceOf(atoum\exceptions\logic::class)87 ->hasMessage('\'' . $name . '\' must be used in CLI only')88 ;89 }90 public function testSetAdapter()91 {92 $this93 ->if($script = new mock\script($name = uniqid()))94 ->then95 ->object($script->setAdapter($adapter = new atoum\adapter()))->isIdenticalTo($script)96 ->object($script->getAdapter())->isIdenticalTo($adapter)97 ;98 }99 public function testSetLocale()100 {101 $this102 ->if($script = new mock\script($name = uniqid()))103 ->then104 ->object($script->setLocale($locale = new atoum\locale()))->isIdenticalTo($script)105 ->object($script->getLocale())->isIdenticalTo($locale)106 ;107 }108 public function testSetCli()109 {110 $this111 ->if($script = new mock\script(uniqid()))112 ->then113 ->object($script->setCli($cli = new atoum\cli()))->isIdenticalTo($script)114 ->object($script->getCli())->isIdenticalTo($cli)115 ->object($script->setCli())->isIdenticalTo($script)116 ->object($script->getCli())117 ->isNotIdenticalTo($cli)118 ->isEqualTo(new atoum\cli())119 ;120 }121 public function testSetArgumentParser()122 {123 $this124 ->if($script = new mock\script($name = uniqid()))125 ->then126 ->object($script->setArgumentsParser($argumentsParser = new atoum\script\arguments\parser()))->isIdenticalTo($script)127 ->object($script->getArgumentsParser())->isIdenticalTo($argumentsParser)128 ;129 }130 public function testSetOutputWriter()131 {132 $this133 ->if($script = new mock\script($name = uniqid()))134 ->then135 ->object($script->setOutputWriter($outputWriter = new writers\std\out()))->isIdenticalTo($script)136 ->object($script->getOutputWriter())->isIdenticalTo($outputWriter)137 ->given(138 $defaultOutputWriter = new writers\std\out()139 )140 ->then141 ->object($script->setOutputWriter())->isIdenticalTo($script)142 ->object($script->getOutputWriter())143 ->isNotIdenticalTo($outputWriter)144 ->isEqualTo($defaultOutputWriter)145 ->object($script->getOutputWriter()->getCli())->isIdenticalTo($script->getCli())146 ;147 }148 public function testSetInfoWriter()149 {150 $this151 ->if($script = new mock\script($name = uniqid()))152 ->then153 ->object($script->setInfoWriter($infoWriter = new writers\std\out()))->isIdenticalTo($script)154 ->object($script->getInfoWriter())->isIdenticalTo($infoWriter)155 ->given(156 $defaultInfoWriter = new writers\std\out(),157 $defaultInfoWriter158 ->addDecorator(new writer\decorators\rtrim())159 ->addDecorator(new writer\decorators\eol())160 ->addDecorator(new atoum\cli\clear())161 )162 ->object($script->setInfoWriter())->isIdenticalTo($script)163 ->object($script->getInfoWriter())164 ->isNotIdenticalTo($infoWriter)165 ->isEqualTo($defaultInfoWriter)166 ->object($script->getInfoWriter()->getCli())->isIdenticalTo($script->getCli())167 ;168 }169 public function testSetWarningWriter()170 {171 $this172 ->if($script = new mock\script($name = uniqid()))173 ->then174 ->object($script->setWarningWriter($warningWriter = new writers\std\out()))->isIdenticalTo($script)175 ->object($script->getWarningWriter())->isIdenticalTo($warningWriter)176 ->given(177 $defaultWarningWriter = new writers\std\err(),178 $defaultWarningWriter179 ->addDecorator(new writer\decorators\trim())180 ->addDecorator(new writer\decorators\prompt($script->getLocale()->_('Warning: ')))181 ->addDecorator(new writer\decorators\eol())182 ->addDecorator(new atoum\cli\clear())183 )184 ->then185 ->object($script->setWarningWriter())->isIdenticalTo($script)186 ->object($script->getWarningWriter())187 ->isNotIdenticalTo($warningWriter)188 ->isEqualTo($defaultWarningWriter)189 ->object($script->getWarningWriter()->getCli())->isIdenticalTo($script->getCli())190 ;191 }192 public function testSetErrorWriter()193 {194 $this195 ->if($script = new mock\script($name = uniqid()))196 ->then197 ->object($script->setErrorWriter($errorWriter = new writers\std\out()))->isIdenticalTo($script)198 ->object($script->getErrorWriter())->isIdenticalTo($errorWriter)199 ->given(200 $defaultErrorWriter = new writers\std\err(),201 $defaultErrorWriter202 ->addDecorator(new writer\decorators\trim())203 ->addDecorator(new writer\decorators\prompt($script->getLocale()->_('Error: ')))204 ->addDecorator(new writer\decorators\eol())205 ->addDecorator(new atoum\cli\clear())206 )207 ->then208 ->object($script->setErrorWriter())->isIdenticalTo($script)209 ->object($script->getErrorWriter())210 ->isNotIdenticalTo($errorWriter)211 ->isEqualTo($defaultErrorWriter)212 ->object($script->getErrorWriter()->getCli())->isIdenticalTo($script->getCli())213 ;214 }215 public function testSetHelpWriter()216 {217 $this218 ->if($script = new mock\script($name = uniqid()))219 ->then220 ->object($script->setHelpWriter($helpWriter = new writers\std\out()))->isIdenticalTo($script)221 ->object($script->getHelpWriter())->isIdenticalTo($helpWriter)222 ->given(223 $labelColorizer = new atoum\cli\colorizer('0;32'),224 $labelColorizer->setPattern('/(^[^:]+: )/'),225 $argumentColorizer = new atoum\cli\colorizer('0;37'),226 $argumentColorizer->setPattern('/((?:^| )[-+]+[-a-z]+)/'),227 $valueColorizer = new atoum\cli\colorizer('0;36'),228 $valueColorizer->setPattern('/(<[^>]+>(?:\.\.\.)?)/'),229 $defaultHelpWriter = new writers\std\out(),230 $defaultHelpWriter231 ->addDecorator($labelColorizer)232 ->addDecorator($valueColorizer)233 ->addDecorator($argumentColorizer)234 ->addDecorator(new writer\decorators\rtrim())235 ->addDecorator(new writer\decorators\eol())236 ->addDecorator(new atoum\cli\clear())237 )238 ->then239 ->object($script->setHelpWriter())->isIdenticalTo($script)240 ->object($script->getHelpWriter())->isEqualTo($defaultHelpWriter)241 ;242 }243 public function testSetPrompt()244 {245 $this246 ->if($script = new mock\script(uniqid()))247 ->then248 ->object($script->setPrompt($prompt = new prompt()))->isIdenticalTo($script)249 ->object($script->getPrompt())->isIdenticalTo($prompt)250 ->object($prompt->getOutputWriter())->isIdenticalTo($script->getOutputWriter())251 ->given(252 $defaultPrompt = new prompt(),253 $defaultPrompt->setOutputWriter($script->getOutputWriter())254 )255 ->then256 ->object($script->setPrompt())->isIdenticalTo($script)257 ->object($script->getPrompt())258 ->isNotIdenticalTo($prompt)259 ->isEqualTo($defaultPrompt)260 ;261 }262 public function testAddArgumentHandler()263 {264 $this265 ->if($argumentsParser = new mock\script\arguments\parser())266 ->and($this->calling($argumentsParser)->addHandler = function () {267 })268 ->and($script = new mock\script($name = uniqid()))269 ->and($script->setArgumentsParser($argumentsParser))270 ->then271 ->object($script->addArgumentHandler($handlerA = function () {272 }, $argumentsA = ['-a']))->isIdenticalTo($script)273 ->mock($argumentsParser)->call('addHandler')->withArguments($handlerA, $argumentsA)->once()274 ->array($script->getHelp())->isEmpty()275 ->object($script->addArgumentHandler($handlerB = function () {276 }, $argumentsB = ['-b', '--b'], $valuesB = '<argumentB>'))->isIdenticalTo($script)277 ->mock($argumentsParser)->call('addHandler')->withArguments($handlerB, $argumentsB)->once()278 ->array($script->getHelp())->isEmpty()279 ->object($script->addArgumentHandler($handlerC = function () {280 }, $argumentsC = ['-c', '--c'], $valuesC = '<argumentC>', $helpC = 'help of C argument'))->isIdenticalTo($script)281 ->mock($argumentsParser)->call('addHandler')->withArguments($handlerC, $argumentsC)->once()282 ->array($script->getHelp())->isEqualTo([[$argumentsC, $valuesC, $helpC]])283 ;284 }285 public function testSetDefaultArgumentHandler()286 {287 $this288 ->if($argumentsParser = new mock\script\arguments\parser())289 ->and($this->calling($argumentsParser)->addHandler = function () {290 })291 ->and($script = new mock\script($name = uniqid()))292 ->and($script->setArgumentsParser($argumentsParser))293 ->then294 ->object($script->setDefaultArgumentHandler($defaultHandler = function ($script, $argument) {295 }))->isIdenticalTo($script)296 ->mock($argumentsParser)->call('setDefaultHandler')->withArguments($defaultHandler)->once()297 ->array($script->getHelp())->isEmpty()298 ;299 }300 public function testIncreaseVerbosityLevel()301 {302 $this303 ->if($script = new mock\script(uniqid()))304 ->then305 ->object($script->increaseVerbosityLevel())->isIdenticalTo($script)306 ->integer($script->getVerbosityLevel())->isEqualTo(1)307 ->object($script->increaseVerbosityLevel())->isIdenticalTo($script)308 ->integer($script->getVerbosityLevel())->isEqualTo(2)309 ->object($script->increaseVerbosityLevel())->isIdenticalTo($script)310 ->integer($script->getVerbosityLevel())->isEqualTo(3)311 ;312 }313 public function testDecreaseVerbosityLevel()314 {315 $this316 ->if($script = new mock\script(uniqid()))317 ->then318 ->object($script->DecreaseVerbosityLevel())->isIdenticalTo($script)319 ->integer($script->getVerbosityLevel())->isZero()320 ->if($script->increaseVerbosityLevel())321 ->then322 ->object($script->DecreaseVerbosityLevel())->isIdenticalTo($script)323 ->integer($script->getVerbosityLevel())->isZero()324 ->object($script->DecreaseVerbosityLevel())->isIdenticalTo($script)325 ->integer($script->getVerbosityLevel())->isZero()326 ;327 }328 public function testResetVerbosityLevel()329 {330 $this331 ->if($script = new mock\script(uniqid()))332 ->then333 ->object($script->resetVerbosityLevel())->isIdenticalTo($script)334 ->integer($script->getVerbosityLevel())->isZero()335 ->if($script->increaseVerbosityLevel())336 ->and($script->increaseVerbosityLevel())337 ->then338 ->object($script->resetVerbosityLevel())->isIdenticalTo($script)339 ->integer($script->getVerbosityLevel())->isZero()340 ;341 }342 public function testHelp()343 {344 $this345 ->if($argumentsParser = new mock\script\arguments\parser())346 ->and($this->calling($argumentsParser)->addHandler = function () {347 })348 ->and($locale = new mock\locale())349 ->and($this->calling($locale)->_ = function ($string) {350 return vsprintf($string, array_slice(func_get_args(), 1));351 })352 ->and($helpWriter = new mock\writers\std\out())353 ->and($this->calling($helpWriter)->write = function () {354 })355 ->and($script = new mock\script($name = uniqid()))356 ->and($script->setArgumentsParser($argumentsParser))357 ->and($script->setLocale($locale))358 ->and($script->setHelpWriter($helpWriter))359 ->then360 ->object($script->help())->isIdenticalTo($script)361 ->mock($helpWriter)->call('write')->never()362 ->if($script->addArgumentHandler(function () {363 }, ['-c', '--c'], $valuesC = '<argumentC>', $helpC = 'help of C argument'))364 ->then365 ->object($script->help())->isIdenticalTo($script)366 ->mock($locale)->call('_')->withArguments('Usage: %s [options]')->once()367 ->mock($helpWriter)368 ->call('write')369 ->withArguments('Usage: ' . $script->getName() . ' [options]')->once()370 ->withArguments('Available options are:')->once()371 ->withArguments(' -c <argumentC>, --c <argumentC> help of C argument')->once()372 ;373 }374 public function testRun()375 {376 $this377 ->if($script = new mock\script(uniqid(), $adapter = new atoum\test\adapter()))378 ->and($argumentsParser = new mock\script\arguments\parser())379 ->and($this->calling($argumentsParser)->addHandler = function () {380 })381 ->and($script->setArgumentsParser($argumentsParser))382 ->then383 ->object($script->run())->isIdenticalTo($script)384 ->mock($argumentsParser)->call('parse')->withArguments($script, [])->once()385 ->adapter($adapter)->call('ini_set')->withArguments('log_errors_max_len', 0)->once()386 ->adapter($adapter)->call('ini_set')->withArguments('log_errors', 'Off')->once()387 ->adapter($adapter)->call('ini_set')->withArguments('display_errors', 'stderr')->once()388 ;389 }390 public function testPrompt()391 {392 $this393 ->if($prompt = new mock\script\prompt())394 ->and($this->calling($prompt)->ask = $answer = uniqid())395 ->and($script = new mock\script(uniqid()))396 ->and($script->setPrompt($prompt))397 ->then398 ->string($script->prompt($message = uniqid()))->isEqualTo($answer)399 ->mock($prompt)->call('ask')->withIdenticalArguments($message)->once()400 ->string($script->prompt(($message = ' ' . $message) . "\t\n"))->isEqualTo($answer)401 ->mock($prompt)->call('ask')->withIdenticalArguments($message)->once()402 ->if($this->calling($prompt)->ask = ' ' . ($answer = uniqid()) . "\t")403 ->then404 ->string($script->prompt($message = uniqid()))->isEqualTo($answer)405 ->mock($prompt)->call('ask')->withIdenticalArguments($message)->once()406 ;407 }408 public function testWriteMessage()409 {410 $this411 ->if($outputWriter = new mock\writers\std\out())412 ->and($this->calling($outputWriter)->write->doesNothing())413 ->and($script = new mock\script(uniqid()))414 ->and($script->setOutputWriter($outputWriter))415 ->then416 ->object($script->writeMessage($message = uniqid()))->isIdenticalTo($script)417 ->mock($outputWriter)418 ->call('write')419 ->withArguments($message)420 ->after($this->mock($outputWriter)->call('removeDecorators')->once())421 ->once()422 ;423 }424 public function testWriteInfo()425 {426 $this427 ->if($infoWriter = new mock\writers\std\out())428 ->and($this->calling($infoWriter)->write->doesNothing())429 ->and($script = new mock\script(uniqid()))430 ->and($script->setInfoWriter($infoWriter))431 ->then432 ->object($script->writeInfo($info = uniqid()))->isIdenticalTo($script)433 ->mock($infoWriter)->call('write')->withArguments($info)->once()434 ;435 }436 public function testWriteWarning()437 {438 $this439 ->if($errorWriter = new mock\writers\std\err())440 ->and($this->calling($errorWriter)->clear = $errorWriter)441 ->and($this->calling($errorWriter)->write->doesNothing())442 ->and($script = new mock\script(uniqid()))443 ->and($script->setWarningWriter($errorWriter))444 ->then445 ->object($script->writeWarning($warning = uniqid()))->isIdenticalTo($script)446 ->mock($errorWriter)->call('write')->withArguments($warning)->once()447 ;448 }449 public function testWriteError()450 {451 $this452 ->if($errorWriter = new mock\writers\std\err())453 ->and($this->calling($errorWriter)->clear = $errorWriter)454 ->and($this->calling($errorWriter)->write->doesNothing())455 ->and($script = new mock\script(uniqid()))456 ->and($script->setErrorWriter($errorWriter))457 ->then458 ->object($script->writeError($message = uniqid()))->isIdenticalTo($script)459 ->mock($errorWriter)->call('write')->withIdenticalArguments($message)->once()460 ;461 }462 public function testVerbose()463 {464 $this465 ->if($script = new mock\script(uniqid()))466 ->and($script->setInfoWriter($infoWriter = new mock\writers\std\out()))467 ->and($this->calling($infoWriter)->write->doesNothing())468 ->then469 ->object($script->verbose($message = uniqid()))->isIdenticalTo($script)470 ->mock($infoWriter)->call('write')->withIdenticalArguments($message . PHP_EOL)->never()471 ->if($script->increaseVerbosityLevel())472 ->then473 ->object($script->verbose($message = uniqid()))->isIdenticalTo($script)474 ->mock($infoWriter)->call('write')->withIdenticalArguments($message)->once()475 ->object($script->verbose($message, 1))->isIdenticalTo($script)476 ->mock($infoWriter)->call('write')->withIdenticalArguments($message)->twice()477 ->object($script->verbose($message, rand(2, PHP_INT_MAX)))->isIdenticalTo($script)478 ->mock($infoWriter)->call('write')->withIdenticalArguments($message)->twice()479 ->object($script->verbose($message = uniqid(), 0))->isIdenticalTo($script)480 ->mock($infoWriter)->call('write')->withIdenticalArguments($message)->never()481 ->object($script->verbose($message, 1))->isIdenticalTo($script)482 ->mock($infoWriter)->call('write')->withIdenticalArguments($message)->once()483 ;484 }485 public function testClearMessage()486 {487 $this488 ->if($script = new mock\script(uniqid()))489 ->and($script->setOutputWriter($outputWriter = new mock\writers\std\out()))490 ->and($this->calling($outputWriter)->clear->doesNothing())491 ->then492 ->object($script->clearMessage($message = uniqid()))->isIdenticalTo($script)493 ->mock($outputWriter)->call('clear')->once()494 ;495 }496 public function testWriteLabel()497 {498 $this499 ->if($script = new mock\script(uniqid()))500 ->and($script->setHelpWriter($helpWriter = new mock\writers\std\out()))501 ->and($this->calling($helpWriter)->write->doesNothing())502 ->then503 ->object($script->writeLabel($label = uniqid(), $message = uniqid()))->isIdenticalTo($script)504 ->mock($helpWriter)->call('write')->withIdenticalArguments(' ' . $label . ' ' . $message)->once()505 ->object($script->writeLabel($label, $message, 0))->isIdenticalTo($script)506 ->mock($helpWriter)->call('write')->withIdenticalArguments(' ' . $label . ' ' . $message)->exactly(2)507 ->object($script->writeLabel(($label = ' ' . $label) . PHP_EOL, ' ' . $message . ' ' . PHP_EOL))->isIdenticalTo($script)...
Writecache.php
Source:Writecache.php
...101 $book->title = 'a Funny Tale 3';102 $book->coauthor = $coauthor1;103 $id = R::store( $book );104 $books = R::find( 'book' );105 $logger->clear();106 $authors = array();107 $authorsByName = array();108 foreach($books as $book) {109 $coAuthor = $book->with( ' ORDER BY title ASC ' )110 ->fetchAs( 'author' )->coauthor;111 $authors[] = $coAuthor->name;112 $authorsByName[ $coAuthor->name ] = $coAuthor;113 }114 asrt( count( $logger->grep( 'SELECT' ) ), 2 ); //must be 2! 3 if cache does not work!115 asrt( count( $authors ), 3 );116 asrt( isset( $authorsByName[ 'John' ] ), TRUE );117 asrt( isset( $authorsByName[ 'Pete' ] ), TRUE );118 $logger->clear();119 $authors = array();120 $authorsByName = array();121 foreach($books as $book) {122 $coAuthor = $book->with( ' ORDER BY title DESC ' )123 ->fetchAs( 'author' )->coauthor;124 $authors[] = $coAuthor->name;125 $authorsByName[ $coAuthor->name ] = $coAuthor;126 }127 asrt( count( $logger->grep( 'SELECT' ) ), 0 ); //must be 0!128 asrt( count( $authors ), 3 );129 asrt( isset( $authorsByName[ 'John' ] ), TRUE );130 asrt( isset( $authorsByName[ 'Pete' ] ), TRUE );131 }132 /**133 * Test effects of cache.134 *135 * @return void136 */137 public function testCachingEffects()138 {139 testpack( 'Testing WriteCache Query Writer Cache' );140 R::setNarrowFieldMode( FALSE );141 R::useWriterCache( FALSE );142 R::debug( TRUE, 1 );143 $logger = R::getDatabaseAdapter()->getDatabase()->getLogger();144 $book = R::dispense( 'book' )->setAttr( 'title', 'ABC' );145 $book->ownPage[] = R::dispense( 'page' );146 $id = R::store( $book );147 // Test load cache -- without148 $logger->clear();149 $book = R::load( 'book', $id );150 $book = R::load( 'book', $id );151 asrt( count( $logger->grep( 'SELECT' ) ), 2 );152 // With cache153 R::useWriterCache( TRUE );154 $logger->clear();155 $book = R::load( 'book', $id );156 $book = R::load( 'book', $id );157 asrt( count( $logger->grep( 'SELECT' ) ), 1 );158 R::useWriterCache( FALSE );159 // Test find cache160 $logger->clear();161 $book = R::find( 'book' );162 $book = R::find( 'book' );163 asrt( count( $logger->grep( 'SELECT' ) ), 2 );164 // With cache165 R::getWriter()->setUseCache( TRUE );166 $logger->clear();167 $book = R::find( 'book' );168 $book = R::find( 'book' );169 asrt( count( $logger->grep( 'SELECT' ) ), 1 );170 R::getWriter()->setUseCache( FALSE );171 // Test combinations172 $logger->clear();173 $book = R::findOne( 'book', ' id = ? ', array( $id ) );174 $book->ownPage;175 R::batch( 'book', array( $id ) );176 $book = R::findOne( 'book', ' id = ? ', array( $id ) );177 $book->ownPage;178 R::batch( 'book', array( $id ) );179 asrt( count( $logger->grep( 'SELECT' ) ), 6 );180 // With cache181 R::getWriter()->setUseCache( TRUE );182 $logger->clear();183 R::batch( 'book', array( $id ) );184 $book = R::findOne( 'book', ' id = ? ', array( $id ) );185 $book->ownPage;186 $book = R::findOne( 'book', ' id = ? ', array( $id ) );187 $book->ownPage;188 asrt( count( $logger->grep( 'SELECT' ) ), 3 );189 R::getWriter()->setUseCache( FALSE );190 // Test auto flush191 $logger->clear();192 $book = R::findOne( 'book' );193 $book->name = 'X';194 R::store( $book );195 $book = R::findOne( 'book' );196 asrt( count( $logger->grep( 'SELECT *' ) ), 2 );197 // With cache198 R::getWriter()->setUseCache( TRUE );199 $logger->clear();200 $book = R::findOne( 'book' );201 $book->name = 'Y';202 // Will flush203 R::store( $book );204 $book = R::findOne( 'book' );205 // Now the same, auto flushed206 asrt( count( $logger->grep( 'SELECT *' ) ), 2 );207 R::getWriter()->setUseCache( FALSE );208 // Test whether delete flushes as well (because uses selectRecord - might be a gotcha!)209 R::store( R::dispense( 'garbage' ) );210 $garbage = R::findOne( 'garbage' );211 $logger->clear();212 $book = R::findOne( 'book' );213 R::trash( $garbage );214 $book = R::findOne( 'book' );215 asrt( count( $logger->grep( 'SELECT *' ) ), 2 );216 R::store( R::dispense( 'garbage' ) );217 $garbage = R::findOne( 'garbage' );218 // With cache219 R::getWriter()->setUseCache( TRUE );220 $logger->clear();221 $book = R::findOne( 'book' );222 R::trash( $garbage );223 $book = R::findOne( 'book' );224 // Now the same, auto flushed225 asrt( count( $logger->grep( 'SELECT *' ) ), 2 );226 R::getWriter()->setUseCache( FALSE );227 R::store( R::dispense( 'garbage' ) );228 $garbage = R::findOne( 'garbage' );229 // With cache230 R::getWriter()->setUseCache( TRUE );231 $logger->clear();232 $book = R::findOne( 'book' );233 R::getWriter()->queryRecord( 'garbage', array( 'id' => array( $garbage->id ) ) );234 $book = R::findOne( 'book' );235 // Now the same, auto flushed236 asrt( count( $logger->grep( 'SELECT *' ) ), 2 );237 $page = R::dispense('page');238 $book->sharedPage[] = $page;239 R::store( $book );240 $logger->clear();241 $link = R::getWriter()->queryRecordLink( 'book', 'page', $book->id, $page->id );242 asrt( count( $logger->grep( 'SELECT' ) ), 1 );243 $link = R::getWriter()->queryRecordLink( 'book', 'page', $book->id, $page->id );244 asrt( count( $logger->grep( 'SELECT' ) ), 1 );245 R::getWriter()->setUseCache( FALSE );246 $link = R::getWriter()->queryRecordLink( 'book', 'page', $book->id, $page->id );247 asrt( count( $logger->grep( 'SELECT' ) ), 2 );248 R::getWriter()->setUseCache( TRUE );249 R::setNarrowFieldMode( TRUE );250 }251 /**252 * Try to fool the cache :)253 *254 * @return void255 */256 public function testRegressions()257 {258 testpack( 'Testing possible regressions: Try to fool the cache' );259 $str = 'SELECT * FROM ' . R::getWriter()->esc( 'bean', TRUE ) . ' WHERE ( ' . R::getWriter()->esc( 'id', TRUE ) . ' IN ( 1) ) ';260 $bean = R::dispense( 'bean' );261 $bean->title = 'abc';262 $id = R::store( $bean );263 $bean = R::load( 'bean', $id );264 $bean->title = 'xxx';265 R::store( $bean );266 // Fire exact same query so cache may think no other query has been fired267 R::exec( $str );268 $bean = R::load( 'bean', $id );269 asrt( $bean->title, 'xxx' );270 }271 /**272 * Test keep-cache comment.273 *274 * @return void275 */276 public function testKeepCacheCommentInSQL()277 {278 $bean = R::dispense( 'bean' );279 $bean->title = 'abc';280 $id = R::store( $bean );281 $bean = R::load( 'bean', $id );282 $bean->title = 'xxx';283 R::store( $bean );284 // Causes flush even though it contains -- keep-cache (not at the end, not intended)285 R::findOne( 'bean', ' title = ? ', array( '-- keep-cache' ) );286 $bean = R::load( 'bean', $id );287 asrt( $bean->title, 'xxx' );288 }289 /**290 *291 * Same as above.. test keep cache.292 *293 * @return void294 */295 public function testInstructNoDrop()296 {297 $str = 'SELECT * FROM ' . R::getWriter()->esc( 'bean', TRUE ) . ' -- keep-cache';298 $bean = R::dispense( 'bean' );299 $bean->title = 'abc';300 $id = R::store( $bean );301 $bean = R::load( 'bean', $id );302 $bean->title = 'xxx';303 R::store( $bean );304 R::exec( $str );305 $bean = R::load( 'bean', $id );306 asrt( $bean->title, 'abc' );307 R::nuke();308 // Now INSTRUCT the cache to not drop the cache CASE 2309 $str = 'SELECT * FROM ' . R::getWriter()->esc( 'bean', TRUE ) . ' -- keep-cache';310 $bean = R::dispense( 'bean' );311 $bean->title = 'abc';312 $id = R::store( $bean );313 $bean = R::load( 'bean', $id );314 $bean->title = 'xxx';315 R::store( $bean );316 R::findOne( 'bean', ' title = ? ', array( 'cache' ) );317 $bean = R::load( 'bean', $id );318 asrt( $bean->title, 'xxx' );319 }320 /**321 * Can we confuse the cache?322 *323 * @return void324 */325 public function testConfusionRegression()326 {327 testpack( 'Testing possible confusion regression' );328 $bean = R::dispense( 'bean' );329 $bean->title = 'abc';330 $id1 = R::store( $bean );331 $bean = R::dispense( 'bean' );332 $bean->title = 'abc2';333 $id2 = R::store( $bean );334 $bean = R::load( 'bean', $id1 );335 asrt( $bean->title, 'abc' );336 $bean = R::load( 'bean', $id2 );337 asrt( $bean->title, 'abc2' );338 }339 /**340 * Test Ghost beans....341 *342 * @return void343 */344 public function testGhostBeans()345 {346 testpack( 'Testing ghost beans' );347 $bean = R::dispense( 'bean' );348 $bean->title = 'abc';349 $id1 = R::store( $bean );350 R::trash( $bean );351 $bean = R::load( 'bean', $id1 );352 asrt( (int) $bean->id, 0 );353 }354 /**355 * Test explicit flush.356 *357 * @return void358 */359 public function testExplicitCacheFlush()360 {361 testpack( 'Test cache flush (explicit)' );362 R::setNarrowFieldMode( FALSE );363 R::debug( true, 1 );364 $logger = R::getDatabaseAdapter()->getDatabase()->getLogger();365 $bean = R::dispense( 'bean' );366 $bean->title = 'abc';367 $id1 = R::store( $bean );368 $logger->clear();369 $bean = R::load( 'bean', $id1 );370 asrt( $bean->title, 'abc' );371 asrt( count( $logger->grep( 'SELECT *' ) ), 1 );372 $bean = R::load( 'bean', $id1 );373 asrt( count( $logger->grep( 'SELECT *' ) ), 1 );374 R::getWriter()->flushCache();375 $bean = R::load( 'bean', $id1 );376 asrt( count( $logger->grep( 'SELECT *' ) ), 2 );377 R::getWriter()->flushCache();378 R::getWriter()->setUseCache( FALSE );379 R::setNarrowFieldMode( TRUE );380 }381}...
clear
Using AI Code Generation
1require_once 'vendor/autoload.php';2use PhpOffice\PhpSpreadsheet\Spreadsheet;3use PhpOffice\PhpSpreadsheet\Writer\Xlsx;4$spreadsheet = new Spreadsheet();5$sheet = $spreadsheet->getActiveSheet();6$sheet->setCellValue('A1', 'Hello World !');7$writer = new Xlsx($spreadsheet);8$writer->save('hello world.xlsx');9$writer->clear();10require_once 'vendor/autoload.php';11use PhpOffice\PhpSpreadsheet\Spreadsheet;12use PhpOffice\PhpSpreadsheet\Writer\Xlsx;13$spreadsheet = new Spreadsheet();14$sheet = $spreadsheet->getActiveSheet();15$sheet->setCellValue('A1', 'Hello World !');16$writer = new Xlsx($spreadsheet);17$writer->save('hello world.xlsx');18require_once 'vendor/autoload.php';19use PhpOffice\PhpSpreadsheet\Spreadsheet;20use PhpOffice\PhpSpreadsheet\Writer\Xlsx;21$spreadsheet = new Spreadsheet();22$sheet = $spreadsheet->getActiveSheet();23$sheet->setCellValue('A1', 'Hello World !');24$writer = new Xlsx($spreadsheet);25$writer->save('hello world.xlsx');26require_once 'vendor/autoload.php';27use PhpOffice\PhpSpreadsheet\Spreadsheet;28use PhpOffice\PhpSpreadsheet\Writer\Xlsx;29$spreadsheet = new Spreadsheet();30$sheet = $spreadsheet->getActiveSheet();31$sheet->setCellValue('A1', 'Hello World !');32$writer = new Xlsx($spreadsheet);33$writer->save('hello world.xlsx');34require_once 'vendor/autoload.php';35use PhpOffice\PhpSpreadsheet\Spreadsheet;36use PhpOffice\PhpSpreadsheet\Writer\Xlsx;37$spreadsheet = new Spreadsheet();38$sheet = $spreadsheet->getActiveSheet();39$sheet->setCellValue('A1', 'Hello World !');40$writer = new Xlsx($spreadsheet);41$writer->save('hello world.xlsx');
clear
Using AI Code Generation
1require_once 'excel/Classes/PHPExcel.php';2require_once 'excel/Classes/PHPExcel/Writer/Excel2007.php';3$objPHPExcel = new PHPExcel();4$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")5 ->setLastModifiedBy("Maarten Balliauw")6 ->setTitle("Office 2007 XLSX Test Document")7 ->setSubject("Office 2007 XLSX Test Document")8 ->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")9 ->setKeywords("office 2007 php")10 ->setCategory("Test result file");11$objPHPExcel->setActiveSheetIndex(0)12 ->setCellValue('A1', 'Hello')13 ->setCellValue('B2', 'world!')14 ->setCellValue('C1', 'Hello')15 ->setCellValue('D2', 'world!');16$objPHPExcel->getActiveSheet()->setTitle('Simple');17$objPHPExcel->setActiveSheetIndex(0);18$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);19$objWriter->save('test.xlsx');20require_once 'excel/Classes/PHPExcel/Worksheet.php';21$objPHPExcel->createSheet();22$objPHPExcel->setActiveSheetIndex(1);23$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Hello');24$objPHPExcel->getActiveSheet()->setCellValue('B2', 'world!');25$objPHPExcel->getActiveSheet()->setCellValue('C1', 'Hello');26$objPHPExcel->getActiveSheet()->setCellValue('D2', 'world!');27$objPHPExcel->getActiveSheet()->setTitle('Simple');28$objPHPExcel->setActiveSheetIndex(0);29$objPHPExcel->getActiveSheet()->clear();30$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);31$objWriter->save('test.xlsx');32require_once 'excel/Classes/PHPExcel.php';33require_once 'excel/Classes/PHPExcel/Writer/Excel2007.php';34$objPHPExcel = new PHPExcel();35$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")36 ->setLastModifiedBy("Maarten Balliauw")37 ->setTitle("Office 2007 XLSX Test Document
clear
Using AI Code Generation
1include 'Spreadsheet/Excel/Writer.php';2$workbook = new Spreadsheet_Excel_Writer();3$worksheet =& $workbook->addWorksheet('My Worksheet');4$worksheet->write(0,0,"This is a test");5$worksheet->clear();6$workbook->send('test.xls');7$workbook->close();
clear
Using AI Code Generation
1include 'Classes/PHPExcel.php';2include 'Classes/PHPExcel/Writer/Excel2007.php';3$objPHPExcel = new PHPExcel();4$objPHPExcel->getProperties()->setCreator("Sujit Kumar");5$objPHPExcel->getProperties()->setLastModifiedBy("Sujit Kumar");6$objPHPExcel->getProperties()->setTitle("Office 2007 XLSX Test Document");7$objPHPExcel->getProperties()->setSubject("Office 2007 XLSX Test Document");8$objPHPExcel->getProperties()->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.");9$objPHPExcel->setActiveSheetIndex(0);10$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Hello');11$objPHPExcel->getActiveSheet()->setCellValue('B2', 'world!');12$objPHPExcel->getActiveSheet()->setCellValue('C1', 'Hello');13$objPHPExcel->getActiveSheet()->setCellValue('D2', 'world!');14$objPHPExcel->getActiveSheet()->setTitle('Simple');15$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);16$objWriter->save("1.xlsx");17$objWriter->clear();18$objWriter = new PHPExcel_Writer_Excel5($objPHPExcel);19$objWriter->save("1.xls");
clear
Using AI Code Generation
1$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);2$objWriter->save("1.xlsx");3$objWriter->clear();4$objWriter = new PHPExcel_Writer_Excel5($objPHPExcel);5$objWriter->save("1.xls");6$objWriter->clear();
clear
Using AI Code Generation
1include 'writer.php';2$writer = new Writer();3$writer->setPath('1.php');4$writer->write('Hello World');5$writer->clear();6$writer->write('Hello World Again');7echo $writer->read();
clear
Using AI Code Generation
1include 'writer.php';2$writer=new writer();3$writer->clear();4$writer->write("This is the first line<br>");5$writer->write("This is the second line<br>");6$writer->write("This is the third line<br>");7$writer->write("This is the fourth line<br>");8$writer->write("This is the fifth line<br>");
clear
Using AI Code Generation
1include 'autoloader.php';2$writer = new Writer('1.txt');3$writer->write('Hello World');4$writer->clear();5$writer->write('Hello World Again');6$writer->close();7include 'autoloader.php';8$writer = new Writer('1.txt');9$writer->write('Hello World');10$writer->delete();11$writer->write('Hello World Again');12$writer->close();13include 'autoloader.php';14$writer = new Writer('1.txt');15$writer->write('Hello World');16$writer->close();17include 'autoloader.php';18$writer = new Writer('1.txt');
clear
Using AI Code Generation
1namespace App\writer;2class Writer{3 public function clear()4 {5 echo "clear method of writer class";6 }7}
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Execute automation tests with clear on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.
Test now for FreeGet 100 minutes of automation test minutes FREE!!