Commits

Anonymous committed 6a693b0

* Major refactoring of unit and functional tests.

Comments (0)

Files changed (11)

Trunk/Tests/Functional/test_Clone.php

 $hg = new VersionControl_Hg();
 
 /* Rely on Init.php to do work? */
+
+/*r_rmdir($new_repository);
 $cloned_repository_object_1 =
     $hg->clone($old_repository)->to($new_repository)->run();
 
 var_dump($cloned_repository_object_1);
+*/
+
+//r_rmdir($new_repository);
+$cloned_repository_object_2 =
+    $hg->clone($old_repository)->revision('e5e678260dfe')->to($new_repository)->run();
+
+var_dump($cloned_repository_object_2);
+//@TODO check to ensure its at rev 4
+die;
+
+
+
+
+
+r_rmdir($new_repository);
+$cloned_repository_object_3 =
+    $hg->clone($old_repository)->revision('e5e678260dfe')->to($new_repository)->run();
+
+var_dump($cloned_repository_object_3);
+
+
+function r_rmdir($dir) {
+   if (is_dir($dir)) {
+     $objects = scandir($dir);
+     foreach ($objects as $object) {
+       if ($object != "." && $object != "..") {
+         if (filetype($dir."/".$object) == "dir") r_rmdir($dir."/".$object); else unlink($dir."/".$object);
+       }
+     }
+     reset($objects);
+     rmdir($dir);
+   }
+ }
+
 die('end of test');
 
 
 
-
-$cloned_repository_object_2 =
-    $hg->clone($old_repository)->revision(3)->to($new_repository)->run();
-
-$cloned_repository_object_3 =
-    $hg->clone($old_repository)->revision('cdf5643ade')->to($new_repository)->run();
-
 //default is to create a working copy as well; only('repository') is the same
 //as hg update null and kills the working copy.
 // -U option

Trunk/Tests/Functional/test_HgConstructor_InvalidRepository.php

 <?php
 
+include_once '../../VersionControl/Hg.php';
+
 /* construct with an invalid repository */
 echo "construct with an invalid repository\r\n";
 try {
     $repo = realpath("C:\Windows\Temp");
     $hg = new VersionControl_Hg($repo);
-    var_dump($hg->getRepository());
+    var_dump($hg);
 }
 catch (Exception $e) {
-    var_dump($e->getMessage());
+    var_dump(get_class($e), $e->getMessage());
 }

Trunk/Tests/Functional/test_HgConstructor_NonexistantPath.php

 <?php
 
