diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..fc8a5de --- /dev/null +++ b/LICENSE @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/README.md b/README.md index ffea095..7091374 100644 --- a/README.md +++ b/README.md @@ -579,7 +579,7 @@ Runs a target called "precache" right before you enter in to the repository cach ##### deploy.history ##### -By default, Phingistrano only keeps 5 of your most recent deployments including the current. If you would like to change the number of back deployments, you can do that with the deploy.history property. If you want to keep every deployment, simply set the value to zero. +By default, Phingistrano will keep every deployment if your project. If you do not want to limit the amount of back deployments simply do not set this value. If you would like to limit the number of back deployments, that Phingistrano will retain, you can do that with the deploy.history property. If you do not want to keep any back deployments, simply set the value to zero (not recommended). diff --git a/docs/.gitkeep b/docs/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/build.example.xml b/phingistrano/build.example.xml similarity index 100% rename from build.example.xml rename to phingistrano/build.example.xml diff --git a/build.helpers.example.xml b/phingistrano/build.helpers.example.xml similarity index 100% rename from build.helpers.example.xml rename to phingistrano/build.helpers.example.xml diff --git a/build.xml b/phingistrano/build.xml similarity index 96% rename from build.xml rename to phingistrano/build.xml index 11c21ba..137497f 100644 --- a/build.xml +++ b/phingistrano/build.xml @@ -26,6 +26,8 @@ + + diff --git a/deploy/NetScpTask.php b/phingistrano/deploy/NetScpTask.php similarity index 100% rename from deploy/NetScpTask.php rename to phingistrano/deploy/NetScpTask.php diff --git a/deploy/NetSshTask.php b/phingistrano/deploy/NetSshTask.php similarity index 100% rename from deploy/NetSshTask.php rename to phingistrano/deploy/NetSshTask.php diff --git a/deploy/build.xml b/phingistrano/deploy/build.xml similarity index 92% rename from deploy/build.xml rename to phingistrano/deploy/build.xml index 19cb1ee..0d0184c 100644 --- a/deploy/build.xml +++ b/phingistrano/deploy/build.xml @@ -6,7 +6,6 @@ - @@ -157,24 +156,8 @@ ${deploy.path}/releases/${deploy.ts}/log/${deploy.ts}.deploy.log; rm ${deploy.path}/deploy.log; " /> - - - - - - - - + + @@ -404,25 +387,10 @@ host="${deploy.server}" sshlib="${deploy.sshlib}" command="echo ${deploy.revision} > ${deploy.path}/current/REVISION" /> - - - - - - - - - + + + + @@ -476,9 +444,7 @@ - - @@ -519,6 +485,36 @@ sshlib="${deploy.sshlib}" command="echo ${deploy.password} | ${command}" /> + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/build.xml b/phingistrano/docs/build.xml similarity index 100% rename from docs/build.xml rename to phingistrano/docs/build.xml diff --git a/package.xml b/phingistrano/package.xml similarity index 98% rename from package.xml rename to phingistrano/package.xml index c53ede4..6132e3a 100644 --- a/package.xml +++ b/phingistrano/package.xml @@ -196,7 +196,7 @@ stable 2011-07-05 - MIT + GNU GPL 3.0 - diff --git a/rollback/build.xml b/phingistrano/rollback/build.xml similarity index 100% rename from rollback/build.xml rename to phingistrano/rollback/build.xml diff --git a/sniff/build.xml b/phingistrano/sniff/build.xml similarity index 100% rename from sniff/build.xml rename to phingistrano/sniff/build.xml diff --git a/symfony2.helpers.xml b/phingistrano/symfony2.helpers.xml similarity index 100% rename from symfony2.helpers.xml rename to phingistrano/symfony2.helpers.xml diff --git a/test/build.xml b/phingistrano/test/build.xml similarity index 100% rename from test/build.xml rename to phingistrano/test/build.xml diff --git a/tunnel/build.xml b/phingistrano/tunnel/build.xml similarity index 100% rename from tunnel/build.xml rename to phingistrano/tunnel/build.xml diff --git a/version/GitDescribeTask.php b/phingistrano/version/GitDescribeTask.php similarity index 100% rename from version/GitDescribeTask.php rename to phingistrano/version/GitDescribeTask.php diff --git a/version/GitDiffTask.php b/phingistrano/version/GitDiffTask.php similarity index 100% rename from version/GitDiffTask.php rename to phingistrano/version/GitDiffTask.php diff --git a/version/GitLogTask.php b/phingistrano/version/GitLogTask.php similarity index 100% rename from version/GitLogTask.php rename to phingistrano/version/GitLogTask.php diff --git a/version/GitRemoteShowTask.php b/phingistrano/version/GitRemoteShowTask.php similarity index 100% rename from version/GitRemoteShowTask.php rename to phingistrano/version/GitRemoteShowTask.php diff --git a/version/GitTagTask.php b/phingistrano/version/GitTagTask.php similarity index 100% rename from version/GitTagTask.php rename to phingistrano/version/GitTagTask.php diff --git a/version/MimeMailTask.php b/phingistrano/version/MimeMailTask.php similarity index 100% rename from version/MimeMailTask.php rename to phingistrano/version/MimeMailTask.php diff --git a/version/build.xml b/phingistrano/version/build.xml similarity index 100% rename from version/build.xml rename to phingistrano/version/build.xml diff --git a/version/notify.html b/phingistrano/version/notify.html similarity index 100% rename from version/notify.html rename to phingistrano/version/notify.html diff --git a/test/BuildFileTest.php b/test/BuildFileTest.php new file mode 100644 index 0000000..9f53148 --- /dev/null +++ b/test/BuildFileTest.php @@ -0,0 +1,443 @@ +. + */ + +require_once 'PHPUnit/Framework/TestCase.php'; +require_once 'phing/BuildListener.php'; +require_once 'phing/system/io/PhingFile.php'; + +/** + * A BuildFileTest is a TestCase which executes targets from an Ant buildfile + * for testing. + * + * This class provides a number of utility methods for particular build file + * tests which extend this class. + * + * @author Nico Seessle + * @author Conor MacNeill + * @author Victor Farazdagi + */ +abstract class BuildFileTest extends PHPUnit_Framework_TestCase { + + protected $project; + + /** + * @var array Array of log BuildEvent objects. + */ + public $logBuffer = array(); + + private $outBuffer; + private $errBuffer; + private $buildException; + + /** + * Scan the log buffer for all lines matching the pattern + * "assert [value1] == [value2]" and assert that value1 and + * value2 are equal. That way, simple test buildfiles can be + * written that can easily be interpreted when run alone, + * but are also easier to understand because everything + * is kept together in the buildfile. Of course, that only works + * for simple cases like checking the value, but does not guarantee + * that a particular line occurs at all. + * @param $target Optional name of a target that is to be executed before scanning the log. + */ + protected function scanAssertionsInLogs($target = null) { + if ($target) $this->executeTarget($target); + foreach ($this->logBuffer as $log) { + if (preg_match('/assert\s*(.*)==(.*)/i', $log, $m)) { + $this->assertEquals(trim($m[1]), trim($m[2]), $log); + } + } + } + /** + * Asserts that the log buffer contains specified message at specified priority. + * @param string $expected Message subsctring + * @param int $priority Message priority (default: any) + * @param string $errmsg The error message to display. + */ + protected function assertInLogs($expected, $priority = null, $errormsg = "Expected to find '%s' in logs: %s") + { + foreach($this->logBuffer as $log) { + if (false !== stripos($log, $expected)) { + $this->assertEquals(1, 1); // increase number of positive assertions + return; + } + } + $this->fail(sprintf($errormsg, $expected, var_export($this->logBuffer,true))); + } + + /** + * Asserts that the log buffer does NOT contain specified message at specified priority. + * @param string $expected Message subsctring + * @param int $priority Message priority (default: any) + * @param string $errmsg The error message to display. + */ + protected function assertNotInLogs($message, $priority = null, $errormsg = "Unexpected string '%s' found in logs: %s") + { + foreach($this->logBuffer as $log) { + if (false !== stripos($log, $message)) { + $this->fail(sprintf($errormsg, $message, var_export($this->logBuffer,true))); + } + } + + $this->assertEquals(1, 1); // increase number of positive assertions + } + + /** + * run a target, expect for any build exception + * + *@param target target to run + *@param cause information string to reader of report + */ + protected function expectBuildException($target, $cause) { + $this->expectSpecificBuildException($target, $cause, null); + } + + /** + * Assert that only the given message has been logged with a + * priority >= INFO when running the given target. + */ + protected function expectLog($target, $log) { + $this->executeTarget($target); + $this->assertInLogs($log); + } + + /** + * Assert that the given message has been logged with a priority + * >= INFO when running the given target. + */ + protected function expectLogContaining($target, $log) { + $this->executeTarget($target); + $this->assertInLogs($log); + } + + /** + * Assert that the given message has been logged with a priority + * >= DEBUG when running the given target. + */ + protected function expectDebuglog($target, $log) { + $this->executeTarget($target); + $this->assertInLogs($log, Project::MSG_DEBUG); + } + + /** + * execute the target, verify output matches expectations + * + *@param target target to execute + *@param output output to look for + */ + + protected function expectOutput($target, $output) { + $this->executeTarget($target); + $realOutput = $this->getOutput(); + $this->assertEquals($output, $realOutput); + } + + /** + * execute the target, verify output matches expectations + * and that we got the named error at the end + *@param target target to execute + *@param output output to look for + *@param error Description of Parameter + */ + + protected function expectOutputAndError($target, $output, $error) { + $this->executeTarget($target); + $realOutput = $this->getOutput(); + $this->assertEquals($output, $realOutput); + $realError = $this->getError(); + $this->assertEquals($error, $realError); + } + + protected function getOutput() { + return $this->cleanBuffer($this->outBuffer); + } + + protected function getError() { + return $this->cleanBuffer($this->errBuffer); + } + + protected function getBuildException() { + return $this->buildException; + } + + private function cleanBuffer($buffer) { + $cleanedBuffer = ""; + $cr = false; + for ($i = 0, $bufflen=strlen($buffer); $i < $bufflen; $i++) { + $ch = $buffer{$i}; + if ($ch == "\r") { + $cr = true; + continue; + } + + if (!$cr) { + $cleanedBuffer.= $ch; + } else { + if ($ch == "\n") { + $cleanedBuffer .= $ch; + } else { + $cleanedBuffer .= "\r" . $ch; + } + } + } + return $cleanedBuffer; + } + + /** + * set up to run the named project + * + * @param filename name of project file to run + * @throws BuildException + */ + protected function configureProject($filename) { + $this->logBuffer = ""; + $this->fullLogBuffer = ""; + $this->project = new Project(); + $this->project->init(); + $f = new PhingFile($filename); + $this->project->setUserProperty( "phing.file" , $f->getAbsolutePath() ); + $this->project->addBuildListener(new PhingTestListener($this)); + ProjectConfigurator::configureProject($this->project, new PhingFile($filename)); + } + + /** + * execute a target we have set up + * @pre configureProject has been called + * @param string $targetName target to run + */ + protected function executeTarget($targetName) { + + $this->outBuffer = ""; + $this->errBuffer = ""; + $this->logBuffer = ""; + $this->fullLogBuffer = ""; + $this->buildException = null; + $this->project->executeTarget($targetName); + + } + + /** + * Get the project which has been configured for a test. + * + * @return the Project instance for this test. + */ + protected function getProject() { + return $this->project; + } + + /** + * get the directory of the project + * @return the base dir of the project + */ + protected function getProjectDir() { + return $this->project->getBaseDir(); + } + + /** + * run a target, wait for a build exception + * + *@param target target to run + *@param cause information string to reader of report + *@param msg the message value of the build exception we are waiting for + set to null for any build exception to be valid + */ + protected function expectSpecificBuildException($target, $cause, $msg) { + try { + $this->executeTarget($target); + } catch (BuildException $ex) { + $this->buildException = $ex; + if (($msg !== null) && ($ex->getMessage() != $msg)) { + $this->fail("Should throw BuildException because '" . $cause + . "' with message '" . $msg + . "' (actual message '" . $ex->getMessage() . "' instead)"); + } + $this->assertEquals(1, 1); // increase number of positive assertions + return; + } + $this->fail("Should throw BuildException because: " . $cause); + } + + /** + * run a target, expect an exception string + * containing the substring we look for (case sensitive match) + * + *@param target target to run + *@param cause information string to reader of report + *@param msg the message value of the build exception we are waiting for + *@param contains substring of the build exception to look for + */ + protected function expectBuildExceptionContaining($target, $cause, $contains) { + try { + $this->executeTarget($target); + } catch (BuildException $ex) { + $this->buildException = $ex; + if ((null != $contains) && (false === strpos($ex->getMessage(), $contains))) { + $this->fail("Should throw BuildException because '" . $cause . "' with message containing '" . $contains . "' (actual message '" . $ex->getMessage() . "' instead)"); + } + $this->assertEquals(1, 1); // increase number of positive assertions + return; + } + $this->fail("Should throw BuildException because: " . $cause); + } + + + /** + * call a target, verify property is as expected + * + * @param target build file target + * @param property property name + * @param value expected value + */ + + protected function expectPropertySet($target, $property, $value = "true") { + $this->executeTarget($target); + $this->assertPropertyEquals($property, $value); + } + + /** + * assert that a property equals a value; comparison is case sensitive. + * @param property property name + * @param value expected value + */ + protected function assertPropertyEquals($property, $value) { + $result = $this->project->getProperty($property); + $this->assertEquals($value, $result, "property " . $property); + } + + /** + * assert that a property equals "true" + * @param property property name + */ + protected function assertPropertySet($property) { + $this->assertPropertyEquals($property, "true"); + } + + /** + * assert that a property is null + * @param property property name + */ + protected function assertPropertyUnset($property) { + $this->assertPropertyEquals($property, null); + } + + + /** + * call a target, verify property is null + * @param target build file target + * @param property property name + */ + protected function expectPropertyUnset($target, $property) { + $this->expectPropertySet($target, $property, null); + } + + /** + * Retrieve a resource from the caller classloader to avoid + * assuming a vm working directory. The resource path must be + * relative to the package name or absolute from the root path. + * @param resource the resource to retrieve its url. + * @throws AssertionFailureException if resource is not found. + */ + protected function getResource($resource){ + throw new BuildException("getResource() not yet implemented"); + //$url = ggetClass().getResource(resource); + //assertNotNull("Could not find resource :" + resource, url); + //return url; + } + + + +} + +/** + * our own personal build listener + */ +class PhingTestListener implements BuildListener { + + private $parent; + + public function __construct($parent) { + $this->parent = $parent; + } + + /** + * Fired before any targets are started. + */ + public function buildStarted(BuildEvent $event) { + } + + /** + * Fired after the last target has finished. This event + * will still be thrown if an error occured during the build. + * + * @see BuildEvent#getException() + */ + public function buildFinished(BuildEvent $event) { + } + + /** + * Fired when a target is started. + * + * @see BuildEvent#getTarget() + */ + public function targetStarted(BuildEvent $event) { + //System.out.println("targetStarted " + event.getTarget().getName()); + } + + /** + * Fired when a target has finished. This event will + * still be thrown if an error occured during the build. + * + * @see BuildEvent#getException() + */ + public function targetFinished(BuildEvent $event) { + //System.out.println("targetFinished " + event.getTarget().getName()); + } + + /** + * Fired when a task is started. + * + * @see BuildEvent#getTask() + */ + public function taskStarted(BuildEvent $event) { + //System.out.println("taskStarted " + event.getTask().getTaskName()); + } + + /** + * Fired when a task has finished. This event will still + * be throw if an error occured during the build. + * + * @see BuildEvent#getException() + */ + public function taskFinished(BuildEvent $event) { + //System.out.println("taskFinished " + event.getTask().getTaskName()); + } + + /** + * Fired whenever a message is logged. + * + * @see BuildEvent#getMessage() + * @see BuildEvent#getPriority() + */ + public function messageLogged(BuildEvent $event) { + $this->parent->logBuffer[] = $event->getMessage(); + } +} diff --git a/test/phingistrano/GitTasks/.svn/all-wcprops b/test/phingistrano/GitTasks/.svn/all-wcprops new file mode 100644 index 0000000..8620a06 --- /dev/null +++ b/test/phingistrano/GitTasks/.svn/all-wcprops @@ -0,0 +1,155 @@ +K 25 +svn:wc:ra_dav:version-url +V 65 +/!svn/ver/1179/branches/2.5/test/classes/phing/tasks/ext/GitTasks +END +GitGcTaskTest.xml +K 25 +svn:wc:ra_dav:version-url +V 83 +/!svn/ver/1179/branches/2.5/test/classes/phing/tasks/ext/GitTasks/GitGcTaskTest.xml +END +GitFetchTaskTest.xml +K 25 +svn:wc:ra_dav:version-url +V 86 +/!svn/ver/1179/branches/2.5/test/classes/phing/tasks/ext/GitTasks/GitFetchTaskTest.xml +END +GitInitTaskTest.php +K 25 +svn:wc:ra_dav:version-url +V 85 +/!svn/ver/1179/branches/2.5/test/classes/phing/tasks/ext/GitTasks/GitInitTaskTest.php +END +GitCheckoutTaskTest.php +K 25 +svn:wc:ra_dav:version-url +V 89 +/!svn/ver/1179/branches/2.5/test/classes/phing/tasks/ext/GitTasks/GitCheckoutTaskTest.php +END +GitBranchTaskTest.xml +K 25 +svn:wc:ra_dav:version-url +V 87 +/!svn/ver/1179/branches/2.5/test/classes/phing/tasks/ext/GitTasks/GitBranchTaskTest.xml +END +GitMergeTaskTest.xml +K 25 +svn:wc:ra_dav:version-url +V 86 +/!svn/ver/1179/branches/2.5/test/classes/phing/tasks/ext/GitTasks/GitMergeTaskTest.xml +END +GitCloneTaskTest.xml +K 25 +svn:wc:ra_dav:version-url +V 86 +/!svn/ver/1179/branches/2.5/test/classes/phing/tasks/ext/GitTasks/GitCloneTaskTest.xml +END +GitTagTaskTest.php +K 25 +svn:wc:ra_dav:version-url +V 84 +/!svn/ver/1179/branches/2.5/test/classes/phing/tasks/ext/GitTasks/GitTagTaskTest.php +END +GitInitTaskTest.xml +K 25 +svn:wc:ra_dav:version-url +V 85 +/!svn/ver/1179/branches/2.5/test/classes/phing/tasks/ext/GitTasks/GitInitTaskTest.xml +END +GitPullTaskTest.php +K 25 +svn:wc:ra_dav:version-url +V 85 +/!svn/ver/1179/branches/2.5/test/classes/phing/tasks/ext/GitTasks/GitPullTaskTest.php +END +GitCheckoutTaskTest.xml +K 25 +svn:wc:ra_dav:version-url +V 89 +/!svn/ver/1179/branches/2.5/test/classes/phing/tasks/ext/GitTasks/GitCheckoutTaskTest.xml +END +GitPushTaskTest.php +K 25 +svn:wc:ra_dav:version-url +V 85 +/!svn/ver/1179/branches/2.5/test/classes/phing/tasks/ext/GitTasks/GitPushTaskTest.php +END +GitTestsHelper.php +K 25 +svn:wc:ra_dav:version-url +V 84 +/!svn/ver/1125/branches/2.5/test/classes/phing/tasks/ext/GitTasks/GitTestsHelper.php +END +GitLogTaskTest.php +K 25 +svn:wc:ra_dav:version-url +V 84 +/!svn/ver/1179/branches/2.5/test/classes/phing/tasks/ext/GitTasks/GitLogTaskTest.php +END +GitTagTaskTest.xml +K 25 +svn:wc:ra_dav:version-url +V 84 +/!svn/ver/1179/branches/2.5/test/classes/phing/tasks/ext/GitTasks/GitTagTaskTest.xml +END +GitPullTaskTest.xml +K 25 +svn:wc:ra_dav:version-url +V 85 +/!svn/ver/1179/branches/2.5/test/classes/phing/tasks/ext/GitTasks/GitPullTaskTest.xml +END +GitBaseTest.php +K 25 +svn:wc:ra_dav:version-url +V 81 +/!svn/ver/1179/branches/2.5/test/classes/phing/tasks/ext/GitTasks/GitBaseTest.php +END +GitPushTaskTest.xml +K 25 +svn:wc:ra_dav:version-url +V 85 +/!svn/ver/1179/branches/2.5/test/classes/phing/tasks/ext/GitTasks/GitPushTaskTest.xml +END +GitGcTaskTest.php +K 25 +svn:wc:ra_dav:version-url +V 83 +/!svn/ver/1179/branches/2.5/test/classes/phing/tasks/ext/GitTasks/GitGcTaskTest.php +END +GitFetchTaskTest.php +K 25 +svn:wc:ra_dav:version-url +V 86 +/!svn/ver/1179/branches/2.5/test/classes/phing/tasks/ext/GitTasks/GitFetchTaskTest.php +END +GitLogTaskTest.xml +K 25 +svn:wc:ra_dav:version-url +V 84 +/!svn/ver/1179/branches/2.5/test/classes/phing/tasks/ext/GitTasks/GitLogTaskTest.xml +END +GitBranchTaskTest.php +K 25 +svn:wc:ra_dav:version-url +V 87 +/!svn/ver/1179/branches/2.5/test/classes/phing/tasks/ext/GitTasks/GitBranchTaskTest.php +END +GitMergeTaskTest.php +K 25 +svn:wc:ra_dav:version-url +V 86 +/!svn/ver/1179/branches/2.5/test/classes/phing/tasks/ext/GitTasks/GitMergeTaskTest.php +END +GitCloneTaskTest.php +K 25 +svn:wc:ra_dav:version-url +V 86 +/!svn/ver/1179/branches/2.5/test/classes/phing/tasks/ext/GitTasks/GitCloneTaskTest.php +END +GitBaseTest.xml +K 25 +svn:wc:ra_dav:version-url +V 81 +/!svn/ver/1179/branches/2.5/test/classes/phing/tasks/ext/GitTasks/GitBaseTest.xml +END diff --git a/test/phingistrano/GitTasks/.svn/entries b/test/phingistrano/GitTasks/.svn/entries new file mode 100644 index 0000000..9f35e8c --- /dev/null +++ b/test/phingistrano/GitTasks/.svn/entries @@ -0,0 +1,878 @@ +10 + +dir +1205 +http://svn.phing.info/branches/2.5/test/classes/phing/tasks/ext/GitTasks +http://svn.phing.info + + + +2011-06-22T11:31:08.993107Z +1179 +mp + + + + + + + + + + + + + + +34c17c5f-800b-0410-92ba-a69295604261 + +GitGcTaskTest.xml +file + + + + +2011-07-02T13:37:04.341658Z +2a0adb5beb7b6883e09804dbeaa947f3 +2011-06-22T11:31:08.993107Z +1179 +mp + + + + + + + + + + + + + + + + + + + + + +1815 + +GitFetchTaskTest.xml +file + + + + +2011-07-02T13:37:04.341658Z +6b859879d59703a21906ca324128a715 +2011-06-22T11:31:08.993107Z +1179 +mp + + + + + + + + + + + + + + + + + + + + + +1605 + +GitInitTaskTest.php +file + + + + +2011-07-02T13:37:04.341658Z +9587c342fc9f18be45986602977b3f9a +2011-06-22T11:31:08.993107Z +1179 +mp +has-props + + + + + + + + + + + + + + + + + + + + +3086 + +GitCheckoutTaskTest.php +file + + + + +2011-07-02T13:37:04.351657Z +86d6665e909bce12731dbbd1c21a4be2 +2011-06-22T11:31:08.993107Z +1179 +mp +has-props + + + + + + + + + + + + + + + + + + + + +4717 + +GitBranchTaskTest.xml +file + + + + +2011-07-02T13:37:04.351657Z +1b14f244622ca16ccb54ba3e74ffb2ac +2011-06-22T11:31:08.993107Z +1179 +mp + + + + + + + + + + + + + + + + + + + + + +5245 + +GitMergeTaskTest.xml +file + + + + +2011-07-02T13:37:04.351657Z +152d0cf715e963b68a9f26a896549c66 +2011-06-22T11:31:08.993107Z +1179 +mp + + + + + + + + + + + + + + + + + + + + + +3950 + +GitCloneTaskTest.xml +file + + + + +2011-07-02T13:37:04.351657Z +a0aa5f9866e44f95087e7801ffae9d66 +2011-06-22T11:31:08.993107Z +1179 +mp + + + + + + + + + + + + + + + + + + + + + +1434 + +GitTagTaskTest.php +file + + + + +2011-07-02T13:37:04.351657Z +c3462a644f326ad5a2f6a7c81cb642fa +2011-06-22T11:31:08.993107Z +1179 +mp +has-props + + + + + + + + + + + + + + + + + + + + +7668 + +GitInitTaskTest.xml +file + + + + +2011-07-02T13:37:04.351657Z +5763560e1c7e151b270356905119f866 +2011-06-22T11:31:08.993107Z +1179 +mp + + + + + + + + + + + + + + + + + + + + + +784 + +GitPullTaskTest.php +file + + + + +2011-07-02T13:37:04.351657Z +67261dd7a5881c6a18911362fd555981 +2011-06-22T11:31:08.993107Z +1179 +mp +has-props + + + + + + + + + + + + + + + + + + + + +5214 + +GitCheckoutTaskTest.xml +file + + + + +2011-07-02T13:37:04.351657Z +7fbe6f3e1018abbb78a54dca8acb56c4 +2011-06-22T11:31:08.993107Z +1179 +mp + + + + + + + + + + + + + + + + + + + + + +4246 + +GitPushTaskTest.php +file + + + + +2011-07-02T13:37:04.351657Z +9df61301c4b26921414e070d747509cc +2011-06-22T11:31:08.993107Z +1179 +mp +has-props + + + + + + + + + + + + + + + + + + + + +3946 + +GitTestsHelper.php +file + + + + +2011-07-02T13:37:04.351657Z +17546ca6e0707cde2f43652225d8ddd0 +2011-05-31T19:44:36.758947Z +1125 +mrook +has-props + + + + + + + + + + + + + + + + + + + + +1916 + +GitLogTaskTest.php +file + + + + +2011-07-02T13:37:04.351657Z +2b47898f75ca90415d13c88310139a12 +2011-06-22T11:31:08.993107Z +1179 +mp +has-props + + + + + + + + + + + + + + + + + + + + +12499 + +GitTagTaskTest.xml +file + + + + +2011-07-02T13:37:04.351657Z +2cdecdef83eba33ba704b73d9bf2b7fb +2011-06-22T11:31:08.993107Z +1179 +mp + + + + + + + + + + + + + + + + + + + + + +6813 + +GitPullTaskTest.xml +file + + + + +2011-07-02T13:37:04.351657Z +7f920ec4a5741db2976096d53c89cba6 +2011-06-22T11:31:08.993107Z +1179 +mp + + + + + + + + + + + + + + + + + + + + + +3076 + +GitBaseTest.php +file + + + + +2011-07-02T13:37:04.351657Z +16b8d6daefdeb21d3dc187494a11fe01 +2011-06-22T11:31:08.993107Z +1179 +mp +has-props + + + + + + + + + + + + + + + + + + + + +2284 + +GitPushTaskTest.xml +file + + + + +2011-07-02T13:37:04.351657Z +b0f552d56ad248ff4552890893a480e4 +2011-06-22T11:31:08.993107Z +1179 +mp + + + + + + + + + + + + + + + + + + + + + +3110 + +GitGcTaskTest.php +file + + + + +2011-07-02T13:37:04.351657Z +d52b8b420eb7241aaa8682bb1e4e8cf0 +2011-06-22T11:31:08.993107Z +1179 +mp +has-props + + + + + + + + + + + + + + + + + + + + +3405 + +GitFetchTaskTest.php +file + + + + +2011-07-02T13:37:04.351657Z +2984a5656d949d876cf4d8546367511a +2011-06-22T11:31:08.993107Z +1179 +mp +has-props + + + + + + + + + + + + + + + + + + + + +3293 + +GitLogTaskTest.xml +file + + + + +2011-07-02T13:37:04.351657Z +39b492bdb39d3e3ad321b8c153715398 +2011-06-22T11:31:08.993107Z +1179 +mp + + + + + + + + + + + + + + + + + + + + + +5709 + +GitBranchTaskTest.php +file + + + + +2011-07-02T13:37:04.351657Z +4c030234eeb53d6300cd154280e0b351 +2011-06-22T11:31:08.993107Z +1179 +mp +has-props + + + + + + + + + + + + + + + + + + + + +5843 + +GitMergeTaskTest.php +file + + + + +2011-07-02T13:37:04.351657Z +b21e0e1153858f78d53334cbd0e29e9b +2011-06-22T11:31:08.993107Z +1179 +mp +has-props + + + + + + + + + + + + + + + + + + + + +3945 + +GitCloneTaskTest.php +file + + + + +2011-07-02T13:37:04.351657Z +e681a1c54f671208c375384620a10e88 +2011-06-22T11:31:08.993107Z +1179 +mp +has-props + + + + + + + + + + + + + + + + + + + + +3729 + +GitBaseTest.xml +file + + + + +2011-07-02T13:37:04.351657Z +f7298d77755cdd937417526d575eeb24 +2011-06-22T11:31:08.993107Z +1179 +mp + + + + + + + + + + + + + + + + + + + + + +144 + diff --git a/test/phingistrano/GitTasks/.svn/prop-base/GitBaseTest.php.svn-base b/test/phingistrano/GitTasks/.svn/prop-base/GitBaseTest.php.svn-base new file mode 100644 index 0000000..92c8ad7 --- /dev/null +++ b/test/phingistrano/GitTasks/.svn/prop-base/GitBaseTest.php.svn-base @@ -0,0 +1,5 @@ +K 12 +svn:keywords +V 2 +Id +END diff --git a/test/phingistrano/GitTasks/.svn/prop-base/GitBranchTaskTest.php.svn-base b/test/phingistrano/GitTasks/.svn/prop-base/GitBranchTaskTest.php.svn-base new file mode 100644 index 0000000..92c8ad7 --- /dev/null +++ b/test/phingistrano/GitTasks/.svn/prop-base/GitBranchTaskTest.php.svn-base @@ -0,0 +1,5 @@ +K 12 +svn:keywords +V 2 +Id +END diff --git a/test/phingistrano/GitTasks/.svn/prop-base/GitCheckoutTaskTest.php.svn-base b/test/phingistrano/GitTasks/.svn/prop-base/GitCheckoutTaskTest.php.svn-base new file mode 100644 index 0000000..92c8ad7 --- /dev/null +++ b/test/phingistrano/GitTasks/.svn/prop-base/GitCheckoutTaskTest.php.svn-base @@ -0,0 +1,5 @@ +K 12 +svn:keywords +V 2 +Id +END diff --git a/test/phingistrano/GitTasks/.svn/prop-base/GitCloneTaskTest.php.svn-base b/test/phingistrano/GitTasks/.svn/prop-base/GitCloneTaskTest.php.svn-base new file mode 100644 index 0000000..92c8ad7 --- /dev/null +++ b/test/phingistrano/GitTasks/.svn/prop-base/GitCloneTaskTest.php.svn-base @@ -0,0 +1,5 @@ +K 12 +svn:keywords +V 2 +Id +END diff --git a/test/phingistrano/GitTasks/.svn/prop-base/GitFetchTaskTest.php.svn-base b/test/phingistrano/GitTasks/.svn/prop-base/GitFetchTaskTest.php.svn-base new file mode 100644 index 0000000..92c8ad7 --- /dev/null +++ b/test/phingistrano/GitTasks/.svn/prop-base/GitFetchTaskTest.php.svn-base @@ -0,0 +1,5 @@ +K 12 +svn:keywords +V 2 +Id +END diff --git a/test/phingistrano/GitTasks/.svn/prop-base/GitGcTaskTest.php.svn-base b/test/phingistrano/GitTasks/.svn/prop-base/GitGcTaskTest.php.svn-base new file mode 100644 index 0000000..92c8ad7 --- /dev/null +++ b/test/phingistrano/GitTasks/.svn/prop-base/GitGcTaskTest.php.svn-base @@ -0,0 +1,5 @@ +K 12 +svn:keywords +V 2 +Id +END diff --git a/test/phingistrano/GitTasks/.svn/prop-base/GitInitTaskTest.php.svn-base b/test/phingistrano/GitTasks/.svn/prop-base/GitInitTaskTest.php.svn-base new file mode 100644 index 0000000..92c8ad7 --- /dev/null +++ b/test/phingistrano/GitTasks/.svn/prop-base/GitInitTaskTest.php.svn-base @@ -0,0 +1,5 @@ +K 12 +svn:keywords +V 2 +Id +END diff --git a/test/phingistrano/GitTasks/.svn/prop-base/GitLogTaskTest.php.svn-base b/test/phingistrano/GitTasks/.svn/prop-base/GitLogTaskTest.php.svn-base new file mode 100644 index 0000000..92c8ad7 --- /dev/null +++ b/test/phingistrano/GitTasks/.svn/prop-base/GitLogTaskTest.php.svn-base @@ -0,0 +1,5 @@ +K 12 +svn:keywords +V 2 +Id +END diff --git a/test/phingistrano/GitTasks/.svn/prop-base/GitMergeTaskTest.php.svn-base b/test/phingistrano/GitTasks/.svn/prop-base/GitMergeTaskTest.php.svn-base new file mode 100644 index 0000000..92c8ad7 --- /dev/null +++ b/test/phingistrano/GitTasks/.svn/prop-base/GitMergeTaskTest.php.svn-base @@ -0,0 +1,5 @@ +K 12 +svn:keywords +V 2 +Id +END diff --git a/test/phingistrano/GitTasks/.svn/prop-base/GitPullTaskTest.php.svn-base b/test/phingistrano/GitTasks/.svn/prop-base/GitPullTaskTest.php.svn-base new file mode 100644 index 0000000..92c8ad7 --- /dev/null +++ b/test/phingistrano/GitTasks/.svn/prop-base/GitPullTaskTest.php.svn-base @@ -0,0 +1,5 @@ +K 12 +svn:keywords +V 2 +Id +END diff --git a/test/phingistrano/GitTasks/.svn/prop-base/GitPushTaskTest.php.svn-base b/test/phingistrano/GitTasks/.svn/prop-base/GitPushTaskTest.php.svn-base new file mode 100644 index 0000000..92c8ad7 --- /dev/null +++ b/test/phingistrano/GitTasks/.svn/prop-base/GitPushTaskTest.php.svn-base @@ -0,0 +1,5 @@ +K 12 +svn:keywords +V 2 +Id +END diff --git a/test/phingistrano/GitTasks/.svn/prop-base/GitTagTaskTest.php.svn-base b/test/phingistrano/GitTasks/.svn/prop-base/GitTagTaskTest.php.svn-base new file mode 100644 index 0000000..92c8ad7 --- /dev/null +++ b/test/phingistrano/GitTasks/.svn/prop-base/GitTagTaskTest.php.svn-base @@ -0,0 +1,5 @@ +K 12 +svn:keywords +V 2 +Id +END diff --git a/test/phingistrano/GitTasks/.svn/prop-base/GitTestsHelper.php.svn-base b/test/phingistrano/GitTasks/.svn/prop-base/GitTestsHelper.php.svn-base new file mode 100644 index 0000000..92c8ad7 --- /dev/null +++ b/test/phingistrano/GitTasks/.svn/prop-base/GitTestsHelper.php.svn-base @@ -0,0 +1,5 @@ +K 12 +svn:keywords +V 2 +Id +END diff --git a/test/phingistrano/GitTasks/.svn/text-base/GitBaseTest.php.svn-base b/test/phingistrano/GitTasks/.svn/text-base/GitBaseTest.php.svn-base new file mode 100644 index 0000000..df4d7c5 --- /dev/null +++ b/test/phingistrano/GitTasks/.svn/text-base/GitBaseTest.php.svn-base @@ -0,0 +1,65 @@ +. + */ + +require_once 'phing/BuildFileTest.php'; +require_once '../classes/phing/tasks/ext/git/GitBaseTask.php'; + +/** + * @author Victor Farazdagi + * @version $Id$ + * @package phing.tasks.ext + */ +class GitBaseTest extends BuildFileTest { + + protected $mock; + + public function setUp() { + $this->configureProject(__DIR__ . "/GitBaseTest.xml"); + $this->mock = $this->getMockForAbstractClass('GitBaseTask'); + } + + public function testInitialization() + { + $this->assertInstanceOf('GitBaseTask', $this->mock); + } + + /** + * @todo - make sure that required arguments are checked + */ + public function testArguments() + {} + + public function testMutators() + { + // gitPath + $gitPath = $this->mock->getGitPath(); + $this->mock->setGitPath('my-new-path'); + $this->assertEquals('my-new-path', $this->mock->getGitPath()); + $this->mock->setGitPath($gitPath); + + // repository + $repository = $this->mock->getRepository(); + $this->mock->setRepository('/tmp'); + $this->assertEquals('/tmp', $this->mock->getRepository()); + $this->mock->setRepository($repository); + } + +} diff --git a/test/phingistrano/GitTasks/.svn/text-base/GitBaseTest.xml.svn-base b/test/phingistrano/GitTasks/.svn/text-base/GitBaseTest.xml.svn-base new file mode 100644 index 0000000..a961450 --- /dev/null +++ b/test/phingistrano/GitTasks/.svn/text-base/GitBaseTest.xml.svn-base @@ -0,0 +1,6 @@ + + + + + + diff --git a/test/phingistrano/GitTasks/.svn/text-base/GitBranchTaskTest.php.svn-base b/test/phingistrano/GitTasks/.svn/text-base/GitBranchTaskTest.php.svn-base new file mode 100644 index 0000000..e61daf1 --- /dev/null +++ b/test/phingistrano/GitTasks/.svn/text-base/GitBranchTaskTest.php.svn-base @@ -0,0 +1,158 @@ +. + */ + +require_once 'phing/BuildFileTest.php'; +require_once '../classes/phing/tasks/ext/git/GitBranchTask.php'; +require_once dirname(__FILE__) . '/GitTestsHelper.php'; + +/** + * @author Victor Farazdagi + * @version $Id$ + * @package phing.tasks.ext + */ +class GitBranchTaskTest extends BuildFileTest { + + public function setUp() { + if (is_readable(PHING_TEST_TMP . '/git')) { + // make sure we purge previously created directory + // if left-overs from previous run are found + GitTestsHelper::rmdir(PHING_TEST_TMP . '/git'); + } + // set temp directory used by test cases + mkdir(PHING_TEST_TMP . '/git'); + + $this->configureProject(__DIR__ . '/GitBranchTaskTest.xml'); + } + + public function tearDown() + { + GitTestsHelper::rmdir(PHING_TEST_TMP . '/git'); + } + + public function testAllParamsSet() + { + $repository = PHING_TEST_TMP . '/git'; + $this->executeTarget('allParamsSet'); + $this->assertInLogs('git-branch output: Branch all-params-set set up to track remote branch master from origin.'); + } + + public function testNoRepositorySpecified() + { + $this->expectBuildExceptionContaining('noRepository', + 'Repo dir is required', + '"repository" is required parameter'); + } + + public function testNoBranchnameSpecified() + { + $this->expectBuildExceptionContaining('noBranchname', + 'Branchname dir is required', + '"branchname" is required parameter'); + } + + public function testTrackParameter() + { + $repository = PHING_TEST_TMP . '/git'; + + $this->executeTarget('trackParamSet'); + $this->assertInLogs('git-branch: branch "' . $repository . '" repository'); + $this->assertInLogs( 'git-branch output: Branch track-param-set set up to track local branch master.'); + } + + public function testNoTrackParameter() + { + $repository = PHING_TEST_TMP . '/git'; + + $this->executeTarget('noTrackParamSet'); + $this->assertInLogs('git-branch: branch "' . $repository . '" repository'); + $this->assertInLogs('git-branch output: '); // no output actually + } + + public function testSetUpstreamParameter() + { + $repository = PHING_TEST_TMP . '/git'; + + $this->executeTarget('setUpstreamParamSet'); + $this->assertInLogs('git-branch: branch "' . $repository . '" repository'); + $this->assertInLogs('Branch set-upstream-param-set set up to track local branch master.'); // no output actually + } + + public function testForceParameter() + { + $repository = PHING_TEST_TMP . '/git'; + + $this->executeTarget('forceParamSet'); + $this->assertInLogs('git-branch: branch "' . $repository . '" repository'); + $this->assertInLogs('git-branch output: '); // no output actually + } + + public function testDeleteBranch() + { + $repository = PHING_TEST_TMP . '/git'; + + $this->executeTarget('deleteBranch'); + $this->assertInLogs('git-branch: branch "' . $repository . '" repository'); + $this->assertInLogs('Branch delete-branch-1 set up to track local branch master.'); + $this->assertInLogs('Branch delete-branch-2 set up to track local branch master.'); + $this->assertInLogs('Deleted branch delete-branch-1'); + $this->assertInLogs('Deleted branch delete-branch-2'); + } + + public function testMoveBranch() + { + $repository = PHING_TEST_TMP . '/git'; + + $this->executeTarget('moveBranch'); + $this->assertInLogs('git-branch: branch "' . $repository . '" repository'); + // try to delete new branch (thus understanding that rename worked) + $this->assertInLogs('Deleted branch move-branch-2'); + } + + public function testForceMoveBranch() + { + $repository = PHING_TEST_TMP . '/git'; + + $this->executeTarget('forceMoveBranch'); + $this->assertInLogs('git-branch: branch "' . $repository . '" repository'); + // try to delete new branch (thus understanding that rename worked) + $this->assertInLogs('Deleted branch move-branch-2'); + } + + public function testForceMoveBranchNoNewbranch() + { + $repository = PHING_TEST_TMP . '/git'; + + $this->expectBuildExceptionContaining('forceMoveBranchNoNewbranch', + 'New branch name is required in branch move', + '"newbranch" is required parameter'); + } + + public function testMoveBranchNoNewbranch() + { + $repository = PHING_TEST_TMP . '/git'; + + $this->expectBuildExceptionContaining('moveBranchNoNewbranch', + 'New branch name is required in branch move', + '"newbranch" is required parameter'); + } + + +} diff --git a/test/phingistrano/GitTasks/.svn/text-base/GitBranchTaskTest.xml.svn-base b/test/phingistrano/GitTasks/.svn/text-base/GitBranchTaskTest.xml.svn-base new file mode 100644 index 0000000..1517fb8 --- /dev/null +++ b/test/phingistrano/GitTasks/.svn/text-base/GitBranchTaskTest.xml.svn-base @@ -0,0 +1,158 @@ + + + + + + + + This file should only be run via a testcase + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/phingistrano/GitTasks/.svn/text-base/GitCheckoutTaskTest.php.svn-base b/test/phingistrano/GitTasks/.svn/text-base/GitCheckoutTaskTest.php.svn-base new file mode 100644 index 0000000..431b16a --- /dev/null +++ b/test/phingistrano/GitTasks/.svn/text-base/GitCheckoutTaskTest.php.svn-base @@ -0,0 +1,117 @@ +. + */ + +require_once 'phing/BuildFileTest.php'; +require_once '../classes/phing/tasks/ext/git/GitCheckoutTask.php'; +require_once dirname(__FILE__) . '/GitTestsHelper.php'; + +/** + * @author Victor Farazdagi + * @version $Id$ + * @package phing.tasks.ext + */ +class GitCheckoutTaskTest extends BuildFileTest { + + public function setUp() { + if (is_readable(PHING_TEST_TMP . '/git')) { + // make sure we purge previously created directory + // if left-overs from previous run are found + GitTestsHelper::rmdir(PHING_TEST_TMP . '/git'); + } + // set temp directory used by test cases + mkdir(PHING_TEST_TMP . '/git'); + + $this->configureProject(__DIR__ . '/GitCheckoutTaskTest.xml'); + } + + public function tearDown() + { + GitTestsHelper::rmdir(PHING_TEST_TMP . '/git'); + } + + public function testCheckoutExistingBranch() + { + $repository = PHING_TEST_TMP . '/git'; + $this->executeTarget('checkoutExistingBranch'); + $this->assertInLogs('git-checkout: checkout "' . $repository . '" repository'); + $this->assertInLogs('git-branch output: Branch co-branch set up to track remote branch master from origin.'); + // @todo - actually make sure that Ebihara updates code to return (not + // echo output from $command->execute() + //$this->assertInLogs("Switched to branch 'test'"); + $this->assertInLogs('git-checkout output: '); // no output actually + } + + public function testCheckoutNonExistingBranch() + { + $this->expectBuildExceptionContaining('checkoutNonExistingBranch', + 'Checkout of non-existent repo is impossible', + 'Task execution failed'); + } + + public function testNoRepositorySpecified() + { + $this->expectBuildExceptionContaining('noRepository', + 'Repo dir is required', + '"repository" is required parameter'); + } + + public function testNoBranchnameSpecified() + { + $this->expectBuildExceptionContaining('noBranchname', + 'Branchname is required', + '"branchname" is required parameter'); + } + + public function testCheckoutMerge() + { + $repository = PHING_TEST_TMP . '/git'; + $this->executeTarget('checkoutMerge'); + $this->assertInLogs('git-checkout: checkout "' . $repository . '" repository'); + $this->assertInLogs('git-branch output: Branch co-branch set up to track remote branch master from origin.'); + $this->assertInLogs('git-branch output: Deleted branch master'); + } + + public function testCheckoutCreateBranch() + { + $repository = PHING_TEST_TMP . '/git'; + $this->executeTarget('checkoutCreateBranch'); + $this->assertInLogs('git-checkout: checkout "' . $repository . '" repository'); + $this->assertInLogs('git-checkout output: Branch co-create-branch set up to track remote branch master from origin.'); + $this->assertInLogs('git-branch output: Deleted branch co-create-branch'); + } + + public function testForceCheckoutCreateBranch() + { + $repository = PHING_TEST_TMP . '/git'; + $this->executeTarget('checkoutForceCreateBranch'); + $this->assertInLogs('git-checkout: checkout "' . $repository . '" repository'); + $this->assertInLogs('git-branch output: Deleted branch co-create-branch'); + } + + public function testForceCheckoutCreateBranchFailed() + { + $this->expectBuildExceptionContaining('checkoutForceCreateBranchFailed', + 'Branch already exists', + 'Task execution failed.'); + } + + +} diff --git a/test/phingistrano/GitTasks/.svn/text-base/GitCheckoutTaskTest.xml.svn-base b/test/phingistrano/GitTasks/.svn/text-base/GitCheckoutTaskTest.xml.svn-base new file mode 100644 index 0000000..e22534a --- /dev/null +++ b/test/phingistrano/GitTasks/.svn/text-base/GitCheckoutTaskTest.xml.svn-base @@ -0,0 +1,122 @@ + + + + + + + + This file should only be run via a testcase + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/phingistrano/GitTasks/.svn/text-base/GitCloneTaskTest.php.svn-base b/test/phingistrano/GitTasks/.svn/text-base/GitCloneTaskTest.php.svn-base new file mode 100644 index 0000000..1b284f0 --- /dev/null +++ b/test/phingistrano/GitTasks/.svn/text-base/GitCloneTaskTest.php.svn-base @@ -0,0 +1,100 @@ +. + */ + +require_once 'phing/BuildFileTest.php'; +require_once '../classes/phing/tasks/ext/git/GitCloneTask.php'; +require_once dirname(__FILE__) . '/GitTestsHelper.php'; + +/** + * @author Victor Farazdagi + * @version $Id$ + * @package phing.tasks.ext + */ +class GitCloneTaskTest extends BuildFileTest { + + public function setUp() { + // set temp directory used by test cases + mkdir(PHING_TEST_TMP . '/git'); + + $this->configureProject(__DIR__ . '/GitCloneTaskTest.xml'); + } + + public function tearDown() + { + GitTestsHelper::rmdir(PHING_TEST_TMP . '/git'); + } + + public function testWrongRepository() + { + $this->expectBuildExceptionContaining('wrongRepository', + 'Repository not readable', + 'The remote end hung up unexpectedly'); + } + + public function testWrongTargetPath() + { + $this->expectBuildExceptionContaining('wrongTargetPath', + 'Repository not readable', + 'You must specify readable directory as repository'); + } + + public function testGitClone() + { + $repository = PHING_TEST_TMP . '/git'; + $gitFilesDir = $repository . '/.git'; + $this->executeTarget('gitClone'); + + $this->assertInLogs('git-clone: cloning "git://github.com/farazdagi/phing-tests.git" repository to "' . $repository . '" directory'); + $this->assertTrue(is_dir($repository)); + $this->assertTrue(is_dir($gitFilesDir)); + // test that file is actully cloned + $this->assertTrue(is_readable($repository . '/README')); + } + + public function testGitCloneBare() + { + $repository = PHING_TEST_TMP . '/git'; + $gitFilesDir = $repository . '/.git'; + $this->executeTarget('gitCloneBare'); + $this->assertInLogs('git-clone: cloning (bare) "git://github.com/farazdagi/phing-tests.git" repository to "' . $repository . '" directory'); + $this->assertTrue(is_dir($repository)); + $this->assertTrue(is_dir($repository . '/branches')); + $this->assertTrue(is_dir($repository . '/info')); + $this->assertTrue(is_dir($repository . '/hooks')); + $this->assertTrue(is_dir($repository . '/refs')); + } + + public function testNoRepositorySpecified() + { + $this->expectBuildExceptionContaining('noRepository', + 'Repo dir is required', + '"repository" is required parameter'); + } + + public function testNoTargetPathSpecified() + { + $this->expectBuildExceptionContaining('noTargetPath', + 'Target path is required', + '"targetPath" is required parameter'); + } + + +} diff --git a/test/phingistrano/GitTasks/.svn/text-base/GitCloneTaskTest.xml.svn-base b/test/phingistrano/GitTasks/.svn/text-base/GitCloneTaskTest.xml.svn-base new file mode 100644 index 0000000..834e316 --- /dev/null +++ b/test/phingistrano/GitTasks/.svn/text-base/GitCloneTaskTest.xml.svn-base @@ -0,0 +1,43 @@ + + + + + + + + This file should only be run via a testcase + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/phingistrano/GitTasks/.svn/text-base/GitFetchTaskTest.php.svn-base b/test/phingistrano/GitTasks/.svn/text-base/GitFetchTaskTest.php.svn-base new file mode 100644 index 0000000..89aedbd --- /dev/null +++ b/test/phingistrano/GitTasks/.svn/text-base/GitFetchTaskTest.php.svn-base @@ -0,0 +1,88 @@ +. + */ + +require_once 'phing/BuildFileTest.php'; +require_once '../classes/phing/tasks/ext/git/GitFetchTask.php'; +require_once dirname(__FILE__) . '/GitTestsHelper.php'; + +/** + * @author Victor Farazdagi + * @version $Id$ + * @package phing.tasks.ext + */ +class GitFetchTaskTest extends BuildFileTest { + + public function setUp() { + if (is_readable(PHING_TEST_TMP . '/git')) { + // make sure we purge previously created directory + // if left-overs from previous run are found + GitTestsHelper::rmdir(PHING_TEST_TMP . '/git'); + } + // set temp directory used by test cases + mkdir(PHING_TEST_TMP . '/git'); + + $this->configureProject(__DIR__ . '/GitFetchTaskTest.xml'); + } + + public function tearDown() + { + GitTestsHelper::rmdir(PHING_TEST_TMP . '/git'); + } + + public function testAllParamsSet() + { + $repository = PHING_TEST_TMP . '/git'; + $this->executeTarget('allParamsSet'); + $this->assertInLogs('git-fetch: branch "' . $repository . '" repository'); + $this->assertInLogs('git-fetch output: '); // no output actually + } + + public function testFetchAllRemotes() + { + $repository = PHING_TEST_TMP . '/git'; + $this->executeTarget('fetchAllRemotes'); + $this->assertInLogs('git-fetch: branch "' . $repository . '" repository'); + $this->assertInLogs('git-fetch output: Fetching origin'); + } + + public function testNoRepositorySpecified() + { + $this->expectBuildExceptionContaining('noRepository', + 'Repo dir is required', + '"repository" is required parameter'); + } + + public function testNoTargetSpecified() + { + $this->expectBuildExceptionContaining('noTarget', + 'Target is required', + 'No remote repository specified'); + } + + public function testRefspecSet() + { + $repository = PHING_TEST_TMP . '/git'; + $this->executeTarget('refspecSet'); + $this->assertInLogs('git-fetch: branch "' . $repository . '" repository'); + $this->assertInLogs('git-fetch output: '); + $this->assertInLogs('Deleted branch refspec-branch'); + } +} diff --git a/test/phingistrano/GitTasks/.svn/text-base/GitFetchTaskTest.xml.svn-base b/test/phingistrano/GitTasks/.svn/text-base/GitFetchTaskTest.xml.svn-base new file mode 100644 index 0000000..9de0d48 --- /dev/null +++ b/test/phingistrano/GitTasks/.svn/text-base/GitFetchTaskTest.xml.svn-base @@ -0,0 +1,51 @@ + + + + + + + + This file should only be run via a testcase + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/phingistrano/GitTasks/.svn/text-base/GitGcTaskTest.php.svn-base b/test/phingistrano/GitTasks/.svn/text-base/GitGcTaskTest.php.svn-base new file mode 100644 index 0000000..db114ac --- /dev/null +++ b/test/phingistrano/GitTasks/.svn/text-base/GitGcTaskTest.php.svn-base @@ -0,0 +1,99 @@ +. + */ + +require_once 'phing/BuildFileTest.php'; +require_once '../classes/phing/tasks/ext/git/GitGcTask.php'; +require_once dirname(__FILE__) . '/GitTestsHelper.php'; + +/** + * @author Victor Farazdagi + * @version $Id$ + * @package phing.tasks.ext + */ +class GitGcTaskTest extends BuildFileTest { + + public function setUp() { + if (is_readable(PHING_TEST_TMP . '/git')) { + // make sure we purge previously created directory + // if left-overs from previous run are found + GitTestsHelper::rmdir(PHING_TEST_TMP . '/git'); + } + // set temp directory used by test cases + mkdir(PHING_TEST_TMP . '/git'); + + $this->configureProject(__DIR__ . '/GitGcTaskTest.xml'); + } + + public function tearDown() + { + GitTestsHelper::rmdir(PHING_TEST_TMP . '/git'); + } + + public function testAllParamsSet() + { + $repository = PHING_TEST_TMP . '/git'; + $this->executeTarget('allParamsSet'); + $this->assertInLogs('git-gc: cleaning up "' . $repository . '" repository'); + } + + public function testNoRepositorySpecified() + { + $this->expectBuildExceptionContaining('noRepository', + 'Repo dir is required', + '"repository" is required parameter'); + } + + public function testAutoParameter() + { + $repository = PHING_TEST_TMP . '/git'; + $msg = 'git-gc: cleaning up "' . $repository . '" repository'; + + $this->executeTarget('autoParamSet'); + $this->assertInLogs($msg); + } + + public function testNoPruneParameter() + { + $repository = PHING_TEST_TMP . '/git'; + $msg = 'git-gc: cleaning up "' . $repository . '" repository'; + + $this->executeTarget('nopruneParamSet'); + $this->assertInLogs($msg); + } + + public function testAggressiveParameter() + { + $repository = PHING_TEST_TMP . '/git'; + $msg = 'git-gc: cleaning up "' . $repository . '" repository'; + + $this->executeTarget('aggressiveParamSet'); + $this->assertInLogs($msg); + } + + public function testPruneParameter() + { + $repository = PHING_TEST_TMP . '/git'; + $msg = 'git-gc: cleaning up "' . $repository . '" repository'; + + $this->executeTarget('pruneParamSet'); + $this->assertInLogs($msg); + } +} diff --git a/test/phingistrano/GitTasks/.svn/text-base/GitGcTaskTest.xml.svn-base b/test/phingistrano/GitTasks/.svn/text-base/GitGcTaskTest.xml.svn-base new file mode 100644 index 0000000..fe2615a --- /dev/null +++ b/test/phingistrano/GitTasks/.svn/text-base/GitGcTaskTest.xml.svn-base @@ -0,0 +1,57 @@ + + + + + + + + This file should only be run via a testcase + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/phingistrano/GitTasks/.svn/text-base/GitInitTaskTest.php.svn-base b/test/phingistrano/GitTasks/.svn/text-base/GitInitTaskTest.php.svn-base new file mode 100644 index 0000000..4b4975a --- /dev/null +++ b/test/phingistrano/GitTasks/.svn/text-base/GitInitTaskTest.php.svn-base @@ -0,0 +1,83 @@ +. + */ + +require_once 'phing/BuildFileTest.php'; +require_once '../classes/phing/tasks/ext/git/GitInitTask.php'; +require_once dirname(__FILE__) . '/GitTestsHelper.php'; + +/** + * @author Victor Farazdagi + * @version $Id$ + * @package phing.tasks.ext + */ +class GitInitTaskTest extends BuildFileTest { + + public function setUp() { + // set temp directory used by test cases + mkdir(PHING_TEST_TMP . '/git'); + + $this->configureProject(__DIR__ . '/GitInitTaskTest.xml'); + } + + public function tearDown() + { + GitTestsHelper::rmdir(PHING_TEST_TMP . '/git'); + } + + public function testWrongRepository() + { + $this->expectBuildExceptionContaining('wrongRepository', + 'Repository directory not readable', + 'You must specify readable directory as repository.'); + } + + public function testGitInit() + { + $repository = PHING_TEST_TMP . '/git'; + $gitFilesDir = $repository . '/.git'; + $this->executeTarget('gitInit'); + + $this->assertInLogs('git-init: initializing "' . $repository . '" repository'); + $this->assertTrue(is_dir($repository)); + $this->assertTrue(is_dir($gitFilesDir)); + } + + public function testGitInitBare() + { + $repository = PHING_TEST_TMP . '/git'; + $gitFilesDir = $repository . '/.git'; + $this->executeTarget('gitInitBare'); + $this->assertInLogs('git-init: initializing (bare) "' . $repository . '" repository'); + $this->assertTrue(is_dir($repository)); + $this->assertTrue(is_dir($repository . '/branches')); + $this->assertTrue(is_dir($repository . '/info')); + $this->assertTrue(is_dir($repository . '/hooks')); + $this->assertTrue(is_dir($repository . '/refs')); + } + + public function testNoRepositorySpecified() + { + $this->expectBuildExceptionContaining('noRepository', + 'Repo dir is required', + '"repository" is required parameter'); + } + +} diff --git a/test/phingistrano/GitTasks/.svn/text-base/GitInitTaskTest.xml.svn-base b/test/phingistrano/GitTasks/.svn/text-base/GitInitTaskTest.xml.svn-base new file mode 100644 index 0000000..39f1488 --- /dev/null +++ b/test/phingistrano/GitTasks/.svn/text-base/GitInitTaskTest.xml.svn-base @@ -0,0 +1,27 @@ + + + + + + + + This file should only be run via a testcase + + + + + + + + + + + + + + + + + + + diff --git a/test/phingistrano/GitTasks/.svn/text-base/GitLogTaskTest.php.svn-base b/test/phingistrano/GitTasks/.svn/text-base/GitLogTaskTest.php.svn-base new file mode 100644 index 0000000..eb94b8e --- /dev/null +++ b/test/phingistrano/GitTasks/.svn/text-base/GitLogTaskTest.php.svn-base @@ -0,0 +1,301 @@ +. + */ + +require_once 'phing/BuildFileTest.php'; +require_once '../classes/phing/tasks/ext/git/GitLogTask.php'; +require_once dirname(__FILE__) . '/GitTestsHelper.php'; + +/** + * @author Victor Farazdagi + * @version $Id$ + * @package phing.tasks.ext + */ +class GitLogTaskTest extends BuildFileTest { + + private $testCommits = array( + array( + 'commit' => '6dbaf4508e75dcd426b5b974a67c462c70d46e1f', + 'author' => 'Victor Farazdagi ', + 'date' => 'Sun Sep 26 21:14:44 2010 +0400', + 'msg' => 'Inited', + 'msg-full' => '', + 'From' => '6dbaf4508e75dcd426b5b974a67c462c70d46e1f Mon Sep 17 00:00:00 2001', + 'From:' => 'Victor Farazdagi ', + 'Date' => 'Sun, 26 Sep 2010 21:14:44 +0400', + 'Subject' => '[PATCH] Inited', + ), + array( + 'commit' => 'b8cddb3fa5f408560d0d00d6c8721fe333895888', + 'author' => 'Victor Farazdagi ', + 'date' => 'Sun Jan 23 22:53:07 2011 +0300', + 'msg' => 'Added file1 + file2', + 'msg-full' => '', + 'From' => 'b8cddb3fa5f408560d0d00d6c8721fe333895888 Mon Sep 17 00:00:00 2001', + 'From:' => 'Victor Farazdagi ', + 'Date' => 'Sun, 23 Jan 2011 22:53:07 +0300', + 'Subject' => '[PATCH] Added file1 + file2', + ), + array( + 'commit' => 'c573116f395d36497a1ac1dba565ecd3d3944277', + 'author' => 'Victor Farazdagi ', + 'date' => 'Sun Jan 23 22:53:19 2011 +0300', + 'msg' => 'Added file3', + 'msg-full' => '', + 'From' => 'c573116f395d36497a1ac1dba565ecd3d3944277 Mon Sep 17 00:00:00 2001', + 'From:' => 'Victor Farazdagi ', + 'Date' => 'Sun, 23 Jan 2011 22:53:19 +0300', + 'Subject' => '[PATCH] Added file3', + ), + array( + 'commit' => '2b4a5409bf60813b6a84d583bbdcbed25c7c3a00', + 'author' => 'Victor Farazdagi ', + 'date' => 'Sun Jan 23 22:53:42 2011 +0300', + 'msg' => 'Removed file3', + 'msg-full' => '', + 'From' => '2b4a5409bf60813b6a84d583bbdcbed25c7c3a00 Mon Sep 17 00:00:00 2001', + 'From:' => 'Victor Farazdagi ', + 'Date' => 'Sun, 23 Jan 2011 22:53:42 +0300', + 'Subject' => '[PATCH] Removed file3', + ), + array( + 'commit' => 'ee07085160003ffd1100867deb6059bae0c45455', + 'author' => 'Victor Farazdagi ', + 'date' => 'Sun Jan 23 23:38:34 2011 +0300', + 'msg' => 'Title: file4 was added', + 'msg-full' => 'Full commit message: and here goes some elaboration on what has been done.', + 'From' => 'ee07085160003ffd1100867deb6059bae0c45455 Mon Sep 17 00:00:00 2001', + 'From:' => 'Victor Farazdagi ', + 'Date' => 'Sun, 23 Jan 2011 23:38:34 +0300', + 'Subject' => '[PATCH] Title: file4 was added', + ), + array( + 'commit' => '1b767b75bb5329f4e53345c516c0a9f4ed32d330', + 'author' => 'Victor Farazdagi ', + 'date' => 'Mon Jan 24 09:58:33 2011 +0300', + 'msg' => 'Added file5', + 'msg-full' => 'This file was added one day after file1, file2, file3 and file4 were added', + 'From' => '1b767b75bb5329f4e53345c516c0a9f4ed32d330 Mon Sep 17 00:00:00 2001', + 'From:' => 'Victor Farazdagi ', + 'Date' => 'Mon, 24 Jan 2011 09:58:33 +0300', + 'Subject' => '[PATCH] Added file5', + ), + + ); + + public function setUp() { + if (is_readable(PHING_TEST_TMP . '/git')) { + // make sure we purge previously created directory + // if left-overs from previous run are found + GitTestsHelper::rmdir(PHING_TEST_TMP . '/git'); + } + // set temp directory used by test cases + mkdir(PHING_TEST_TMP . '/git'); + + $this->configureProject(__DIR__ . '/GitLogTaskTest.xml'); + } + + public function tearDown() + { + GitTestsHelper::rmdir(PHING_TEST_TMP . '/git'); + } + + public function testGitLogWithoutParams() + { + $this->executeTarget('gitLogWithoutParams'); + foreach($this->testCommits as $commit) { + $this->assertInLogs($commit['date']); + $this->assertInLogs($commit['author']); + $this->assertInLogs($commit['commit']); + $this->assertInLogs($commit['msg']); + if (strlen($commit['msg-full'])) { + $this->assertInLogs($commit['msg-full']); + } + } + } + + public function testGitWithMostParams() + { + $this->executeTarget('gitLogWithMostParams'); + $lastTwoCommits = array_slice($this->testCommits, -2); + $allOtherCommits = array_slice($this->testCommits, 0, -2); + + // test max-count + foreach($lastTwoCommits as $commit) { + $this->assertInLogs($commit['commit']); + $this->assertInLogs($commit['msg']); + } + foreach($allOtherCommits as $commit) { + $this->assertNotInLogs($commit['commit']); + $this->assertNotInLogs($commit['msg']); + } + + $this->assertInLogs('0 files changed, 0 insertions(+), 0 deletions(-)'); + + } + + public function testGitOutputPropertySet() + { + $this->executeTarget('gitLogOutputPropertySet'); + $this->assertPropertyEquals('gitLogOutput', '1b767b75bb5329f4e53345c516c0a9f4ed32d330 Added file5' . "\n"); + } + + public function testGitLogNameStatus() + { + $this->executeTarget('gitLogNameStatusSet'); + $this->assertInLogs("A\tfile1"); + $this->assertInLogs("A\tfile2"); + $this->assertInLogs("A\tfile3"); + $this->assertInLogs("A\tREADME"); + $this->assertInLogs("D\tfile3"); + } + + public function testGitDateRelative() + { + $this->executeTarget('gitLogDateRelative'); + foreach($this->testCommits as $commit) { + $timestamp = strtotime($commit['date']); + $this->assertInLogs(GitTestsHelper::getRelativeDate($timestamp)); + } + } + + public function testGitSinceUntilSet() + { + $this->executeTarget('gitLogSinceUntilSet'); + $this->assertNotInLogs('6dbaf4508e75dcd426b5b974a67c462c70d46e1f Inited'); + $this->assertNotInLogs('1b767b75bb5329f4e53345c516c0a9f4ed32d330 Added file5'); + $this->assertInLogs('ee07085160003ffd1100867deb6059bae0c45455 Title: file4 was added'); + $this->assertInLogs('2b4a5409bf60813b6a84d583bbdcbed25c7c3a00 Removed file3'); + $this->assertInLogs('c573116f395d36497a1ac1dba565ecd3d3944277 Added file3'); + $this->assertInLogs('b8cddb3fa5f408560d0d00d6c8721fe333895888 Added file1 + file2'); + } + + public function testGitBeforeAfterSet() + { + $this->executeTarget('gitLogBeforeAfterSet'); + $this->assertNotInLogs('6dbaf4508e75dcd426b5b974a67c462c70d46e1f Inited'); + $this->assertNotInLogs('1b767b75bb5329f4e53345c516c0a9f4ed32d330 Added file5'); + $this->assertInLogs('ee07085160003ffd1100867deb6059bae0c45455 Title: file4 was added'); + $this->assertInLogs('2b4a5409bf60813b6a84d583bbdcbed25c7c3a00 Removed file3'); + $this->assertInLogs('c573116f395d36497a1ac1dba565ecd3d3944277 Added file3'); + $this->assertInLogs('b8cddb3fa5f408560d0d00d6c8721fe333895888 Added file1 + file2'); + } + + public function testGitFormatOneLine() + { + $this->executeTarget('gitLogFormatOneLine'); + foreach($this->testCommits as $commit) { + $this->assertNotInLogs($commit['author']); + $this->assertNotInLogs($commit['date']); + $this->assertInLogs($commit['commit']); + $this->assertInLogs($commit['msg']); + } + } + + public function testGitFormatShort() + { + $this->executeTarget('gitLogFormatShort'); + foreach($this->testCommits as $commit) { + $this->assertNotInLogs($commit['date']); + $this->assertInLogs($commit['author']); + $this->assertInLogs($commit['commit']); + $this->assertInLogs($commit['msg']); + } + } + + public function testGitFormatMedium() + { + $this->executeTarget('gitLogFormatMedium'); + foreach($this->testCommits as $commit) { + $this->assertInLogs($commit['date']); + $this->assertInLogs($commit['author']); + $this->assertInLogs($commit['commit']); + $this->assertInLogs($commit['msg']); + if (strlen($commit['msg-full'])) { + $this->assertInLogs($commit['msg-full']); + } + } + } + + public function testGitFormatFull() + { + $this->executeTarget('gitLogFormatFull'); + foreach($this->testCommits as $commit) { + $this->assertNotInLogs($commit['date']); + $this->assertInLogs('Author: ' . $commit['author']); + $this->assertInLogs('Commit: ' . $commit['author']); + $this->assertInLogs('commit ' . $commit['commit']); + $this->assertInLogs($commit['msg']); + if (strlen($commit['msg-full'])) { + $this->assertInLogs($commit['msg-full']); + } + } + } + + public function testGitFormatFuller() + { + $this->executeTarget('gitLogFormatFuller'); + foreach($this->testCommits as $commit) { + $this->assertInLogs('Author: ' . $commit['author']); + $this->assertInLogs('AuthorDate: ' . $commit['date']); + $this->assertInLogs('Commit: ' . $commit['author']); + $this->assertInLogs('CommitDate: ' . $commit['date']); + $this->assertInLogs('commit ' . $commit['commit']); + $this->assertInLogs($commit['msg']); + if (strlen($commit['msg-full'])) { + $this->assertInLogs($commit['msg-full']); + } + } + } + + public function testGitFormatEmail() + { + $this->executeTarget('gitLogFormatEmail'); + foreach($this->testCommits as $commit) { + $this->assertInLogs('From ' . $commit['From']); + $this->assertInLogs('From: ' . $commit['From:']); + $this->assertInLogs('Date: ' . $commit['Date']); + $this->assertInLogs('Subject: ' . $commit['Subject']); + if (strlen($commit['msg-full'])) { + $this->assertInLogs($commit['msg-full']); + } + } + } + + public function testGitFormatCustom() + { + $this->executeTarget('gitLogFormatCustom'); + foreach($this->testCommits as $commit) { + $this->assertInLogs( + sprintf('The author of %s was %s', $commit['commit'], $commit['author'])); + } + } + + + + public function testNoRepositorySpecified() + { + $this->expectBuildExceptionContaining('noRepository', + 'Repo dir is required', + '"repository" is required parameter'); + } + + +} diff --git a/test/phingistrano/GitTasks/.svn/text-base/GitLogTaskTest.xml.svn-base b/test/phingistrano/GitTasks/.svn/text-base/GitLogTaskTest.xml.svn-base new file mode 100644 index 0000000..c89cd73 --- /dev/null +++ b/test/phingistrano/GitTasks/.svn/text-base/GitLogTaskTest.xml.svn-base @@ -0,0 +1,167 @@ + + + + + + + + This file should only be run via a testcase + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/phingistrano/GitTasks/.svn/text-base/GitMergeTaskTest.php.svn-base b/test/phingistrano/GitTasks/.svn/text-base/GitMergeTaskTest.php.svn-base new file mode 100644 index 0000000..2bd4dd4 --- /dev/null +++ b/test/phingistrano/GitTasks/.svn/text-base/GitMergeTaskTest.php.svn-base @@ -0,0 +1,102 @@ +. + */ + +require_once 'phing/BuildFileTest.php'; +require_once '../classes/phing/tasks/ext/git/GitMergeTask.php'; +require_once dirname(__FILE__) . '/GitTestsHelper.php'; + +/** + * @author Victor Farazdagi + * @version $Id$ + * @package phing.tasks.ext + */ +class GitMergeTaskTest extends BuildFileTest { + + public function setUp() { + if (is_readable(PHING_TEST_TMP . '/git')) { + // make sure we purge previously created directory + // if left-overs from previous run are found + GitTestsHelper::rmdir(PHING_TEST_TMP . '/git'); + } + // set temp directory used by test cases + mkdir(PHING_TEST_TMP . '/git'); + + $this->configureProject(__DIR__ . '/GitMergeTaskTest.xml'); + } + + public function tearDown() + { + GitTestsHelper::rmdir(PHING_TEST_TMP . '/git'); + } + + public function testAllParamsSet() + { + $repository = PHING_TEST_TMP . '/git'; + $this->executeTarget('allParamsSet'); + $this->assertInLogs('git-merge: replaying "merge-test-1 merge-test-2" commits'); + $this->assertInLogs('git-merge output: Already up-to-date.'); + } + + public function testNoCommitSet() + { + $repository = PHING_TEST_TMP . '/git'; + $this->executeTarget('noCommitSet'); + $this->assertInLogs('git-merge: replaying "6dbaf4508e75dcd426b5b974a67c462c70d46e1f" commits'); + $this->assertInLogs('git-merge output: Already up-to-date.'); + } + + public function testRemoteSet() + { + $repository = PHING_TEST_TMP . '/git'; + $this->executeTarget('remoteSet'); + $this->assertInLogs('git-merge: replaying "6dbaf4508e75dcd426b5b974a67c462c70d46e1f" commits'); + $this->assertInLogs('git-merge output: Already up-to-date.'); + } + + public function testFastForwardCommitSet() + { + $repository = PHING_TEST_TMP . '/git'; + $this->executeTarget('fastForwardCommitSet'); + $this->assertInLogs('git-merge command: /usr/bin/git merge --no-ff \'origin/master\''); + $this->assertInLogs('git-merge: replaying "origin/master" commits'); + $this->assertInLogs('Merge remote-tracking branch \'origin/master\' into merge-test-1'); + } + + public function testNoRepositorySpecified() + { + $this->expectBuildExceptionContaining('noRepository', + 'Repo dir is required', + '"repository" is required parameter'); + } + + public function testNoRemotesSpecified() + { + $this->expectBuildExceptionContaining('noRemotes', + 'At least one commit is required', + '"remote" is required parameter'); + } + + public function testWrongStrategySet() + { + $this->expectBuildExceptionContaining('wrongStrategySet', + 'Wrong strategy passed', 'Could not find merge strategy \'plain-wrong\''); + } +} diff --git a/test/phingistrano/GitTasks/.svn/text-base/GitMergeTaskTest.xml.svn-base b/test/phingistrano/GitTasks/.svn/text-base/GitMergeTaskTest.xml.svn-base new file mode 100644 index 0000000..4ed4d34 --- /dev/null +++ b/test/phingistrano/GitTasks/.svn/text-base/GitMergeTaskTest.xml.svn-base @@ -0,0 +1,112 @@ + + + + + + + + This file should only be run via a testcase + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/phingistrano/GitTasks/.svn/text-base/GitPullTaskTest.php.svn-base b/test/phingistrano/GitTasks/.svn/text-base/GitPullTaskTest.php.svn-base new file mode 100644 index 0000000..7ed91e3 --- /dev/null +++ b/test/phingistrano/GitTasks/.svn/text-base/GitPullTaskTest.php.svn-base @@ -0,0 +1,131 @@ +. + */ + +require_once 'phing/BuildFileTest.php'; +require_once '../classes/phing/tasks/ext/git/GitPullTask.php'; +require_once dirname(__FILE__) . '/GitTestsHelper.php'; + +/** + * @author Victor Farazdagi + * @version $Id$ + * @package phing.tasks.ext + */ +class GitPullTaskTest extends BuildFileTest { + + public function setUp() { + if (is_readable(PHING_TEST_TMP . '/git')) { + // make sure we purge previously created directory + // if left-overs from previous run are found + GitTestsHelper::rmdir(PHING_TEST_TMP . '/git'); + } + // set temp directory used by test cases + mkdir(PHING_TEST_TMP . '/git'); + + $this->configureProject(__DIR__ . '/GitPullTaskTest.xml'); + } + + public function tearDown() + { + GitTestsHelper::rmdir(PHING_TEST_TMP . '/git'); + } + + public function testAllParamsSet() + { + /*$repository = PHING_TEST_TMP . '/git'; + $this->executeTarget('allParamsSet'); + $this->assertInLogs('git-pull: pulling from origin foobranch'); + $this->assertInLogs('git-pull: complete'); + $this->assertInLogs('git-pull output: Updating 6dbaf45..6ad2ea3'); + // make sure that foofile from foobranch made it to master + $this->assertTrue(is_readable($repository . '/foofile'));*/ + } + + public function testAllParamsSetRebase() + { + /*$repository = PHING_TEST_TMP . '/git'; + $this->executeTarget('allParamsSetRebase'); + $this->assertInLogs('git-pull: pulling from origin foobranch'); + $this->assertInLogs('git-pull: complete'); + $this->assertInLogs('git-pull output: First, rewinding head to replay your work on top of it...'); + $this->assertInLogs('Fast-forwarded master to 6ad2ea37a26ce3534073e89043f890c054fddb20.'); + // make sure that foofile from foobranch made it to master + $this->assertTrue(is_readable($repository . '/foofile'));*/ + } + + public function testAllReposSet() + { + $repository = PHING_TEST_TMP . '/git'; + $this->executeTarget('allReposSet'); + $this->assertInLogs('git-pull: fetching from all remotes'); + $this->assertInLogs('git-pull: complete'); + } + + public function testTagsSet() + { + /*$repository = PHING_TEST_TMP . '/git'; + $this->executeTarget('tagsSet'); + $this->assertInLogs('git-pull: pulling from origin foobranch'); + $this->assertInLogs('git-pull: complete'); + $this->assertInLogs('git-pull output: Updating 6dbaf45..6ad2ea3'); + // make sure that foofile from foobranch made it to master + $this->assertTrue(is_readable($repository . '/foofile'));*/ + } + + public function testAppendSet() + { + $repository = PHING_TEST_TMP . '/git'; + $this->executeTarget('appendSet'); + $this->assertInLogs('git-pull: fetching from all remotes'); + $this->assertInLogs('git-pull: complete'); + $this->assertInLogs('git-pull output: Already up-to-date.'); + } + + public function testNoTagsSet() + { + /*$repository = PHING_TEST_TMP . '/git'; + $this->executeTarget('noTagsSet'); + $this->assertInLogs('git-pull: pulling from origin foobranch'); + $this->assertInLogs('git-pull: complete'); + $this->assertInLogs('git-pull output: Updating 6dbaf45..6ad2ea3'); + // make sure that foofile from foobranch made it to master + $this->assertTrue(is_readable($repository . '/foofile'));*/ + } + + public function testNoRepositorySpecified() + { + $this->expectBuildExceptionContaining('noRepository', + 'Repo dir is required', + '"repository" is required parameter'); + } + + public function testNoSourceSpecified() + { + $this->expectBuildExceptionContaining('noSource', + 'At least one source must be provided', + 'No source repository specified'); + } + + public function testWrongStrategySet() + { + $this->expectBuildExceptionContaining('wrongStrategySet', + 'Wrong strategy passed', 'Could not find merge strategy \'plain-wrong\''); + } +} diff --git a/test/phingistrano/GitTasks/.svn/text-base/GitPullTaskTest.xml.svn-base b/test/phingistrano/GitTasks/.svn/text-base/GitPullTaskTest.xml.svn-base new file mode 100644 index 0000000..23c8d70 --- /dev/null +++ b/test/phingistrano/GitTasks/.svn/text-base/GitPullTaskTest.xml.svn-base @@ -0,0 +1,93 @@ + + + + + + + + This file should only be run via a testcase + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/phingistrano/GitTasks/.svn/text-base/GitPushTaskTest.php.svn-base b/test/phingistrano/GitTasks/.svn/text-base/GitPushTaskTest.php.svn-base new file mode 100644 index 0000000..5e9e7da --- /dev/null +++ b/test/phingistrano/GitTasks/.svn/text-base/GitPushTaskTest.php.svn-base @@ -0,0 +1,112 @@ +. + */ + +require_once 'phing/BuildFileTest.php'; +require_once '../classes/phing/tasks/ext/git/GitPushTask.php'; +require_once dirname(__FILE__) . '/GitTestsHelper.php'; + +/** + * @author Victor Farazdagi + * @version $Id$ + * @package phing.tasks.ext + */ +class GitPushTaskTest extends BuildFileTest { + + public function setUp() { + if (is_readable(PHING_TEST_TMP . '/git')) { + // make sure we purge previously created directory + // if left-overs from previous run are found + GitTestsHelper::rmdir(PHING_TEST_TMP . '/git'); + } + // set temp directory used by test cases + mkdir(PHING_TEST_TMP . '/git'); + + $this->configureProject(__DIR__ . '/GitPushTaskTest.xml'); + } + + public function tearDown() + { + GitTestsHelper::rmdir(PHING_TEST_TMP . '/git'); + } + + public function testAllParamsSet() + { + $repository = PHING_TEST_TMP . '/git'; + $this->executeTarget('allParamsSet'); + $this->assertInLogs('git-push: pushing to origin master:foobranch'); + $this->assertInLogs('git-push: complete'); + } + + public function testAllReposSet() + { + $repository = PHING_TEST_TMP . '/git'; + $this->executeTarget('allReposSet'); + $this->assertInLogs('git-push: push to all refs'); + $this->assertInLogs('git-push: complete'); + } + + public function testTagsSet() + { + $repository = PHING_TEST_TMP . '/git'; + $this->executeTarget('tagsSet'); + $this->assertInLogs('git-push: pushing to origin master:foobranch'); + $this->assertInLogs('git-push: complete'); + } + + public function testDeleteSet() + { + $repository = PHING_TEST_TMP . '/git'; + $this->executeTarget('deleteSet'); + $this->assertInLogs('git-push: pushing to origin master:newbranch'); + $this->assertInLogs('git-push: branch delete requested'); + $this->assertInLogs('git-push: complete'); + } + + public function testMirrorSet() + { + $repository = PHING_TEST_TMP . '/git'; + $this->executeTarget('mirrorSet'); + $this->assertInLogs('git-push: mirror all refs'); + $this->assertInLogs('git-push: complete'); + } + + public function testNoRepositorySpecified() + { + $this->expectBuildExceptionContaining('noRepository', + 'Repo dir is required', + '"repository" is required parameter'); + } + + public function testWrongRepo() + { + $this->expectBuildExceptionContaining('wrongRepo', + 'Repo dir is wrong', + 'You must specify readable directory as repository.'); + } + + public function testNoDestinationSpecified() + { + $this->expectBuildExceptionContaining('noDestination', + 'No source set', + 'At least one destination must be provided'); + } + +} diff --git a/test/phingistrano/GitTasks/.svn/text-base/GitPushTaskTest.xml.svn-base b/test/phingistrano/GitTasks/.svn/text-base/GitPushTaskTest.xml.svn-base new file mode 100644 index 0000000..aa84d57 --- /dev/null +++ b/test/phingistrano/GitTasks/.svn/text-base/GitPushTaskTest.xml.svn-base @@ -0,0 +1,93 @@ + + + + + + + + This file should only be run via a testcase + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/phingistrano/GitTasks/.svn/text-base/GitTagTaskTest.php.svn-base b/test/phingistrano/GitTasks/.svn/text-base/GitTagTaskTest.php.svn-base new file mode 100644 index 0000000..e2ae11b --- /dev/null +++ b/test/phingistrano/GitTasks/.svn/text-base/GitTagTaskTest.php.svn-base @@ -0,0 +1,187 @@ +. + */ + +require_once 'phing/BuildFileTest.php'; +require_once '../classes/phing/tasks/ext/git/GitTagTask.php'; +require_once dirname(__FILE__) . '/GitTestsHelper.php'; + +/** + * @author Victor Farazdagi + * @version $Id$ + * @package phing.tasks.ext + */ +class GitTagTaskTest extends BuildFileTest { + + public function setUp() { + if (is_readable(PHING_TEST_TMP . '/git')) { + // make sure we purge previously created directory + // if left-overs from previous run are found + GitTestsHelper::rmdir(PHING_TEST_TMP . '/git'); + } + // set temp directory used by test cases + mkdir(PHING_TEST_TMP . '/git'); + + $this->configureProject(__DIR__ . '/GitTagTaskTest.xml'); + } + + public function tearDown() + { + GitTestsHelper::rmdir(PHING_TEST_TMP . '/git'); + } + + public function testGitTagCreate() + { + $this->executeTarget('gitTagCreate'); + $this->assertInLogs('git-tag output: ver1.0'); + } + + public function testGitTagReplaceCreateDuplicate() + { + $this->executeTarget('gitTagReplaceCreateDuplicate'); + $this->assertInLogs('git-tag command: /usr/bin/git tag -f \'ver1.0\''); + $this->assertInLogs('git-tag command: /usr/bin/git tag -l'); + $this->assertInLogs('git-tag output: ver1.0'); + } + + public function testGitTagForceCreateDuplicate() + { + $this->executeTarget('gitTagForceCreateDuplicate'); + $this->assertInLogs('git-tag command: /usr/bin/git tag -f \'ver1.0\''); + $this->assertInLogs('git-tag command: /usr/bin/git tag -l'); + $this->assertInLogs('git-tag output: ver1.0'); + } + + public function testGitTagCreateDuplicate() + { + $this->expectBuildExceptionContaining('gitTagCreateDuplicate', + 'Tag already exists', + "fatal: tag 'ver1.0' already exists"); + } + + public function testTagCreateAnnotatedNoMessage() + { + $this->expectBuildExceptionContaining('gitTagCreateAnnotatedNoMessage', + 'Message not provided..', + '"message" or "file" required to make a tag'); + } + + public function testTagCreateAnnotated() + { + $this->executeTarget('gitTagCreateAnnotated'); + $this->assertInLogs('git-tag command: /usr/bin/git tag -a -m\'Version 1.0 tag\' \'ver1.0\''); + $this->assertInLogs('git-tag command: /usr/bin/git tag -l'); + $this->assertInLogs('git-tag output: ver1.0'); + } + + public function testTagCreateAnnotatedImplicit() + { + $this->executeTarget('gitTagCreateAnnotatedImplicit'); + $this->assertInLogs('git-tag command: /usr/bin/git tag -m\'Version 1.0 tag\' \'ver1.0\''); + $this->assertInLogs('git-tag command: /usr/bin/git tag -l'); + $this->assertInLogs('git-tag output: ver1.0'); + } + + public function testTagDelete() + { + $this->executeTarget('gitTagDelete'); + $this->assertInLogs('git-tag command: /usr/bin/git tag \'ver1.0\''); + $this->assertInLogs('git-tag command: /usr/bin/git tag \'ver2.0\''); + $this->assertInLogs('git-tag command: /usr/bin/git tag -d \'ver2.0\''); + $this->assertInLogs('git-tag output: Deleted tag \'ver2.0\''); + $this->assertInLogs('git-tag command: /usr/bin/git tag -l'); + $this->assertInLogs(' ver1.0'); + $this->assertNotInLogs("\n" . 'ver2.0'); + } + + public function testTagListByPattern() + { + $this->executeTarget('gitTagListByPattern'); + $this->assertInLogs('git-tag command: /usr/bin/git tag \'ver1.0\''); + $this->assertInLogs('git-tag command: /usr/bin/git tag \'ver2.0\''); + $this->assertInLogs('git-tag command: /usr/bin/git tag \'marked\''); + $this->assertInLogs('git-tag command: /usr/bin/git tag -l \'marked\''); + $this->assertInLogs('git-tag output: marked'); + } + + public function testTagOutputPropertySet() + { + $this->executeTarget('gitTagOutpuPropertySet'); + $this->assertInLogs('git-tag command: /usr/bin/git tag \'ver1.0\''); + $this->assertInLogs('git-tag command: /usr/bin/git tag \'ver2.0\''); + $this->assertInLogs('git-tag command: /usr/bin/git tag \'marked\''); + $this->assertInLogs('git-tag command: /usr/bin/git tag -l \'marked\''); + $this->assertInLogs('git-tag output: marked'); + $this->assertPropertyEquals('gitLogOutput', 'marked' . "\n"); + } + + public function testTagWithCommitSet() + { + $this->executeTarget('gitTagWithCommitSet'); + $this->assertInLogs('git-tag command: /usr/bin/git tag \'ver1.0\' \'c573116f395d36497a1ac1dba565ecd3d3944277\''); + $this->assertInLogs('c573116f395d36497a1ac1dba565ecd3d3944277'); + $this->assertInLogs('b8cddb3fa5f408560d0d00d6c8721fe333895888'); + $this->assertInLogs('6dbaf4508e75dcd426b5b974a67c462c70d46e1f'); + $this->assertNotInLogs('1b767b75bb5329f4e53345c516c0a9f4ed32d330'); + $this->assertNotInLogs('ee07085160003ffd1100867deb6059bae0c45455'); + } + + public function testTagWithObjectSet() + { + $this->executeTarget('gitTagWithObjectSet'); + $this->assertInLogs('git-tag command: /usr/bin/git tag \'ver1.0\' \'c573116f395d36497a1ac1dba565ecd3d3944277\''); + $this->assertInLogs('c573116f395d36497a1ac1dba565ecd3d3944277'); + $this->assertInLogs('b8cddb3fa5f408560d0d00d6c8721fe333895888'); + $this->assertInLogs('6dbaf4508e75dcd426b5b974a67c462c70d46e1f'); + $this->assertNotInLogs('1b767b75bb5329f4e53345c516c0a9f4ed32d330'); + $this->assertNotInLogs('ee07085160003ffd1100867deb6059bae0c45455'); + } + + public function testTagCreateSignedDefaultKey() + { + $this->markTestSkipped('Involves configured GPG key'); + $this->executeTarget('gitTagCreateSignedDefaultKey'); + $this->assertInLogs('git-tag command: /usr/bin/git tag -m\'Version 1.0 tag\' \'ver1.0\''); + $this->assertInLogs('git-tag command: /usr/bin/git tag -l'); + $this->assertInLogs('git-tag output: ver1.0'); + } + + public function testTagFileSet() + { + $msgFile = PHING_TEST_TMP . '/msg.txt'; + $fp = fopen($msgFile, 'w'); + fwrite($fp , 'test tag message'); + fclose($fp); + + $this->executeTarget('gitTagFileSet'); + $this->assertInLogs("/usr/bin/git tag -F'{$msgFile}' 'ver1.0'"); + + unlink($msgFile); + } + + public function testNoRepositorySpecified() + { + $this->expectBuildExceptionContaining('noRepository', + 'Repo dir is required', + '"repository" is required parameter'); + } + + +} diff --git a/test/phingistrano/GitTasks/.svn/text-base/GitTagTaskTest.xml.svn-base b/test/phingistrano/GitTasks/.svn/text-base/GitTagTaskTest.xml.svn-base new file mode 100644 index 0000000..c923bfc --- /dev/null +++ b/test/phingistrano/GitTasks/.svn/text-base/GitTagTaskTest.xml.svn-base @@ -0,0 +1,191 @@ + + + + + + + + This file should only be run via a testcase + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/phingistrano/GitTasks/.svn/text-base/GitTestsHelper.php.svn-base b/test/phingistrano/GitTasks/.svn/text-base/GitTestsHelper.php.svn-base new file mode 100644 index 0000000..0156c4d --- /dev/null +++ b/test/phingistrano/GitTasks/.svn/text-base/GitTestsHelper.php.svn-base @@ -0,0 +1,56 @@ + 5259486) { + $returndate = round($timediff / 2629744) . " months ago"; + } else { + $returndate = round($timediff / 604900) . " weeks ago"; + } + + return $returndate; + } + +} diff --git a/test/phingistrano/GitTasks/GitBaseTest.php b/test/phingistrano/GitTasks/GitBaseTest.php new file mode 100644 index 0000000..def44c0 --- /dev/null +++ b/test/phingistrano/GitTasks/GitBaseTest.php @@ -0,0 +1,65 @@ +. + */ + +require_once 'phing/BuildFileTest.php'; +require_once '../classes/phing/tasks/ext/git/GitBaseTask.php'; + +/** + * @author Victor Farazdagi + * @version $Id: GitBaseTest.php 1179 2011-06-22 11:31:08Z mp $ + * @package phing.tasks.ext + */ +class GitBaseTest extends BuildFileTest { + + protected $mock; + + public function setUp() { + $this->configureProject(__DIR__ . "/GitBaseTest.xml"); + $this->mock = $this->getMockForAbstractClass('GitBaseTask'); + } + + public function testInitialization() + { + $this->assertInstanceOf('GitBaseTask', $this->mock); + } + + /** + * @todo - make sure that required arguments are checked + */ + public function testArguments() + {} + + public function testMutators() + { + // gitPath + $gitPath = $this->mock->getGitPath(); + $this->mock->setGitPath('my-new-path'); + $this->assertEquals('my-new-path', $this->mock->getGitPath()); + $this->mock->setGitPath($gitPath); + + // repository + $repository = $this->mock->getRepository(); + $this->mock->setRepository('/tmp'); + $this->assertEquals('/tmp', $this->mock->getRepository()); + $this->mock->setRepository($repository); + } + +} diff --git a/test/phingistrano/GitTasks/GitBaseTest.xml b/test/phingistrano/GitTasks/GitBaseTest.xml new file mode 100644 index 0000000..a961450 --- /dev/null +++ b/test/phingistrano/GitTasks/GitBaseTest.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/test/phingistrano/GitTasks/GitBranchTaskTest.php b/test/phingistrano/GitTasks/GitBranchTaskTest.php new file mode 100644 index 0000000..0f6d1a8 --- /dev/null +++ b/test/phingistrano/GitTasks/GitBranchTaskTest.php @@ -0,0 +1,158 @@ +. + */ + +require_once 'phing/BuildFileTest.php'; +require_once '../classes/phing/tasks/ext/git/GitBranchTask.php'; +require_once dirname(__FILE__) . '/GitTestsHelper.php'; + +/** + * @author Victor Farazdagi + * @version $Id: GitBranchTaskTest.php 1179 2011-06-22 11:31:08Z mp $ + * @package phing.tasks.ext + */ +class GitBranchTaskTest extends BuildFileTest { + + public function setUp() { + if (is_readable(PHING_TEST_TMP . '/git')) { + // make sure we purge previously created directory + // if left-overs from previous run are found + GitTestsHelper::rmdir(PHING_TEST_TMP . '/git'); + } + // set temp directory used by test cases + mkdir(PHING_TEST_TMP . '/git'); + + $this->configureProject(__DIR__ . '/GitBranchTaskTest.xml'); + } + + public function tearDown() + { + GitTestsHelper::rmdir(PHING_TEST_TMP . '/git'); + } + + public function testAllParamsSet() + { + $repository = PHING_TEST_TMP . '/git'; + $this->executeTarget('allParamsSet'); + $this->assertInLogs('git-branch output: Branch all-params-set set up to track remote branch master from origin.'); + } + + public function testNoRepositorySpecified() + { + $this->expectBuildExceptionContaining('noRepository', + 'Repo dir is required', + '"repository" is required parameter'); + } + + public function testNoBranchnameSpecified() + { + $this->expectBuildExceptionContaining('noBranchname', + 'Branchname dir is required', + '"branchname" is required parameter'); + } + + public function testTrackParameter() + { + $repository = PHING_TEST_TMP . '/git'; + + $this->executeTarget('trackParamSet'); + $this->assertInLogs('git-branch: branch "' . $repository . '" repository'); + $this->assertInLogs( 'git-branch output: Branch track-param-set set up to track local branch master.'); + } + + public function testNoTrackParameter() + { + $repository = PHING_TEST_TMP . '/git'; + + $this->executeTarget('noTrackParamSet'); + $this->assertInLogs('git-branch: branch "' . $repository . '" repository'); + $this->assertInLogs('git-branch output: '); // no output actually + } + + public function testSetUpstreamParameter() + { + $repository = PHING_TEST_TMP . '/git'; + + $this->executeTarget('setUpstreamParamSet'); + $this->assertInLogs('git-branch: branch "' . $repository . '" repository'); + $this->assertInLogs('Branch set-upstream-param-set set up to track local branch master.'); // no output actually + } + + public function testForceParameter() + { + $repository = PHING_TEST_TMP . '/git'; + + $this->executeTarget('forceParamSet'); + $this->assertInLogs('git-branch: branch "' . $repository . '" repository'); + $this->assertInLogs('git-branch output: '); // no output actually + } + + public function testDeleteBranch() + { + $repository = PHING_TEST_TMP . '/git'; + + $this->executeTarget('deleteBranch'); + $this->assertInLogs('git-branch: branch "' . $repository . '" repository'); + $this->assertInLogs('Branch delete-branch-1 set up to track local branch master.'); + $this->assertInLogs('Branch delete-branch-2 set up to track local branch master.'); + $this->assertInLogs('Deleted branch delete-branch-1'); + $this->assertInLogs('Deleted branch delete-branch-2'); + } + + public function testMoveBranch() + { + $repository = PHING_TEST_TMP . '/git'; + + $this->executeTarget('moveBranch'); + $this->assertInLogs('git-branch: branch "' . $repository . '" repository'); + // try to delete new branch (thus understanding that rename worked) + $this->assertInLogs('Deleted branch move-branch-2'); + } + + public function testForceMoveBranch() + { + $repository = PHING_TEST_TMP . '/git'; + + $this->executeTarget('forceMoveBranch'); + $this->assertInLogs('git-branch: branch "' . $repository . '" repository'); + // try to delete new branch (thus understanding that rename worked) + $this->assertInLogs('Deleted branch move-branch-2'); + } + + public function testForceMoveBranchNoNewbranch() + { + $repository = PHING_TEST_TMP . '/git'; + + $this->expectBuildExceptionContaining('forceMoveBranchNoNewbranch', + 'New branch name is required in branch move', + '"newbranch" is required parameter'); + } + + public function testMoveBranchNoNewbranch() + { + $repository = PHING_TEST_TMP . '/git'; + + $this->expectBuildExceptionContaining('moveBranchNoNewbranch', + 'New branch name is required in branch move', + '"newbranch" is required parameter'); + } + + +} diff --git a/test/phingistrano/GitTasks/GitBranchTaskTest.xml b/test/phingistrano/GitTasks/GitBranchTaskTest.xml new file mode 100644 index 0000000..1517fb8 --- /dev/null +++ b/test/phingistrano/GitTasks/GitBranchTaskTest.xml @@ -0,0 +1,158 @@ + + + + + + + + This file should only be run via a testcase + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/phingistrano/GitTasks/GitCheckoutTaskTest.php b/test/phingistrano/GitTasks/GitCheckoutTaskTest.php new file mode 100644 index 0000000..a4bc346 --- /dev/null +++ b/test/phingistrano/GitTasks/GitCheckoutTaskTest.php @@ -0,0 +1,117 @@ +. + */ + +require_once 'phing/BuildFileTest.php'; +require_once '../classes/phing/tasks/ext/git/GitCheckoutTask.php'; +require_once dirname(__FILE__) . '/GitTestsHelper.php'; + +/** + * @author Victor Farazdagi + * @version $Id: GitCheckoutTaskTest.php 1179 2011-06-22 11:31:08Z mp $ + * @package phing.tasks.ext + */ +class GitCheckoutTaskTest extends BuildFileTest { + + public function setUp() { + if (is_readable(PHING_TEST_TMP . '/git')) { + // make sure we purge previously created directory + // if left-overs from previous run are found + GitTestsHelper::rmdir(PHING_TEST_TMP . '/git'); + } + // set temp directory used by test cases + mkdir(PHING_TEST_TMP . '/git'); + + $this->configureProject(__DIR__ . '/GitCheckoutTaskTest.xml'); + } + + public function tearDown() + { + GitTestsHelper::rmdir(PHING_TEST_TMP . '/git'); + } + + public function testCheckoutExistingBranch() + { + $repository = PHING_TEST_TMP . '/git'; + $this->executeTarget('checkoutExistingBranch'); + $this->assertInLogs('git-checkout: checkout "' . $repository . '" repository'); + $this->assertInLogs('git-branch output: Branch co-branch set up to track remote branch master from origin.'); + // @todo - actually make sure that Ebihara updates code to return (not + // echo output from $command->execute() + //$this->assertInLogs("Switched to branch 'test'"); + $this->assertInLogs('git-checkout output: '); // no output actually + } + + public function testCheckoutNonExistingBranch() + { + $this->expectBuildExceptionContaining('checkoutNonExistingBranch', + 'Checkout of non-existent repo is impossible', + 'Task execution failed'); + } + + public function testNoRepositorySpecified() + { + $this->expectBuildExceptionContaining('noRepository', + 'Repo dir is required', + '"repository" is required parameter'); + } + + public function testNoBranchnameSpecified() + { + $this->expectBuildExceptionContaining('noBranchname', + 'Branchname is required', + '"branchname" is required parameter'); + } + + public function testCheckoutMerge() + { + $repository = PHING_TEST_TMP . '/git'; + $this->executeTarget('checkoutMerge'); + $this->assertInLogs('git-checkout: checkout "' . $repository . '" repository'); + $this->assertInLogs('git-branch output: Branch co-branch set up to track remote branch master from origin.'); + $this->assertInLogs('git-branch output: Deleted branch master'); + } + + public function testCheckoutCreateBranch() + { + $repository = PHING_TEST_TMP . '/git'; + $this->executeTarget('checkoutCreateBranch'); + $this->assertInLogs('git-checkout: checkout "' . $repository . '" repository'); + $this->assertInLogs('git-checkout output: Branch co-create-branch set up to track remote branch master from origin.'); + $this->assertInLogs('git-branch output: Deleted branch co-create-branch'); + } + + public function testForceCheckoutCreateBranch() + { + $repository = PHING_TEST_TMP . '/git'; + $this->executeTarget('checkoutForceCreateBranch'); + $this->assertInLogs('git-checkout: checkout "' . $repository . '" repository'); + $this->assertInLogs('git-branch output: Deleted branch co-create-branch'); + } + + public function testForceCheckoutCreateBranchFailed() + { + $this->expectBuildExceptionContaining('checkoutForceCreateBranchFailed', + 'Branch already exists', + 'Task execution failed.'); + } + + +} diff --git a/test/phingistrano/GitTasks/GitCheckoutTaskTest.xml b/test/phingistrano/GitTasks/GitCheckoutTaskTest.xml new file mode 100644 index 0000000..e22534a --- /dev/null +++ b/test/phingistrano/GitTasks/GitCheckoutTaskTest.xml @@ -0,0 +1,122 @@ + + + + + + + + This file should only be run via a testcase + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/phingistrano/GitTasks/GitCloneTaskTest.php b/test/phingistrano/GitTasks/GitCloneTaskTest.php new file mode 100644 index 0000000..6f61757 --- /dev/null +++ b/test/phingistrano/GitTasks/GitCloneTaskTest.php @@ -0,0 +1,100 @@ +. + */ + +require_once 'phing/BuildFileTest.php'; +require_once '../classes/phing/tasks/ext/git/GitCloneTask.php'; +require_once dirname(__FILE__) . '/GitTestsHelper.php'; + +/** + * @author Victor Farazdagi + * @version $Id: GitCloneTaskTest.php 1179 2011-06-22 11:31:08Z mp $ + * @package phing.tasks.ext + */ +class GitCloneTaskTest extends BuildFileTest { + + public function setUp() { + // set temp directory used by test cases + mkdir(PHING_TEST_TMP . '/git'); + + $this->configureProject(__DIR__ . '/GitCloneTaskTest.xml'); + } + + public function tearDown() + { + GitTestsHelper::rmdir(PHING_TEST_TMP . '/git'); + } + + public function testWrongRepository() + { + $this->expectBuildExceptionContaining('wrongRepository', + 'Repository not readable', + 'The remote end hung up unexpectedly'); + } + + public function testWrongTargetPath() + { + $this->expectBuildExceptionContaining('wrongTargetPath', + 'Repository not readable', + 'You must specify readable directory as repository'); + } + + public function testGitClone() + { + $repository = PHING_TEST_TMP . '/git'; + $gitFilesDir = $repository . '/.git'; + $this->executeTarget('gitClone'); + + $this->assertInLogs('git-clone: cloning "git://github.com/farazdagi/phing-tests.git" repository to "' . $repository . '" directory'); + $this->assertTrue(is_dir($repository)); + $this->assertTrue(is_dir($gitFilesDir)); + // test that file is actully cloned + $this->assertTrue(is_readable($repository . '/README')); + } + + public function testGitCloneBare() + { + $repository = PHING_TEST_TMP . '/git'; + $gitFilesDir = $repository . '/.git'; + $this->executeTarget('gitCloneBare'); + $this->assertInLogs('git-clone: cloning (bare) "git://github.com/farazdagi/phing-tests.git" repository to "' . $repository . '" directory'); + $this->assertTrue(is_dir($repository)); + $this->assertTrue(is_dir($repository . '/branches')); + $this->assertTrue(is_dir($repository . '/info')); + $this->assertTrue(is_dir($repository . '/hooks')); + $this->assertTrue(is_dir($repository . '/refs')); + } + + public function testNoRepositorySpecified() + { + $this->expectBuildExceptionContaining('noRepository', + 'Repo dir is required', + '"repository" is required parameter'); + } + + public function testNoTargetPathSpecified() + { + $this->expectBuildExceptionContaining('noTargetPath', + 'Target path is required', + '"targetPath" is required parameter'); + } + + +} diff --git a/test/phingistrano/GitTasks/GitCloneTaskTest.xml b/test/phingistrano/GitTasks/GitCloneTaskTest.xml new file mode 100644 index 0000000..834e316 --- /dev/null +++ b/test/phingistrano/GitTasks/GitCloneTaskTest.xml @@ -0,0 +1,43 @@ + + + + + + + + This file should only be run via a testcase + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/phingistrano/GitTasks/GitFetchTaskTest.php b/test/phingistrano/GitTasks/GitFetchTaskTest.php new file mode 100644 index 0000000..e4e5f77 --- /dev/null +++ b/test/phingistrano/GitTasks/GitFetchTaskTest.php @@ -0,0 +1,88 @@ +. + */ + +require_once 'phing/BuildFileTest.php'; +require_once '../classes/phing/tasks/ext/git/GitFetchTask.php'; +require_once dirname(__FILE__) . '/GitTestsHelper.php'; + +/** + * @author Victor Farazdagi + * @version $Id: GitFetchTaskTest.php 1179 2011-06-22 11:31:08Z mp $ + * @package phing.tasks.ext + */ +class GitFetchTaskTest extends BuildFileTest { + + public function setUp() { + if (is_readable(PHING_TEST_TMP . '/git')) { + // make sure we purge previously created directory + // if left-overs from previous run are found + GitTestsHelper::rmdir(PHING_TEST_TMP . '/git'); + } + // set temp directory used by test cases + mkdir(PHING_TEST_TMP . '/git'); + + $this->configureProject(__DIR__ . '/GitFetchTaskTest.xml'); + } + + public function tearDown() + { + GitTestsHelper::rmdir(PHING_TEST_TMP . '/git'); + } + + public function testAllParamsSet() + { + $repository = PHING_TEST_TMP . '/git'; + $this->executeTarget('allParamsSet'); + $this->assertInLogs('git-fetch: branch "' . $repository . '" repository'); + $this->assertInLogs('git-fetch output: '); // no output actually + } + + public function testFetchAllRemotes() + { + $repository = PHING_TEST_TMP . '/git'; + $this->executeTarget('fetchAllRemotes'); + $this->assertInLogs('git-fetch: branch "' . $repository . '" repository'); + $this->assertInLogs('git-fetch output: Fetching origin'); + } + + public function testNoRepositorySpecified() + { + $this->expectBuildExceptionContaining('noRepository', + 'Repo dir is required', + '"repository" is required parameter'); + } + + public function testNoTargetSpecified() + { + $this->expectBuildExceptionContaining('noTarget', + 'Target is required', + 'No remote repository specified'); + } + + public function testRefspecSet() + { + $repository = PHING_TEST_TMP . '/git'; + $this->executeTarget('refspecSet'); + $this->assertInLogs('git-fetch: branch "' . $repository . '" repository'); + $this->assertInLogs('git-fetch output: '); + $this->assertInLogs('Deleted branch refspec-branch'); + } +} diff --git a/test/phingistrano/GitTasks/GitFetchTaskTest.xml b/test/phingistrano/GitTasks/GitFetchTaskTest.xml new file mode 100644 index 0000000..9de0d48 --- /dev/null +++ b/test/phingistrano/GitTasks/GitFetchTaskTest.xml @@ -0,0 +1,51 @@ + + + + + + + + This file should only be run via a testcase + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/phingistrano/GitTasks/GitGcTaskTest.php b/test/phingistrano/GitTasks/GitGcTaskTest.php new file mode 100644 index 0000000..4f754fc --- /dev/null +++ b/test/phingistrano/GitTasks/GitGcTaskTest.php @@ -0,0 +1,99 @@ +. + */ + +require_once 'phing/BuildFileTest.php'; +require_once '../classes/phing/tasks/ext/git/GitGcTask.php'; +require_once dirname(__FILE__) . '/GitTestsHelper.php'; + +/** + * @author Victor Farazdagi + * @version $Id: GitGcTaskTest.php 1179 2011-06-22 11:31:08Z mp $ + * @package phing.tasks.ext + */ +class GitGcTaskTest extends BuildFileTest { + + public function setUp() { + if (is_readable(PHING_TEST_TMP . '/git')) { + // make sure we purge previously created directory + // if left-overs from previous run are found + GitTestsHelper::rmdir(PHING_TEST_TMP . '/git'); + } + // set temp directory used by test cases + mkdir(PHING_TEST_TMP . '/git'); + + $this->configureProject(__DIR__ . '/GitGcTaskTest.xml'); + } + + public function tearDown() + { + GitTestsHelper::rmdir(PHING_TEST_TMP . '/git'); + } + + public function testAllParamsSet() + { + $repository = PHING_TEST_TMP . '/git'; + $this->executeTarget('allParamsSet'); + $this->assertInLogs('git-gc: cleaning up "' . $repository . '" repository'); + } + + public function testNoRepositorySpecified() + { + $this->expectBuildExceptionContaining('noRepository', + 'Repo dir is required', + '"repository" is required parameter'); + } + + public function testAutoParameter() + { + $repository = PHING_TEST_TMP . '/git'; + $msg = 'git-gc: cleaning up "' . $repository . '" repository'; + + $this->executeTarget('autoParamSet'); + $this->assertInLogs($msg); + } + + public function testNoPruneParameter() + { + $repository = PHING_TEST_TMP . '/git'; + $msg = 'git-gc: cleaning up "' . $repository . '" repository'; + + $this->executeTarget('nopruneParamSet'); + $this->assertInLogs($msg); + } + + public function testAggressiveParameter() + { + $repository = PHING_TEST_TMP . '/git'; + $msg = 'git-gc: cleaning up "' . $repository . '" repository'; + + $this->executeTarget('aggressiveParamSet'); + $this->assertInLogs($msg); + } + + public function testPruneParameter() + { + $repository = PHING_TEST_TMP . '/git'; + $msg = 'git-gc: cleaning up "' . $repository . '" repository'; + + $this->executeTarget('pruneParamSet'); + $this->assertInLogs($msg); + } +} diff --git a/test/phingistrano/GitTasks/GitGcTaskTest.xml b/test/phingistrano/GitTasks/GitGcTaskTest.xml new file mode 100644 index 0000000..fe2615a --- /dev/null +++ b/test/phingistrano/GitTasks/GitGcTaskTest.xml @@ -0,0 +1,57 @@ + + + + + + + + This file should only be run via a testcase + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/phingistrano/GitTasks/GitInitTaskTest.php b/test/phingistrano/GitTasks/GitInitTaskTest.php new file mode 100644 index 0000000..2d43953 --- /dev/null +++ b/test/phingistrano/GitTasks/GitInitTaskTest.php @@ -0,0 +1,83 @@ +. + */ + +require_once 'phing/BuildFileTest.php'; +require_once '../classes/phing/tasks/ext/git/GitInitTask.php'; +require_once dirname(__FILE__) . '/GitTestsHelper.php'; + +/** + * @author Victor Farazdagi + * @version $Id: GitInitTaskTest.php 1179 2011-06-22 11:31:08Z mp $ + * @package phing.tasks.ext + */ +class GitInitTaskTest extends BuildFileTest { + + public function setUp() { + // set temp directory used by test cases + mkdir(PHING_TEST_TMP . '/git'); + + $this->configureProject(__DIR__ . '/GitInitTaskTest.xml'); + } + + public function tearDown() + { + GitTestsHelper::rmdir(PHING_TEST_TMP . '/git'); + } + + public function testWrongRepository() + { + $this->expectBuildExceptionContaining('wrongRepository', + 'Repository directory not readable', + 'You must specify readable directory as repository.'); + } + + public function testGitInit() + { + $repository = PHING_TEST_TMP . '/git'; + $gitFilesDir = $repository . '/.git'; + $this->executeTarget('gitInit'); + + $this->assertInLogs('git-init: initializing "' . $repository . '" repository'); + $this->assertTrue(is_dir($repository)); + $this->assertTrue(is_dir($gitFilesDir)); + } + + public function testGitInitBare() + { + $repository = PHING_TEST_TMP . '/git'; + $gitFilesDir = $repository . '/.git'; + $this->executeTarget('gitInitBare'); + $this->assertInLogs('git-init: initializing (bare) "' . $repository . '" repository'); + $this->assertTrue(is_dir($repository)); + $this->assertTrue(is_dir($repository . '/branches')); + $this->assertTrue(is_dir($repository . '/info')); + $this->assertTrue(is_dir($repository . '/hooks')); + $this->assertTrue(is_dir($repository . '/refs')); + } + + public function testNoRepositorySpecified() + { + $this->expectBuildExceptionContaining('noRepository', + 'Repo dir is required', + '"repository" is required parameter'); + } + +} diff --git a/test/phingistrano/GitTasks/GitInitTaskTest.xml b/test/phingistrano/GitTasks/GitInitTaskTest.xml new file mode 100644 index 0000000..39f1488 --- /dev/null +++ b/test/phingistrano/GitTasks/GitInitTaskTest.xml @@ -0,0 +1,27 @@ + + + + + + + + This file should only be run via a testcase + + + + + + + + + + + + + + + + + + + diff --git a/test/phingistrano/GitTasks/GitLogTaskTest.php b/test/phingistrano/GitTasks/GitLogTaskTest.php new file mode 100644 index 0000000..bc58a8d --- /dev/null +++ b/test/phingistrano/GitTasks/GitLogTaskTest.php @@ -0,0 +1,301 @@ +. + */ + +require_once 'phing/BuildFileTest.php'; +require_once '../classes/phing/tasks/ext/git/GitLogTask.php'; +require_once dirname(__FILE__) . '/GitTestsHelper.php'; + +/** + * @author Victor Farazdagi + * @version $Id: GitLogTaskTest.php 1179 2011-06-22 11:31:08Z mp $ + * @package phing.tasks.ext + */ +class GitLogTaskTest extends BuildFileTest { + + private $testCommits = array( + array( + 'commit' => '6dbaf4508e75dcd426b5b974a67c462c70d46e1f', + 'author' => 'Victor Farazdagi ', + 'date' => 'Sun Sep 26 21:14:44 2010 +0400', + 'msg' => 'Inited', + 'msg-full' => '', + 'From' => '6dbaf4508e75dcd426b5b974a67c462c70d46e1f Mon Sep 17 00:00:00 2001', + 'From:' => 'Victor Farazdagi ', + 'Date' => 'Sun, 26 Sep 2010 21:14:44 +0400', + 'Subject' => '[PATCH] Inited', + ), + array( + 'commit' => 'b8cddb3fa5f408560d0d00d6c8721fe333895888', + 'author' => 'Victor Farazdagi ', + 'date' => 'Sun Jan 23 22:53:07 2011 +0300', + 'msg' => 'Added file1 + file2', + 'msg-full' => '', + 'From' => 'b8cddb3fa5f408560d0d00d6c8721fe333895888 Mon Sep 17 00:00:00 2001', + 'From:' => 'Victor Farazdagi ', + 'Date' => 'Sun, 23 Jan 2011 22:53:07 +0300', + 'Subject' => '[PATCH] Added file1 + file2', + ), + array( + 'commit' => 'c573116f395d36497a1ac1dba565ecd3d3944277', + 'author' => 'Victor Farazdagi ', + 'date' => 'Sun Jan 23 22:53:19 2011 +0300', + 'msg' => 'Added file3', + 'msg-full' => '', + 'From' => 'c573116f395d36497a1ac1dba565ecd3d3944277 Mon Sep 17 00:00:00 2001', + 'From:' => 'Victor Farazdagi ', + 'Date' => 'Sun, 23 Jan 2011 22:53:19 +0300', + 'Subject' => '[PATCH] Added file3', + ), + array( + 'commit' => '2b4a5409bf60813b6a84d583bbdcbed25c7c3a00', + 'author' => 'Victor Farazdagi ', + 'date' => 'Sun Jan 23 22:53:42 2011 +0300', + 'msg' => 'Removed file3', + 'msg-full' => '', + 'From' => '2b4a5409bf60813b6a84d583bbdcbed25c7c3a00 Mon Sep 17 00:00:00 2001', + 'From:' => 'Victor Farazdagi ', + 'Date' => 'Sun, 23 Jan 2011 22:53:42 +0300', + 'Subject' => '[PATCH] Removed file3', + ), + array( + 'commit' => 'ee07085160003ffd1100867deb6059bae0c45455', + 'author' => 'Victor Farazdagi ', + 'date' => 'Sun Jan 23 23:38:34 2011 +0300', + 'msg' => 'Title: file4 was added', + 'msg-full' => 'Full commit message: and here goes some elaboration on what has been done.', + 'From' => 'ee07085160003ffd1100867deb6059bae0c45455 Mon Sep 17 00:00:00 2001', + 'From:' => 'Victor Farazdagi ', + 'Date' => 'Sun, 23 Jan 2011 23:38:34 +0300', + 'Subject' => '[PATCH] Title: file4 was added', + ), + array( + 'commit' => '1b767b75bb5329f4e53345c516c0a9f4ed32d330', + 'author' => 'Victor Farazdagi ', + 'date' => 'Mon Jan 24 09:58:33 2011 +0300', + 'msg' => 'Added file5', + 'msg-full' => 'This file was added one day after file1, file2, file3 and file4 were added', + 'From' => '1b767b75bb5329f4e53345c516c0a9f4ed32d330 Mon Sep 17 00:00:00 2001', + 'From:' => 'Victor Farazdagi ', + 'Date' => 'Mon, 24 Jan 2011 09:58:33 +0300', + 'Subject' => '[PATCH] Added file5', + ), + + ); + + public function setUp() { + if (is_readable(PHING_TEST_TMP . '/git')) { + // make sure we purge previously created directory + // if left-overs from previous run are found + GitTestsHelper::rmdir(PHING_TEST_TMP . '/git'); + } + // set temp directory used by test cases + mkdir(PHING_TEST_TMP . '/git'); + + $this->configureProject(__DIR__ . '/GitLogTaskTest.xml'); + } + + public function tearDown() + { + GitTestsHelper::rmdir(PHING_TEST_TMP . '/git'); + } + + public function testGitLogWithoutParams() + { + $this->executeTarget('gitLogWithoutParams'); + foreach($this->testCommits as $commit) { + $this->assertInLogs($commit['date']); + $this->assertInLogs($commit['author']); + $this->assertInLogs($commit['commit']); + $this->assertInLogs($commit['msg']); + if (strlen($commit['msg-full'])) { + $this->assertInLogs($commit['msg-full']); + } + } + } + + public function testGitWithMostParams() + { + $this->executeTarget('gitLogWithMostParams'); + $lastTwoCommits = array_slice($this->testCommits, -2); + $allOtherCommits = array_slice($this->testCommits, 0, -2); + + // test max-count + foreach($lastTwoCommits as $commit) { + $this->assertInLogs($commit['commit']); + $this->assertInLogs($commit['msg']); + } + foreach($allOtherCommits as $commit) { + $this->assertNotInLogs($commit['commit']); + $this->assertNotInLogs($commit['msg']); + } + + $this->assertInLogs('0 files changed, 0 insertions(+), 0 deletions(-)'); + + } + + public function testGitOutputPropertySet() + { + $this->executeTarget('gitLogOutputPropertySet'); + $this->assertPropertyEquals('gitLogOutput', '1b767b75bb5329f4e53345c516c0a9f4ed32d330 Added file5' . "\n"); + } + + public function testGitLogNameStatus() + { + $this->executeTarget('gitLogNameStatusSet'); + $this->assertInLogs("A\tfile1"); + $this->assertInLogs("A\tfile2"); + $this->assertInLogs("A\tfile3"); + $this->assertInLogs("A\tREADME"); + $this->assertInLogs("D\tfile3"); + } + + public function testGitDateRelative() + { + $this->executeTarget('gitLogDateRelative'); + foreach($this->testCommits as $commit) { + $timestamp = strtotime($commit['date']); + $this->assertInLogs(GitTestsHelper::getRelativeDate($timestamp)); + } + } + + public function testGitSinceUntilSet() + { + $this->executeTarget('gitLogSinceUntilSet'); + $this->assertNotInLogs('6dbaf4508e75dcd426b5b974a67c462c70d46e1f Inited'); + $this->assertNotInLogs('1b767b75bb5329f4e53345c516c0a9f4ed32d330 Added file5'); + $this->assertInLogs('ee07085160003ffd1100867deb6059bae0c45455 Title: file4 was added'); + $this->assertInLogs('2b4a5409bf60813b6a84d583bbdcbed25c7c3a00 Removed file3'); + $this->assertInLogs('c573116f395d36497a1ac1dba565ecd3d3944277 Added file3'); + $this->assertInLogs('b8cddb3fa5f408560d0d00d6c8721fe333895888 Added file1 + file2'); + } + + public function testGitBeforeAfterSet() + { + $this->executeTarget('gitLogBeforeAfterSet'); + $this->assertNotInLogs('6dbaf4508e75dcd426b5b974a67c462c70d46e1f Inited'); + $this->assertNotInLogs('1b767b75bb5329f4e53345c516c0a9f4ed32d330 Added file5'); + $this->assertInLogs('ee07085160003ffd1100867deb6059bae0c45455 Title: file4 was added'); + $this->assertInLogs('2b4a5409bf60813b6a84d583bbdcbed25c7c3a00 Removed file3'); + $this->assertInLogs('c573116f395d36497a1ac1dba565ecd3d3944277 Added file3'); + $this->assertInLogs('b8cddb3fa5f408560d0d00d6c8721fe333895888 Added file1 + file2'); + } + + public function testGitFormatOneLine() + { + $this->executeTarget('gitLogFormatOneLine'); + foreach($this->testCommits as $commit) { + $this->assertNotInLogs($commit['author']); + $this->assertNotInLogs($commit['date']); + $this->assertInLogs($commit['commit']); + $this->assertInLogs($commit['msg']); + } + } + + public function testGitFormatShort() + { + $this->executeTarget('gitLogFormatShort'); + foreach($this->testCommits as $commit) { + $this->assertNotInLogs($commit['date']); + $this->assertInLogs($commit['author']); + $this->assertInLogs($commit['commit']); + $this->assertInLogs($commit['msg']); + } + } + + public function testGitFormatMedium() + { + $this->executeTarget('gitLogFormatMedium'); + foreach($this->testCommits as $commit) { + $this->assertInLogs($commit['date']); + $this->assertInLogs($commit['author']); + $this->assertInLogs($commit['commit']); + $this->assertInLogs($commit['msg']); + if (strlen($commit['msg-full'])) { + $this->assertInLogs($commit['msg-full']); + } + } + } + + public function testGitFormatFull() + { + $this->executeTarget('gitLogFormatFull'); + foreach($this->testCommits as $commit) { + $this->assertNotInLogs($commit['date']); + $this->assertInLogs('Author: ' . $commit['author']); + $this->assertInLogs('Commit: ' . $commit['author']); + $this->assertInLogs('commit ' . $commit['commit']); + $this->assertInLogs($commit['msg']); + if (strlen($commit['msg-full'])) { + $this->assertInLogs($commit['msg-full']); + } + } + } + + public function testGitFormatFuller() + { + $this->executeTarget('gitLogFormatFuller'); + foreach($this->testCommits as $commit) { + $this->assertInLogs('Author: ' . $commit['author']); + $this->assertInLogs('AuthorDate: ' . $commit['date']); + $this->assertInLogs('Commit: ' . $commit['author']); + $this->assertInLogs('CommitDate: ' . $commit['date']); + $this->assertInLogs('commit ' . $commit['commit']); + $this->assertInLogs($commit['msg']); + if (strlen($commit['msg-full'])) { + $this->assertInLogs($commit['msg-full']); + } + } + } + + public function testGitFormatEmail() + { + $this->executeTarget('gitLogFormatEmail'); + foreach($this->testCommits as $commit) { + $this->assertInLogs('From ' . $commit['From']); + $this->assertInLogs('From: ' . $commit['From:']); + $this->assertInLogs('Date: ' . $commit['Date']); + $this->assertInLogs('Subject: ' . $commit['Subject']); + if (strlen($commit['msg-full'])) { + $this->assertInLogs($commit['msg-full']); + } + } + } + + public function testGitFormatCustom() + { + $this->executeTarget('gitLogFormatCustom'); + foreach($this->testCommits as $commit) { + $this->assertInLogs( + sprintf('The author of %s was %s', $commit['commit'], $commit['author'])); + } + } + + + + public function testNoRepositorySpecified() + { + $this->expectBuildExceptionContaining('noRepository', + 'Repo dir is required', + '"repository" is required parameter'); + } + + +} diff --git a/test/phingistrano/GitTasks/GitLogTaskTest.xml b/test/phingistrano/GitTasks/GitLogTaskTest.xml new file mode 100644 index 0000000..c89cd73 --- /dev/null +++ b/test/phingistrano/GitTasks/GitLogTaskTest.xml @@ -0,0 +1,167 @@ + + + + + + + + This file should only be run via a testcase + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/phingistrano/GitTasks/GitMergeTaskTest.php b/test/phingistrano/GitTasks/GitMergeTaskTest.php new file mode 100644 index 0000000..076e3c8 --- /dev/null +++ b/test/phingistrano/GitTasks/GitMergeTaskTest.php @@ -0,0 +1,102 @@ +. + */ + +require_once 'phing/BuildFileTest.php'; +require_once '../classes/phing/tasks/ext/git/GitMergeTask.php'; +require_once dirname(__FILE__) . '/GitTestsHelper.php'; + +/** + * @author Victor Farazdagi + * @version $Id: GitMergeTaskTest.php 1179 2011-06-22 11:31:08Z mp $ + * @package phing.tasks.ext + */ +class GitMergeTaskTest extends BuildFileTest { + + public function setUp() { + if (is_readable(PHING_TEST_TMP . '/git')) { + // make sure we purge previously created directory + // if left-overs from previous run are found + GitTestsHelper::rmdir(PHING_TEST_TMP . '/git'); + } + // set temp directory used by test cases + mkdir(PHING_TEST_TMP . '/git'); + + $this->configureProject(__DIR__ . '/GitMergeTaskTest.xml'); + } + + public function tearDown() + { + GitTestsHelper::rmdir(PHING_TEST_TMP . '/git'); + } + + public function testAllParamsSet() + { + $repository = PHING_TEST_TMP . '/git'; + $this->executeTarget('allParamsSet'); + $this->assertInLogs('git-merge: replaying "merge-test-1 merge-test-2" commits'); + $this->assertInLogs('git-merge output: Already up-to-date.'); + } + + public function testNoCommitSet() + { + $repository = PHING_TEST_TMP . '/git'; + $this->executeTarget('noCommitSet'); + $this->assertInLogs('git-merge: replaying "6dbaf4508e75dcd426b5b974a67c462c70d46e1f" commits'); + $this->assertInLogs('git-merge output: Already up-to-date.'); + } + + public function testRemoteSet() + { + $repository = PHING_TEST_TMP . '/git'; + $this->executeTarget('remoteSet'); + $this->assertInLogs('git-merge: replaying "6dbaf4508e75dcd426b5b974a67c462c70d46e1f" commits'); + $this->assertInLogs('git-merge output: Already up-to-date.'); + } + + public function testFastForwardCommitSet() + { + $repository = PHING_TEST_TMP . '/git'; + $this->executeTarget('fastForwardCommitSet'); + $this->assertInLogs('git-merge command: /usr/bin/git merge --no-ff \'origin/master\''); + $this->assertInLogs('git-merge: replaying "origin/master" commits'); + $this->assertInLogs('Merge remote-tracking branch \'origin/master\' into merge-test-1'); + } + + public function testNoRepositorySpecified() + { + $this->expectBuildExceptionContaining('noRepository', + 'Repo dir is required', + '"repository" is required parameter'); + } + + public function testNoRemotesSpecified() + { + $this->expectBuildExceptionContaining('noRemotes', + 'At least one commit is required', + '"remote" is required parameter'); + } + + public function testWrongStrategySet() + { + $this->expectBuildExceptionContaining('wrongStrategySet', + 'Wrong strategy passed', 'Could not find merge strategy \'plain-wrong\''); + } +} diff --git a/test/phingistrano/GitTasks/GitMergeTaskTest.xml b/test/phingistrano/GitTasks/GitMergeTaskTest.xml new file mode 100644 index 0000000..4ed4d34 --- /dev/null +++ b/test/phingistrano/GitTasks/GitMergeTaskTest.xml @@ -0,0 +1,112 @@ + + + + + + + + This file should only be run via a testcase + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/phingistrano/GitTasks/GitPullTaskTest.php b/test/phingistrano/GitTasks/GitPullTaskTest.php new file mode 100644 index 0000000..e62800b --- /dev/null +++ b/test/phingistrano/GitTasks/GitPullTaskTest.php @@ -0,0 +1,131 @@ +. + */ + +require_once 'phing/BuildFileTest.php'; +require_once '../classes/phing/tasks/ext/git/GitPullTask.php'; +require_once dirname(__FILE__) . '/GitTestsHelper.php'; + +/** + * @author Victor Farazdagi + * @version $Id: GitPullTaskTest.php 1179 2011-06-22 11:31:08Z mp $ + * @package phing.tasks.ext + */ +class GitPullTaskTest extends BuildFileTest { + + public function setUp() { + if (is_readable(PHING_TEST_TMP . '/git')) { + // make sure we purge previously created directory + // if left-overs from previous run are found + GitTestsHelper::rmdir(PHING_TEST_TMP . '/git'); + } + // set temp directory used by test cases + mkdir(PHING_TEST_TMP . '/git'); + + $this->configureProject(__DIR__ . '/GitPullTaskTest.xml'); + } + + public function tearDown() + { + GitTestsHelper::rmdir(PHING_TEST_TMP . '/git'); + } + + public function testAllParamsSet() + { + /*$repository = PHING_TEST_TMP . '/git'; + $this->executeTarget('allParamsSet'); + $this->assertInLogs('git-pull: pulling from origin foobranch'); + $this->assertInLogs('git-pull: complete'); + $this->assertInLogs('git-pull output: Updating 6dbaf45..6ad2ea3'); + // make sure that foofile from foobranch made it to master + $this->assertTrue(is_readable($repository . '/foofile'));*/ + } + + public function testAllParamsSetRebase() + { + /*$repository = PHING_TEST_TMP . '/git'; + $this->executeTarget('allParamsSetRebase'); + $this->assertInLogs('git-pull: pulling from origin foobranch'); + $this->assertInLogs('git-pull: complete'); + $this->assertInLogs('git-pull output: First, rewinding head to replay your work on top of it...'); + $this->assertInLogs('Fast-forwarded master to 6ad2ea37a26ce3534073e89043f890c054fddb20.'); + // make sure that foofile from foobranch made it to master + $this->assertTrue(is_readable($repository . '/foofile'));*/ + } + + public function testAllReposSet() + { + $repository = PHING_TEST_TMP . '/git'; + $this->executeTarget('allReposSet'); + $this->assertInLogs('git-pull: fetching from all remotes'); + $this->assertInLogs('git-pull: complete'); + } + + public function testTagsSet() + { + /*$repository = PHING_TEST_TMP . '/git'; + $this->executeTarget('tagsSet'); + $this->assertInLogs('git-pull: pulling from origin foobranch'); + $this->assertInLogs('git-pull: complete'); + $this->assertInLogs('git-pull output: Updating 6dbaf45..6ad2ea3'); + // make sure that foofile from foobranch made it to master + $this->assertTrue(is_readable($repository . '/foofile'));*/ + } + + public function testAppendSet() + { + $repository = PHING_TEST_TMP . '/git'; + $this->executeTarget('appendSet'); + $this->assertInLogs('git-pull: fetching from all remotes'); + $this->assertInLogs('git-pull: complete'); + $this->assertInLogs('git-pull output: Already up-to-date.'); + } + + public function testNoTagsSet() + { + /*$repository = PHING_TEST_TMP . '/git'; + $this->executeTarget('noTagsSet'); + $this->assertInLogs('git-pull: pulling from origin foobranch'); + $this->assertInLogs('git-pull: complete'); + $this->assertInLogs('git-pull output: Updating 6dbaf45..6ad2ea3'); + // make sure that foofile from foobranch made it to master + $this->assertTrue(is_readable($repository . '/foofile'));*/ + } + + public function testNoRepositorySpecified() + { + $this->expectBuildExceptionContaining('noRepository', + 'Repo dir is required', + '"repository" is required parameter'); + } + + public function testNoSourceSpecified() + { + $this->expectBuildExceptionContaining('noSource', + 'At least one source must be provided', + 'No source repository specified'); + } + + public function testWrongStrategySet() + { + $this->expectBuildExceptionContaining('wrongStrategySet', + 'Wrong strategy passed', 'Could not find merge strategy \'plain-wrong\''); + } +} diff --git a/test/phingistrano/GitTasks/GitPullTaskTest.xml b/test/phingistrano/GitTasks/GitPullTaskTest.xml new file mode 100644 index 0000000..23c8d70 --- /dev/null +++ b/test/phingistrano/GitTasks/GitPullTaskTest.xml @@ -0,0 +1,93 @@ + + + + + + + + This file should only be run via a testcase + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/phingistrano/GitTasks/GitPushTaskTest.php b/test/phingistrano/GitTasks/GitPushTaskTest.php new file mode 100644 index 0000000..5d21724 --- /dev/null +++ b/test/phingistrano/GitTasks/GitPushTaskTest.php @@ -0,0 +1,112 @@ +. + */ + +require_once 'phing/BuildFileTest.php'; +require_once '../classes/phing/tasks/ext/git/GitPushTask.php'; +require_once dirname(__FILE__) . '/GitTestsHelper.php'; + +/** + * @author Victor Farazdagi + * @version $Id: GitPushTaskTest.php 1179 2011-06-22 11:31:08Z mp $ + * @package phing.tasks.ext + */ +class GitPushTaskTest extends BuildFileTest { + + public function setUp() { + if (is_readable(PHING_TEST_TMP . '/git')) { + // make sure we purge previously created directory + // if left-overs from previous run are found + GitTestsHelper::rmdir(PHING_TEST_TMP . '/git'); + } + // set temp directory used by test cases + mkdir(PHING_TEST_TMP . '/git'); + + $this->configureProject(__DIR__ . '/GitPushTaskTest.xml'); + } + + public function tearDown() + { + GitTestsHelper::rmdir(PHING_TEST_TMP . '/git'); + } + + public function testAllParamsSet() + { + $repository = PHING_TEST_TMP . '/git'; + $this->executeTarget('allParamsSet'); + $this->assertInLogs('git-push: pushing to origin master:foobranch'); + $this->assertInLogs('git-push: complete'); + } + + public function testAllReposSet() + { + $repository = PHING_TEST_TMP . '/git'; + $this->executeTarget('allReposSet'); + $this->assertInLogs('git-push: push to all refs'); + $this->assertInLogs('git-push: complete'); + } + + public function testTagsSet() + { + $repository = PHING_TEST_TMP . '/git'; + $this->executeTarget('tagsSet'); + $this->assertInLogs('git-push: pushing to origin master:foobranch'); + $this->assertInLogs('git-push: complete'); + } + + public function testDeleteSet() + { + $repository = PHING_TEST_TMP . '/git'; + $this->executeTarget('deleteSet'); + $this->assertInLogs('git-push: pushing to origin master:newbranch'); + $this->assertInLogs('git-push: branch delete requested'); + $this->assertInLogs('git-push: complete'); + } + + public function testMirrorSet() + { + $repository = PHING_TEST_TMP . '/git'; + $this->executeTarget('mirrorSet'); + $this->assertInLogs('git-push: mirror all refs'); + $this->assertInLogs('git-push: complete'); + } + + public function testNoRepositorySpecified() + { + $this->expectBuildExceptionContaining('noRepository', + 'Repo dir is required', + '"repository" is required parameter'); + } + + public function testWrongRepo() + { + $this->expectBuildExceptionContaining('wrongRepo', + 'Repo dir is wrong', + 'You must specify readable directory as repository.'); + } + + public function testNoDestinationSpecified() + { + $this->expectBuildExceptionContaining('noDestination', + 'No source set', + 'At least one destination must be provided'); + } + +} diff --git a/test/phingistrano/GitTasks/GitPushTaskTest.xml b/test/phingistrano/GitTasks/GitPushTaskTest.xml new file mode 100644 index 0000000..aa84d57 --- /dev/null +++ b/test/phingistrano/GitTasks/GitPushTaskTest.xml @@ -0,0 +1,93 @@ + + + + + + + + This file should only be run via a testcase + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/phingistrano/GitTasks/GitTagTaskTest.php b/test/phingistrano/GitTasks/GitTagTaskTest.php new file mode 100644 index 0000000..3283504 --- /dev/null +++ b/test/phingistrano/GitTasks/GitTagTaskTest.php @@ -0,0 +1,187 @@ +. + */ + +require_once 'phing/BuildFileTest.php'; +require_once '../classes/phing/tasks/ext/git/GitTagTask.php'; +require_once dirname(__FILE__) . '/GitTestsHelper.php'; + +/** + * @author Victor Farazdagi + * @version $Id: GitTagTaskTest.php 1179 2011-06-22 11:31:08Z mp $ + * @package phing.tasks.ext + */ +class GitTagTaskTest extends BuildFileTest { + + public function setUp() { + if (is_readable(PHING_TEST_TMP . '/git')) { + // make sure we purge previously created directory + // if left-overs from previous run are found + GitTestsHelper::rmdir(PHING_TEST_TMP . '/git'); + } + // set temp directory used by test cases + mkdir(PHING_TEST_TMP . '/git'); + + $this->configureProject(__DIR__ . '/GitTagTaskTest.xml'); + } + + public function tearDown() + { + GitTestsHelper::rmdir(PHING_TEST_TMP . '/git'); + } + + public function testGitTagCreate() + { + $this->executeTarget('gitTagCreate'); + $this->assertInLogs('git-tag output: ver1.0'); + } + + public function testGitTagReplaceCreateDuplicate() + { + $this->executeTarget('gitTagReplaceCreateDuplicate'); + $this->assertInLogs('git-tag command: /usr/bin/git tag -f \'ver1.0\''); + $this->assertInLogs('git-tag command: /usr/bin/git tag -l'); + $this->assertInLogs('git-tag output: ver1.0'); + } + + public function testGitTagForceCreateDuplicate() + { + $this->executeTarget('gitTagForceCreateDuplicate'); + $this->assertInLogs('git-tag command: /usr/bin/git tag -f \'ver1.0\''); + $this->assertInLogs('git-tag command: /usr/bin/git tag -l'); + $this->assertInLogs('git-tag output: ver1.0'); + } + + public function testGitTagCreateDuplicate() + { + $this->expectBuildExceptionContaining('gitTagCreateDuplicate', + 'Tag already exists', + "fatal: tag 'ver1.0' already exists"); + } + + public function testTagCreateAnnotatedNoMessage() + { + $this->expectBuildExceptionContaining('gitTagCreateAnnotatedNoMessage', + 'Message not provided..', + '"message" or "file" required to make a tag'); + } + + public function testTagCreateAnnotated() + { + $this->executeTarget('gitTagCreateAnnotated'); + $this->assertInLogs('git-tag command: /usr/bin/git tag -a -m\'Version 1.0 tag\' \'ver1.0\''); + $this->assertInLogs('git-tag command: /usr/bin/git tag -l'); + $this->assertInLogs('git-tag output: ver1.0'); + } + + public function testTagCreateAnnotatedImplicit() + { + $this->executeTarget('gitTagCreateAnnotatedImplicit'); + $this->assertInLogs('git-tag command: /usr/bin/git tag -m\'Version 1.0 tag\' \'ver1.0\''); + $this->assertInLogs('git-tag command: /usr/bin/git tag -l'); + $this->assertInLogs('git-tag output: ver1.0'); + } + + public function testTagDelete() + { + $this->executeTarget('gitTagDelete'); + $this->assertInLogs('git-tag command: /usr/bin/git tag \'ver1.0\''); + $this->assertInLogs('git-tag command: /usr/bin/git tag \'ver2.0\''); + $this->assertInLogs('git-tag command: /usr/bin/git tag -d \'ver2.0\''); + $this->assertInLogs('git-tag output: Deleted tag \'ver2.0\''); + $this->assertInLogs('git-tag command: /usr/bin/git tag -l'); + $this->assertInLogs(' ver1.0'); + $this->assertNotInLogs("\n" . 'ver2.0'); + } + + public function testTagListByPattern() + { + $this->executeTarget('gitTagListByPattern'); + $this->assertInLogs('git-tag command: /usr/bin/git tag \'ver1.0\''); + $this->assertInLogs('git-tag command: /usr/bin/git tag \'ver2.0\''); + $this->assertInLogs('git-tag command: /usr/bin/git tag \'marked\''); + $this->assertInLogs('git-tag command: /usr/bin/git tag -l \'marked\''); + $this->assertInLogs('git-tag output: marked'); + } + + public function testTagOutputPropertySet() + { + $this->executeTarget('gitTagOutpuPropertySet'); + $this->assertInLogs('git-tag command: /usr/bin/git tag \'ver1.0\''); + $this->assertInLogs('git-tag command: /usr/bin/git tag \'ver2.0\''); + $this->assertInLogs('git-tag command: /usr/bin/git tag \'marked\''); + $this->assertInLogs('git-tag command: /usr/bin/git tag -l \'marked\''); + $this->assertInLogs('git-tag output: marked'); + $this->assertPropertyEquals('gitLogOutput', 'marked' . "\n"); + } + + public function testTagWithCommitSet() + { + $this->executeTarget('gitTagWithCommitSet'); + $this->assertInLogs('git-tag command: /usr/bin/git tag \'ver1.0\' \'c573116f395d36497a1ac1dba565ecd3d3944277\''); + $this->assertInLogs('c573116f395d36497a1ac1dba565ecd3d3944277'); + $this->assertInLogs('b8cddb3fa5f408560d0d00d6c8721fe333895888'); + $this->assertInLogs('6dbaf4508e75dcd426b5b974a67c462c70d46e1f'); + $this->assertNotInLogs('1b767b75bb5329f4e53345c516c0a9f4ed32d330'); + $this->assertNotInLogs('ee07085160003ffd1100867deb6059bae0c45455'); + } + + public function testTagWithObjectSet() + { + $this->executeTarget('gitTagWithObjectSet'); + $this->assertInLogs('git-tag command: /usr/bin/git tag \'ver1.0\' \'c573116f395d36497a1ac1dba565ecd3d3944277\''); + $this->assertInLogs('c573116f395d36497a1ac1dba565ecd3d3944277'); + $this->assertInLogs('b8cddb3fa5f408560d0d00d6c8721fe333895888'); + $this->assertInLogs('6dbaf4508e75dcd426b5b974a67c462c70d46e1f'); + $this->assertNotInLogs('1b767b75bb5329f4e53345c516c0a9f4ed32d330'); + $this->assertNotInLogs('ee07085160003ffd1100867deb6059bae0c45455'); + } + + public function testTagCreateSignedDefaultKey() + { + $this->markTestSkipped('Involves configured GPG key'); + $this->executeTarget('gitTagCreateSignedDefaultKey'); + $this->assertInLogs('git-tag command: /usr/bin/git tag -m\'Version 1.0 tag\' \'ver1.0\''); + $this->assertInLogs('git-tag command: /usr/bin/git tag -l'); + $this->assertInLogs('git-tag output: ver1.0'); + } + + public function testTagFileSet() + { + $msgFile = PHING_TEST_TMP . '/msg.txt'; + $fp = fopen($msgFile, 'w'); + fwrite($fp , 'test tag message'); + fclose($fp); + + $this->executeTarget('gitTagFileSet'); + $this->assertInLogs("/usr/bin/git tag -F'{$msgFile}' 'ver1.0'"); + + unlink($msgFile); + } + + public function testNoRepositorySpecified() + { + $this->expectBuildExceptionContaining('noRepository', + 'Repo dir is required', + '"repository" is required parameter'); + } + + +} diff --git a/test/phingistrano/GitTasks/GitTagTaskTest.xml b/test/phingistrano/GitTasks/GitTagTaskTest.xml new file mode 100644 index 0000000..c923bfc --- /dev/null +++ b/test/phingistrano/GitTasks/GitTagTaskTest.xml @@ -0,0 +1,191 @@ + + + + + + + + This file should only be run via a testcase + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/phingistrano/GitTasks/GitTestsHelper.php b/test/phingistrano/GitTasks/GitTestsHelper.php new file mode 100644 index 0000000..0156c4d --- /dev/null +++ b/test/phingistrano/GitTasks/GitTestsHelper.php @@ -0,0 +1,56 @@ + 5259486) { + $returndate = round($timediff / 2629744) . " months ago"; + } else { + $returndate = round($timediff / 604900) . " weeks ago"; + } + + return $returndate; + } + +} diff --git a/test/phingistrano/ScpTask/.svn/entries b/test/phingistrano/ScpTask/.svn/entries new file mode 100644 index 0000000..376c2c2 --- /dev/null +++ b/test/phingistrano/ScpTask/.svn/entries @@ -0,0 +1,49 @@ +10 + +dir +0 +http://svn.phing.info/branches/2.5/test/classes/phing/tasks/ext/ScpTask +http://svn.phing.info +add + + + + + + + + + + + + + + + + + + + +34c17c5f-800b-0410-92ba-a69295604261 + +ScpTaskTest.xml +file + + + +add + +ScpTestHelper.php +file + + + +add + +ScpTaskTest.php +file + + + +add + diff --git a/test/phingistrano/ScpTask/ScpTaskTest.php b/test/phingistrano/ScpTask/ScpTaskTest.php new file mode 100644 index 0000000..ba72f00 --- /dev/null +++ b/test/phingistrano/ScpTask/ScpTaskTest.php @@ -0,0 +1,266 @@ +. + */ + +require_once 'phing/BuildFileTest.php'; +require_once '../classes/phing/tasks/ext/ScpTask.php'; +require_once dirname(__FILE__) . '/ScpTestHelper.php'; + +/** + * @author Jesse Greathouse + * @package phing.tasks.ext + */ +class ScpTaskTest extends BuildFileTest { + + protected $mock; + + protected $privatekey = '-----BEGIN RSA PRIVATE KEY----- +Proc-Type: 4,ENCRYPTED +DEK-Info: AES-128-CBC,47E7F9DC303BB5469E67DB116B079C38 + +NqjHYcSKtUCNP0TiAC7+1O6Xd+L457ks0RGawZBFkZa4x6gUHdSQ8Gt9rErfLhU2 +wVY9/X1gPafVOlefha4pljTnNuPfuccn4Dl8QghCjMr7rlaqk+QV3sUK9OvxpLCC +FQ5n+Cqqz5CfH9XgCHIOI2dz2e0niI2TyeTObKOsm0Lu7A0Yt2N+aGee/Uj5HQb5 +X/JwT2GJ2F4vJH7MlFgexdQaJbsavRhn6Ln5C4S4bxnCy2MfZZ1jprgrFYJtiJ+h +cmLsFYbtqMue/8BOh5Cjx+McRsHZwe6WaUmTQ1kWkqDXzREFXse4IggpUZtD4ejc +3Qx9ZMda/gjS3yWwQEoAviEhtMJa1mzTpX6MdSD9YHcxjTSmBhRL/xrjvV/4eJEm +4mVhCaQgWZmq4Njir/vIELAGb3FF8rZUKziD5n4ypU1/A3KmgS2NQPK2HPkelehc +TJOW5oDw85SEzs64Eq3NKXEWfWcLpSlLdx7BRUAP211/YLVbgCxccd7f3RvgAzht +EfJfVTtv1plrMxTA3J2N02brw7mp9F5y1sZf0snWjqv4SCi4OkNIHfDgHT82zJRJ +acHcYskdWfruOwMlMyls2cyjQm8GqalqUehmch54B9YdI3vIrL1jNts0NH7IJOuV +qGTAA+P4/DC6Gk+1Gk9ZH5hDqSKvz/Ja/RjhJJZC93QRKaJvy+oqKicYnPXa5rve +9UiJPvv6ZFeoqugf6AyKdAIlXSK9sjOormpSYBukUlBf/f+QDgt9E22Fu2xAOXBK +ZtbMCFoKRpRZEFlWyggdsWym+61sofBJeRlk9vp/geBKEdOsL4YkPYWIZxqkPF8V +Z0QqEPEeuiEtsFZ/CcueEGUmUwQ3UCN9vliGvL6YYmq8UubS+zzCXEJ4FjCT10S8 +NXhBzy+jOLIYNzX/mpjq4nGXnKlDAoxuKq6f8MlsT/am98xuCzTyYl7uDzHX2CRn +/EY5MiIByRBr0l+HWEI/JdzTTPxLzxnm+QaQcaYotWw4Wjt8KTDa1x9MfQXEffuN +74XX+lyhzGCgU1qzFjdFEYAxHriMkaH6BxRnNLtfNQmAaVmIhDk1rZVFuRHjV6OX +ex5VR1srbRKk+/VWwBxzsQaxz+aCVhqTcssdHhjc6xTZo/UZIrrtZXf4PWB4/FWM +qW36FzdRpRUJ5Yxs3/RtN1Wv2Wk63W09T6XRaIYNAb1J4G1HinFN/4UQF+bpT4W+ +aG/jmBcd1MQt+v2+x+zIZBLx0swQLaENjS6/LD4Tv7u/nHTM0s2z6kpOJ6jqAV+5 +uQw8EuRaJG4MKlbWx5iBo3da10q2j+ObEa6K89osVlZ+hlGjVeIKZ8m4j4u1mjE5 +JwEaFEOTdPcyHC9M9kO94/d9GR5a3meAp+DeRkw61lzG4hYzBPSeKxXCzjWBiOcE +3nz3cs/3u4iZfuUgLYqsKegwDRXctbiIiPLxftVhxt2I5rm5SJmXRmR8SHas79eN +cF+PEMTNtr/mamZ7j1z4mllDqJ4U1IF6xVJqmfa+ekpro6ajBCqRniKzqIRwspXA +yuWUf77/0QTuT+oW+sj6VZK7XY2N69McPZcgFVDLDSy6rDRd1ketNA/D8UqwKFa4 +-----END RSA PRIVATE KEY-----'; + + protected $publickey = 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC9j0bxEAEBSEuqwSUhlUXVT14a7CDiqqP2xC2UGYq910ZSr6aydaSJDs2PTLCvTR5v4pffCbtptOcDkKtWsQKCQvAXHjNlXneKqzUY8SiV9kN8kcaWT9H0fG+X4EBIcyRC3iRcdNJU1mMEc4pKCYc2JqE+w9OsYjo0jK58h0lb/bMvcmN76/2U6nRPMG5wYxVwuXAfpCUX2MrmjmZtUjunYT/8Y7fLZmAueauSJYGU8gNb1pq02Ov8bw+7SxmnRnr0Re15CQaNO4SClQol8SJTM2MVDqSojSsd8oyINX+4iyyiW0ljBPtkBEyin1SFhXp8RupT13eugIG+fGekaoPP phing@jessegreathouse.us'; + + + + public function setUp() { + $this->configureProject(__DIR__ . "/ScpTaskTest.xml"); + $this->mock = $this->getMockForAbstractClass('ScpTask'); + + if (is_readable(PHING_TEST_TMP . '/scp')) { + // make sure we purge previously created directory + // if left-overs from previous run are found + ScpTestHelper::rmdir(PHING_TEST_TMP . '/scp'); + } + // set temp directory used by test cases + mkdir(PHING_TEST_TMP . '/scp'); + + $privatekeyfile = PHING_TEST_TMP . '/scp/id_rsa'; + $publickeyfile = PHING_TEST_TMP . '/scp/id_rsa.pub'; + + //set up pub and private key files + $fv = fopen($privatekeyfile, 'w+'); + fwrite($fv, $this->privatekey); + $fb = fopen($publickeyfile, 'w+'); + fwrite($fb, $this->publickey); + + } + + public function tearDown() + { + ScpTestHelper::rmdir(PHING_TEST_TMP . '/scp'); + } + + public function testInitialization() + { + $this->assertInstanceOf('ScpTask', $this->mock); + } + + public function testMutators() + { + // host + $host = $this->mock->getHost(); + $this->mock->setHost('my-new-host'); + $this->assertEquals('my-new-host', $this->mock->getHost()); + $this->mock->setHost($host); + + // port + $port = $this->mock->getPort(); + $this->mock->setPort('my-new-port'); + $this->assertEquals('my-new-port', $this->mock->getPort()); + $this->mock->setPort($port); + + // username + $username = $this->mock->getUsername(); + $this->mock->setUsername('my-new-username'); + $this->assertEquals('my-new-username', $this->mock->getUsername()); + $this->mock->setUsername($username); + + // password + $password = $this->mock->getPassword(); + $this->mock->setPassword('my-new-password'); + $this->assertEquals('my-new-password', $this->mock->getPassword()); + $this->mock->setPassword($password); + + // pubkeyfile + $pubkeyfile = $this->mock->getPubkeyfile(); + $this->mock->setPubkeyfile('my-new-pubkeyfile'); + $this->assertEquals('my-new-pubkeyfile', $this->mock->getPubkeyfile()); + $this->mock->setPubkeyfile($pubkeyfile); + + // privkeyfile + $privkeyfile = $this->mock->getPrivkeyfile(); + $this->mock->setPrivkeyfile('my-new-privkeyfile'); + $this->assertEquals('my-new-privkeyfile', $this->mock->getPrivkeyfile()); + $this->mock->setPrivkeyfile($privkeyfile); + + // privkeyfilepassphrase + $privkeyfilepassphrase = $this->mock->getPrivkeyfilepassphrase(); + $this->mock->setPrivkeyfilepassphrase('my-new-privkeyfilepassphrase'); + $this->assertEquals('my-new-privkeyfilepassphrase', $this->mock->getPrivkeyfilepassphrase()); + $this->mock->setPrivkeyfilepassphrase($privkeyfilepassphrase); + + // sshlib + $sshlib = $this->mock->getSshlib(); + $this->mock->setSshlib('my-new-sshlib'); + $this->assertEquals('my-new-sshlib', $this->mock->getSshlib()); + $this->mock->setSshlib($sshlib); + + // crypt + $crypt = $this->mock->getCrypt(); + $this->mock->setCrypt('my-new-crypt'); + $this->assertEquals('my-new-crypt', $this->mock->getCrypt()); + $this->mock->setCrypt($crypt); + + // autocreate + $autocreate = $this->mock->getAutocreate(); + $this->mock->setAutocreate(true); + $this->assertEquals(true, $this->mock->getAutocreate()); + $this->mock->setAutocreate($autocreate); + + // todir + $todir = $this->mock->getTodir(); + $this->mock->setTodir('my-new-todir'); + $this->assertEquals('my-new-todir', $this->mock->getTodir()); + $this->mock->setTodir($todir); + + // file + $file = $this->mock->getFile(); + $this->mock->setFile('my-new-file'); + $this->assertEquals('my-new-file', $this->mock->getFile()); + $this->mock->setFile($file); + + // fetch + $fetch = $this->mock->getFetch(); + $this->mock->setFetch(true); + $this->assertEquals(true, $this->mock->getFetch()); + $this->mock->setFetch($fetch); + } + + public function testDefaultSshlib() + { + $uploadFile = PHING_TEST_TMP . '/scp/testUpload'; + if (file_exists($uploadFile)) { + unlink($uploadFile); + } + $fh = fopen($uploadFile, 'w+'); + while (($size = filesize($uploadFile)) < 1024) { + fwrite($fh, rand(0,9)); + clearstatcache(); + } + $this->executeTarget('defaultSshlib'); + $this->assertInLogs('Copied 1 file'); + } + + public function testAuthNetssh() + { + $resultFile = PHING_TEST_TMP . '/scp/scpFetch'; + if (file_exists($resultFile)) { + unlink($resultFile); + } + $this->executeTarget('authNetssh'); + $this->assertEquals('phing', trim(file_get_contents($resultFile))); + } + + public function testAuthSsh2() + { + $resultFile = PHING_TEST_TMP . '/scp/scpFetch'; + if (file_exists($resultFile)) { + unlink($resultFile); + } + $this->executeTarget('authSsh2'); + $this->assertEquals('phing', trim(file_get_contents($resultFile))); + } + + public function testAllParamsSet() + { + $resultFile = PHING_TEST_TMP . '/scp/scpFetch'; + if (file_exists($resultFile)) { + unlink($resultFile); + } + $this->executeTarget('allParamsSet'); + $this->assertEquals('phing', trim(file_get_contents($resultFile))); + } + + public function testUpload() + { + $uploadFile = PHING_TEST_TMP . '/scp/testUpload'; + if (file_exists($uploadFile)) { + unlink($uploadFile); + } + $fh = fopen($uploadFile, 'w+'); + while (($size = filesize($uploadFile)) < 49919677) { + fwrite($fh, rand(0,9)); + clearstatcache(); + } + $this->executeTarget('testUpload'); + $this->assertInLogs('Copied 1 file'); + } + + public function testFilesetUpload() + { + $uploadFile1 = PHING_TEST_TMP . '/scp/testFilesetUpload1.fs'; + $uploadFile2 = PHING_TEST_TMP . '/scp/testFilesetUpload2.fs'; + if (file_exists($uploadFile1)) { + unlink($uploadFile1); + } + if (file_exists($uploadFile2)) { + unlink($uploadFile2); + } + $fh1 = fopen($uploadFile1, 'w+'); + while (($size = filesize($uploadFile1)) < 1024) { + fwrite($fh1, rand(0,9)); + clearstatcache(); + } + $fh2 = fopen($uploadFile2, 'w+'); + while (($size = filesize($uploadFile2)) < 1024) { + fwrite($fh2, rand(0,9)); + clearstatcache(); + } + $this->executeTarget('testFilesetUpload'); + $this->assertInLogs('Copied 2 file'); + } + +} diff --git a/test/phingistrano/ScpTask/ScpTaskTest.xml b/test/phingistrano/ScpTask/ScpTaskTest.xml new file mode 100644 index 0000000..3b288f3 --- /dev/null +++ b/test/phingistrano/ScpTask/ScpTaskTest.xml @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + + + + + + This file should only be run via a testcase + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/phingistrano/ScpTask/ScpTestHelper.php b/test/phingistrano/ScpTask/ScpTestHelper.php new file mode 100644 index 0000000..4bbd84e --- /dev/null +++ b/test/phingistrano/ScpTask/ScpTestHelper.php @@ -0,0 +1,15 @@ +. + */ + +require_once 'phing/BuildFileTest.php'; +require_once '../classes/phing/tasks/ext/SshTask.php'; +require_once dirname(__FILE__) . '/SshTestHelper.php'; + +/** + * @author Jesse Greathouse + * @package phing.tasks.ext + */ +class SshTaskTest extends BuildFileTest { + + protected $mock; + + protected $privatekey = '-----BEGIN RSA PRIVATE KEY----- +Proc-Type: 4,ENCRYPTED +DEK-Info: AES-128-CBC,47E7F9DC303BB5469E67DB116B079C38 + +NqjHYcSKtUCNP0TiAC7+1O6Xd+L457ks0RGawZBFkZa4x6gUHdSQ8Gt9rErfLhU2 +wVY9/X1gPafVOlefha4pljTnNuPfuccn4Dl8QghCjMr7rlaqk+QV3sUK9OvxpLCC +FQ5n+Cqqz5CfH9XgCHIOI2dz2e0niI2TyeTObKOsm0Lu7A0Yt2N+aGee/Uj5HQb5 +X/JwT2GJ2F4vJH7MlFgexdQaJbsavRhn6Ln5C4S4bxnCy2MfZZ1jprgrFYJtiJ+h +cmLsFYbtqMue/8BOh5Cjx+McRsHZwe6WaUmTQ1kWkqDXzREFXse4IggpUZtD4ejc +3Qx9ZMda/gjS3yWwQEoAviEhtMJa1mzTpX6MdSD9YHcxjTSmBhRL/xrjvV/4eJEm +4mVhCaQgWZmq4Njir/vIELAGb3FF8rZUKziD5n4ypU1/A3KmgS2NQPK2HPkelehc +TJOW5oDw85SEzs64Eq3NKXEWfWcLpSlLdx7BRUAP211/YLVbgCxccd7f3RvgAzht +EfJfVTtv1plrMxTA3J2N02brw7mp9F5y1sZf0snWjqv4SCi4OkNIHfDgHT82zJRJ +acHcYskdWfruOwMlMyls2cyjQm8GqalqUehmch54B9YdI3vIrL1jNts0NH7IJOuV +qGTAA+P4/DC6Gk+1Gk9ZH5hDqSKvz/Ja/RjhJJZC93QRKaJvy+oqKicYnPXa5rve +9UiJPvv6ZFeoqugf6AyKdAIlXSK9sjOormpSYBukUlBf/f+QDgt9E22Fu2xAOXBK +ZtbMCFoKRpRZEFlWyggdsWym+61sofBJeRlk9vp/geBKEdOsL4YkPYWIZxqkPF8V +Z0QqEPEeuiEtsFZ/CcueEGUmUwQ3UCN9vliGvL6YYmq8UubS+zzCXEJ4FjCT10S8 +NXhBzy+jOLIYNzX/mpjq4nGXnKlDAoxuKq6f8MlsT/am98xuCzTyYl7uDzHX2CRn +/EY5MiIByRBr0l+HWEI/JdzTTPxLzxnm+QaQcaYotWw4Wjt8KTDa1x9MfQXEffuN +74XX+lyhzGCgU1qzFjdFEYAxHriMkaH6BxRnNLtfNQmAaVmIhDk1rZVFuRHjV6OX +ex5VR1srbRKk+/VWwBxzsQaxz+aCVhqTcssdHhjc6xTZo/UZIrrtZXf4PWB4/FWM +qW36FzdRpRUJ5Yxs3/RtN1Wv2Wk63W09T6XRaIYNAb1J4G1HinFN/4UQF+bpT4W+ +aG/jmBcd1MQt+v2+x+zIZBLx0swQLaENjS6/LD4Tv7u/nHTM0s2z6kpOJ6jqAV+5 +uQw8EuRaJG4MKlbWx5iBo3da10q2j+ObEa6K89osVlZ+hlGjVeIKZ8m4j4u1mjE5 +JwEaFEOTdPcyHC9M9kO94/d9GR5a3meAp+DeRkw61lzG4hYzBPSeKxXCzjWBiOcE +3nz3cs/3u4iZfuUgLYqsKegwDRXctbiIiPLxftVhxt2I5rm5SJmXRmR8SHas79eN +cF+PEMTNtr/mamZ7j1z4mllDqJ4U1IF6xVJqmfa+ekpro6ajBCqRniKzqIRwspXA +yuWUf77/0QTuT+oW+sj6VZK7XY2N69McPZcgFVDLDSy6rDRd1ketNA/D8UqwKFa4 +-----END RSA PRIVATE KEY-----'; + + protected $publickey = 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC9j0bxEAEBSEuqwSUhlUXVT14a7CDiqqP2xC2UGYq910ZSr6aydaSJDs2PTLCvTR5v4pffCbtptOcDkKtWsQKCQvAXHjNlXneKqzUY8SiV9kN8kcaWT9H0fG+X4EBIcyRC3iRcdNJU1mMEc4pKCYc2JqE+w9OsYjo0jK58h0lb/bMvcmN76/2U6nRPMG5wYxVwuXAfpCUX2MrmjmZtUjunYT/8Y7fLZmAueauSJYGU8gNb1pq02Ov8bw+7SxmnRnr0Re15CQaNO4SClQol8SJTM2MVDqSojSsd8oyINX+4iyyiW0ljBPtkBEyin1SFhXp8RupT13eugIG+fGekaoPP phing@jessegreathouse.us'; + + public function setUp() { + $this->configureProject(__DIR__ . "/SshTaskTest.xml"); + $this->mock = $this->getMockForAbstractClass('SshTask'); + + if (is_readable(PHING_TEST_TMP . '/ssh')) { + SshTestHelper::rmdir(PHING_TEST_TMP . '/ssh'); + } + mkdir(PHING_TEST_TMP . '/ssh'); + + $privatekeyfile = PHING_TEST_TMP . '/ssh/id_rsa'; + $publickeyfile = PHING_TEST_TMP . '/ssh/id_rsa.pub'; + + //set up pub and private key files + $fv = fopen($privatekeyfile, 'w+'); + fwrite($fv, $this->privatekey); + $fb = fopen($publickeyfile, 'w+'); + fwrite($fb, $this->publickey); + } + + public function tearDown() + { + SshTestHelper::rmdir(PHING_TEST_TMP . '/ssh'); + } + + public function testInitialization() + { + $this->assertInstanceOf('SshTask', $this->mock); + } + + public function testMutators() + { + // host + $host = $this->mock->getHost(); + $this->mock->setHost('my-new-host'); + $this->assertEquals('my-new-host', $this->mock->getHost()); + $this->mock->setHost($host); + + // port + $port = $this->mock->getPort(); + $this->mock->setPort('my-new-port'); + $this->assertEquals('my-new-port', $this->mock->getPort()); + $this->mock->setPort($port); + + // username + $username = $this->mock->getUsername(); + $this->mock->setUsername('my-new-username'); + $this->assertEquals('my-new-username', $this->mock->getUsername()); + $this->mock->setUsername($username); + + // password + $password = $this->mock->getPassword(); + $this->mock->setPassword('my-new-password'); + $this->assertEquals('my-new-password', $this->mock->getPassword()); + $this->mock->setPassword($password); + + // pubkeyfile + $pubkeyfile = $this->mock->getPubkeyfile(); + $this->mock->setPubkeyfile('my-new-pubkeyfile'); + $this->assertEquals('my-new-pubkeyfile', $this->mock->getPubkeyfile()); + $this->mock->setPubkeyfile($pubkeyfile); + + // privkeyfile + $privkeyfile = $this->mock->getPrivkeyfile(); + $this->mock->setPrivkeyfile('my-new-privkeyfile'); + $this->assertEquals('my-new-privkeyfile', $this->mock->getPrivkeyfile()); + $this->mock->setPrivkeyfile($privkeyfile); + + // privkeyfilepassphrase + $privkeyfilepassphrase = $this->mock->getPrivkeyfilepassphrase(); + $this->mock->setPrivkeyfilepassphrase('my-new-privkeyfilepassphrase'); + $this->assertEquals('my-new-privkeyfilepassphrase', $this->mock->getPrivkeyfilepassphrase()); + $this->mock->setPrivkeyfilepassphrase($privkeyfilepassphrase); + + // sshlib + $sshlib = $this->mock->getSshlib(); + $this->mock->setSshlib('my-new-sshlib'); + $this->assertEquals('my-new-sshlib', $this->mock->getSshlib()); + $this->mock->setSshlib($sshlib); + + // crypt + $crypt = $this->mock->getCrypt(); + $this->mock->setCrypt('my-new-crypt'); + $this->assertEquals('my-new-crypt', $this->mock->getCrypt()); + $this->mock->setCrypt($crypt); + + // command + $command = $this->mock->getCommand(); + $this->mock->setCommand('my-new-command'); + $this->assertEquals('my-new-command', $this->mock->getCommand()); + $this->mock->setCommand($command); + } + + public function testDefaultSshlib() + { + $this->executeTarget('defaultSshlib'); + $this->assertInLogs('Result: phing'); + } + + public function testAuthSsh2() + { + $this->executeTarget('authSsh2'); + $this->assertInLogs('Result: phing'); + } + + public function testAuthNetssh() + { + $this->executeTarget('authNetssh'); + $this->assertInLogs('Result: phing'); + } + + public function testAllParamsSet() + { + $this->executeTarget('allParamsSet'); + $this->assertInLogs('Result: phing'); + } + +} diff --git a/test/phingistrano/SshTask/SshTaskTest.xml b/test/phingistrano/SshTask/SshTaskTest.xml new file mode 100644 index 0000000..ec5a738 --- /dev/null +++ b/test/phingistrano/SshTask/SshTaskTest.xml @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + This file should only be run via a testcase + + + + + + + + + + + + + + + + + + + diff --git a/test/phingistrano/SshTask/SshTestHelper.php b/test/phingistrano/SshTask/SshTestHelper.php new file mode 100644 index 0000000..90d67a5 --- /dev/null +++ b/test/phingistrano/SshTask/SshTestHelper.php @@ -0,0 +1,15 @@ +