Best Atoum code snippet using pusher.getRemote
pusher.php
Source:pusher.php
...23 {24 $this25 ->if($pusher = new testedClass(__FILE__))26 ->then27 ->string($pusher->getRemote())->isEqualTo(testedClass::defaultRemote)28 ->string($pusher->getTagFile())->isEqualTo(getcwd() . DIRECTORY_SEPARATOR . testedClass::defaultTagFile)29 ->object($pusher->getTaggerEngine())->isEqualTo(new scripts\tagger\engine())30 ->string($pusher->getWorkingDirectory())->isEqualTo(getcwd())31 ->object($pusher->getGit())->isEqualTo(new commands\git())32 ;33 }34 public function testSetRemote()35 {36 $this37 ->if($pusher = new testedClass(__FILE__))38 ->then39 ->object($pusher->setRemote($remote = uniqid()))->isIdenticalTo($pusher)40 ->string($pusher->getRemote())->isEqualTo($remote)41 ->object($pusher->setRemote())->isIdenticalTo($pusher)42 ->string($pusher->getRemote())->isEqualTo(testedClass::defaultRemote)43 ;44 }45 public function testSetTagFile()46 {47 $this48 ->if($pusher = new testedClass(__FILE__))49 ->then50 ->object($pusher->setTagFile($tagFile = uniqid()))->isIdenticalTo($pusher)51 ->string($pusher->getTagFile())->isEqualTo($tagFile)52 ->object($pusher->setTagFile())->isIdenticalTo($pusher)53 ->string($pusher->getTagFile())->isEqualTo(getcwd() . DIRECTORY_SEPARATOR . testedClass::defaultTagFile)54 ;55 }56 public function testSetTaggerEngine()57 {58 $this59 ->if($pusher = new testedClass(__FILE__))60 ->then61 ->object($pusher->setTaggerEngine($taggerEngine = new scripts\tagger\engine()))->isIdenticalTo($pusher)62 ->object($pusher->getTaggerEngine())->isIdenticalTo($taggerEngine)63 ->object($pusher->setTaggerEngine())->isIdenticalTo($pusher)64 ->object($pusher->getTaggerEngine())65 ->isNotIdenticalTo($taggerEngine)66 ->isEqualTo(new scripts\tagger\engine())67 ;68 }69 public function testSetWorkingDirectory()70 {71 $this72 ->if($pusher = new testedClass(__FILE__))73 ->then74 ->object($pusher->setWorkingDirectory($workingDirectory = uniqid()))->isIdenticalTo($pusher)75 ->string($pusher->getWorkingDirectory())->isEqualTo($workingDirectory)76 ->object($pusher->setWorkingDirectory())->isIdenticalTo($pusher)77 ->string($pusher->getWorkingDirectory())->isEqualTo(getcwd())78 ;79 }80 public function testSetGit()81 {82 $this83 ->if($pusher = new testedClass(__FILE__))84 ->then85 ->object($pusher->setGit($git = new commands\git()))->isIdenticalTo($pusher)86 ->object($pusher->getGit())->isIdenticalTo($git)87 ->object($pusher->setGit())->isIdenticalTo($pusher)88 ->object($pusher->getGit())89 ->isNotIdenticalTo($git)90 ->isEqualTo(new commands\git())91 ;92 }93 public function testRun()94 {95 $this96 ->given(97 $pusher = new testedClass(__FILE__),98 $pusher->setTaggerEngine($taggerEngine = new \mock\atoum\atoum\scripts\tagger\engine()),99 $pusher->setGit($git = new \mock\atoum\atoum\cli\commands\git()),100 $pusher->setForceMode(true),101 $pusher->setErrorWriter($errorWriter = new \mock\atoum\atoum\writers\std\err()),102 $pusher->setInfoWriter($infoWriter = new \mock\atoum\atoum\writers\std\out()),103 $this->calling($infoWriter)->write = $infoWriter104 )105 ->assert('Pusher should write error if tag file is not readable')106 ->if(107 $this->calling($errorWriter)->write = $errorWriter,108 $this->function->file_get_contents = false109 )110 ->then111 ->object($pusher->run())->isIdenticalTo($pusher)112 ->mock($errorWriter)->call('write')->withArguments('Unable to read \'' . $pusher->getTagFile() . '\'')->once()113 ->assert('Pusher should write error if tag file is not writable')114 ->if(115 $this->calling($errorWriter)->write = $errorWriter,116 $this->function->file_put_contents = false,117 $this->function->file_get_contents = '0.0.0'118 )119 ->then120 ->object($pusher->run())->isIdenticalTo($pusher)121 ->mock($errorWriter)->call('write')->withArguments('Unable to write in \'' . $pusher->getTagFile() . '\'')->once()122 ->assert('Pusher should tag code and commit it if tag file is writable')123 ->if(124 $this->function->file_put_contents = function ($path, $data) {125 return strlen($data);126 },127 $this->calling($taggerEngine)->tagVersion->doesNothing(),128 $this->calling($taggerEngine)->tagChangelog->doesNothing(),129 $this->calling($git)->addAllAndCommit = $git,130 $this->calling($git)->checkoutAllFiles = $git,131 $this->calling($git)->createTag = $git,132 $this->calling($git)->push = $git,133 $this->calling($git)->forcePush = $git,134 $this->calling($git)->pushTag = $git,135 $this->calling($git)->resetHardTo = $git,136 $this->calling($git)->deleteLocalTag = $git137 )138 ->then139 ->object($pusher->run())->isIdenticalTo($pusher)140 ->function('file_put_contents')->wasCalledWithArguments($pusher->getTagFile(), '0.0.1')->once()141 ->mock($taggerEngine)142 ->call('tagVersion')143 ->before($this->mock($taggerEngine)144 ->call('tagChangelog')->withArguments('0.0.1')145 ->before($this->mock($git)146 ->call('addAllAndCommit')->withArguments('Set version to 0.0.1.')147 ->before(148 $this->mock($git)149 ->call('createTag')->withArguments('0.0.1')150 ->before(151 $this->mock($git)152 ->call('push')->withArguments($pusher->getRemote())153 ->once()154 )155 ->before(156 $this->mock($git)157 ->call('pushTag')->withArguments('0.0.1', $pusher->getRemote())158 ->once()159 )160 ->once()161 )162 ->once())163 ->once())164 ->after(165 $this->mock($taggerEngine)166 ->call('setSrcDirectory')->withArguments($pusher->getWorkingDirectory())167 ->once()168 )169 ->after(170 $this->mock($taggerEngine)171 ->call('setVersion')->withArguments('$Rev:' . ' 0.0.1 $') // Don't remove concatenation operator to avoid tagger replace the string....
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 getRemote 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!!