+include_once '../../VersionControl/Hg.php';
+
 /* construct with an non-existing path */
 echo "construct with an non-existing path\r\n";
 try {
     $hg = new VersionControl_Hg("C:\Temp");
-    var_dump($hg->getRepository());
+    var_dump($hg);
 }
 catch (Exception $e) {
     var_dump($e->getMessage());

Trunk/Tests/Functional/test_HgConstructor_ValidRepository.php

 <?php
+//xdebug_start_trace('./trace.log');
+
+include_once '../../VersionControl/Hg.php';
 
 /* construct with a valid repository */
 echo "construct with a valid repository\r\n";
-$repo = realpath('V:\Development\_Webroot\Trunk\Tests\Fixtures\Test_Repository');
+$repo = realpath('H:\Development\_Webroot\Trunk\Tests\Fixtures\Test_Repository');
 $hg = new VersionControl_Hg($repo);
-var_dump($hg->getRepository());
+
+echo $hg;
+
+//var_dump($hg, $hg->repository, $hg->repository->getPath(), $hg->getRepository(), $hg->getRepository()->getPath());
+
+//xdebug_stop_trace();

Trunk/Tests/Functional/test_HgVersion.php

 
 include_once '../../VersionControl/Hg.php';
 
-$hg = new VersionControl_Hg();
+$hg = new VersionControl_Hg('H:\Development\_Webroot\Trunk\Tests\Fixtures\Test_Repository');
 
 /* explicit accessor */
-var_dump($hg->getVersion());
+//var_dump($hg->getVersion());
 
-/* verbose for command related to Hg executable */
-var_dump($hg->version(array('verbose' => null)));
+var_dump($hg->version()->run(array('verbose' => null)));
+var_dump($hg->version()->run('verbose'));
 
-/* use quiet option for command related to Hg executable */
-var_dump($hg->version(array('quiet' => null)));
+/* getting the property */
+//echo $hg->version;
 
 /* misspelled option */
-var_dump($hg->version(array('quite' => null)));
+var_dump($hg->version()->run(array('quite' => null)));

Trunk/Tests/Functional/test_Log.php

 
 echo "EXCLUDING PHP FILES\r\n";
 var_dump($hg->log()->excluding('**.php')->run());
+/* Displays nothing; excluding takes precedence. Remove excluding() to get only index.php */
+var_dump($hg->log()->files(array('index.php'))->excluding('**.php')->run());
 
-die;
-
-/* without 'all', result is empty EVEN though there are items which should display  */
-var_dump($hg->status()->files(array('index.php'))->run());
-
-/* In this case, we left out 'all' which correctly excludes index.php */
-var_dump($hg->status()->excluding('**.php')->run());
-
-/* this displays nothing! Seems to be by design */
-var_dump($hg->status()->including('**.php')->run());
-
-/* Displays index.php */
-var_dump($hg->status()->all()->including('**.php')->run());
-
-/* Displays index.php */
-var_dump($hg->status('all')->files(array('index.php'))->excluding('**.php')->run());
-
-/* Returns nothing! */
-var_dump($hg->status()->files(array('index.php'))->excluding('**.php')->run());
-
-/*
- * In a case like the following:
- * <code>$hg->status('all')->files(array('index.php'))->excluding('**.php')->run();</code>
- * The apparently conflicting options do not cause an exception. The behavior is that
- * apparently, files, takes complete precedence over excluding. However, all such
- * combinations have not been fully tested yet, so you may not get the results
- * you expect by using options which conceptually conflict with each other.
- */
-
-
-/*
- * Future concepts, but 'asXml' violates my no camel case API design principle
-var_dump($hg->status('all')->asXml()->run('verbose'));
-var_dump($hg->status('all')->toXml()->run('verbose'));
-var_dump($hg->status('all')->xml()->run('verbose'));
-
-'at' could be confused with a time/date
-var_dump($hg->status('all')->at('22')->run('verbose'));
-*/
+echo "INCLUDING PHP FILES\r\n";
+//@TODO Add another PHP file to the repo to test for sure
+var_dump($hg->log()->including('**.php')->run());

Trunk/Tests/Functional/test_Pull.php

+<?php
+
+include_once '../../VersionControl/Hg.php';
+
+$cloned_repository = 'H:\Development\_Webroot\Trunk\Tests\Fixtures\Clone_of_Repository';
+$from_repository = 'H:\Development\_Webroot\Trunk\Tests\Fixtures\Test_Repository' ;
+
+$hg = new VersionControl_Hg($cloned_repository);
+
+$pulled_changesets = $hg->pull()->from($from_repository)->run();
+
+var_dump($pulled_changesets);
+die('end of test');

Trunk/Tests/Functional/test_RepoArchive.php

-<?php
-
-include_once '../VersionControl/Hg.php';
-
-//var_dump($_SERVER); die;
-
-$repo = realpath('Fixtures/Test_Repository');
-$hg = new VersionControl_Hg($repo);
-echo "getting the repository path\r\n";
-var_dump($hg->getRepository());
-echo "\r\n";
-$hg->archive('tip', realpath('../'), 'gzip');
-
-/*
-$hg = new VersionControl_Hg();
-$hg->setRepository('Fixtures/Test_Repository');
-$hg->archive('tip')->to('/home/myself/releases/')->with('gzip');
-
-$hg = new VersionControl_Hg();
-$hg->setRepository('Fixtures/Test_Repository')->archive('tip')->to('/home/myself/releases/')->with('gzip');
-
-
-$hg = new VersionControl_Hg();
-$hg->use('Fixtures/Test_Repository')->archive('tip')->to('/home/myself/releases/')->with('gzip');
-*/

Trunk/Tests/Functional/test_RepoSet.php

+<?php
+
+include_once '../../VersionControl/Hg.php';
+
+/* 'Normal' way*/
+$repo = realpath('../Fixtures/Test_Repository');
+$hg = new VersionControl_Hg($repo);
+var_dump($hg->getRepository());
+
+$hg = null;
+unset($hg);
+
+/* Should fail */
+$repo = realpath('../Fixtures/Test_Repository');
+$hg = new VersionControl_Hg($repo);
+var_dump($hg->getRepository());
+$hg->setRepository(realpath('../Fixtures/Test_Repository2'));
+var_dump($hg->getRepository());
+
+$hg = null;
+unset($hg);
+
+/* Should succeed! */
+$repo = realpath('../Fixtures/Test_Repository');
+$hg = new VersionControl_Hg($repo);
+var_dump($hg->getRepository());
+/* secret trick! */
+VersionControl_Hg_Container_Repository::reset();
+$hg->setRepository(realpath('../Fixtures/Test_Repository2'));
+var_dump($hg->getRepository());
+
+$hg = null;
+unset($hg);
+
+/* Excplicitly call setPath() */
+$hg = new VersionControl_Hg();
+$hg->repository->setPath(realpath('../Fixtures/Test_Repository'));
+var_dump($hg->getRepository());
+
+$hg = null;
+unset($hg);
+
+/* set the repository as a property */
+$hg = new VersionControl_Hg();
+$hg->repository = realpath('../Fixtures/Test_Repository');
+var_dump($hg->getRepository());
+//var_dump($hg->repository->path);
+var_dump($hg->repository);
+
+$hg = null;
+unset($hg);

Trunk/Tests/Unit/HgTest.php

          */
         protected function setUp() {}
 
-        public function testConstructorWithNullSignature()
-        {
-            $this->setExpectedException('VersionControl_Hg_Exception');
-            $hg = new VersionControl_Hg();
-        }
 
-        public function testConstructorWithValidRepository()
-        {
-            $hg = new VersionControl_Hg($this->test_repository);
-            $expected = $this->test_repository;
-            $actual = $hg->getRepository()->getPath();
-            $this->assertEquals($expected, $actual);
-        }
-
-        public function testConstructorWithAnInvalidRepository()
-        {
-
-            $this->setExpectedException('VersionControl_Hg_Container_Repository_Exception');
-            $hg = new VersionControl_Hg($this->invalid_repo);
-        }
-
-        public function testConstructorWithNonExistantPath()
-        {
-            $this->setExpectedException('VersionControl_Hg_Container_Repository_Exception');
-            $hg = new VersionControl_Hg($this->nonexistant_path);
-        }
 
         /**
          * Tears down the fixture, for example, closes a network connection.
          * This method is called after a test is executed.
          */
-        public function tearDown() {}
+        public function tearDown() {
+            $this->_object = null;
+            unset($this->_object);
+        }
 
     }

Trunk/Tests/phpunit.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<phpunit
+    colors="false"
+    convertErrorsToExceptions="true"
+    convertNoticesToExceptions="true"
+    convertWarningsToExceptions="true"
+    stopOnFailure="false">
+    <testsuites>
+        <testsuite name="Unit Tests">
+            <file>Unit/ExecutableTest.php</file>
+            <file>Unit/Container/RepositoryTest.php</file>
+            <file>Unit/Command/InitTest.php</file>
+            <!--<file>Unit/HgTest.php</file>-->
+            <!--<file>Unit/Command/VersionTest.php</file>-->
+        </testsuite>
+        <!--<testsuite name="Functional Tests">
+            <file>Functional/test_Status.php</file>
+            <directory>Functional</directory>
+        </testsuite>-->
+    </testsuites>
+    <filter>
+        <whitelist>
+            <directory suffix=".php">../VersionControl</directory>
+            <!--<exclude></exclude>-->
+        </whitelist>
+    </filter>
+
+    <logging>
+        <log type="coverage-html" target="../Documentation/Quality/code-coverage/html/" yui="false" highlight="true" />
+        <log type="testdox-text" target="../Documentation/Quality/test-reports/summary.txt" />
+        <log type="testdox-html" target="../Documentation/Quality/test-reports/testdox.html" />
+        <log type="coverage-clover" target="../Documentation/Quality/code-coverage/coverage.xml "/>
+        <log type="junit" target="../Documentation/Quality/test-reports/junit-log.xml" />
+    </logging>
+</phpunit>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.