Permalink
Browse files

Moved Git- / HgTestHelper to BuildFileTest and fixed #577 (#742)

  • Loading branch information...
1 parent 2110ae7 commit 097a544d8d80fcfd97682daae8e9c8dad8a0b256 @siad007 siad007 committed with mrook Jul 14, 2017
Showing with 421 additions and 478 deletions.
  1. +78 −0 test/classes/phing/BuildFileTest.php
  2. +0 −6 test/classes/phing/tasks/ext/GitTasks/GitBaseTest.php
  3. +2 −9 test/classes/phing/tasks/ext/GitTasks/GitBranchTaskTest.php
  4. +2 −9 test/classes/phing/tasks/ext/GitTasks/GitCheckoutTaskTest.php
  5. +1 −8 test/classes/phing/tasks/ext/GitTasks/GitCloneTaskTest.php
  6. +2 −9 test/classes/phing/tasks/ext/GitTasks/GitDescribeTaskTest.php
  7. +2 −9 test/classes/phing/tasks/ext/GitTasks/GitFetchTaskTest.php
  8. +2 −9 test/classes/phing/tasks/ext/GitTasks/GitGcTaskTest.php
  9. +1 −8 test/classes/phing/tasks/ext/GitTasks/GitInitTaskTest.php
  10. +3 −10 test/classes/phing/tasks/ext/GitTasks/GitLogTaskTest.php
  11. +3 −10 test/classes/phing/tasks/ext/GitTasks/GitMergeTaskTest.php
  12. +2 −9 test/classes/phing/tasks/ext/GitTasks/GitPullTaskTest.php
  13. +3 −10 test/classes/phing/tasks/ext/GitTasks/GitPushTaskTest.php
  14. +27 −34 test/classes/phing/tasks/ext/GitTasks/GitTagTaskTest.php
  15. +0 −80 test/classes/phing/tasks/ext/GitTasks/GitTestsHelper.php
  16. +1 −2 test/classes/phing/tasks/ext/HgTasks/HgAddTaskTest.php
  17. +1 −2 test/classes/phing/tasks/ext/HgTasks/HgArchiveTaskTest.php
  18. +1 −2 test/classes/phing/tasks/ext/HgTasks/HgCommitTaskTest.php
  19. +1 −2 test/classes/phing/tasks/ext/HgTasks/HgInitTaskTest.php
  20. +1 −2 test/classes/phing/tasks/ext/HgTasks/HgLogTaskTest.php
  21. +1 −2 test/classes/phing/tasks/ext/HgTasks/HgPullTaskTest.php
  22. +1 −2 test/classes/phing/tasks/ext/HgTasks/HgPushTaskTest.php
  23. +4 −5 test/classes/phing/tasks/ext/HgTasks/HgRevertTaskTest.php
  24. +1 −2 test/classes/phing/tasks/ext/HgTasks/HgTagTaskTest.php
  25. +0 −23 test/classes/phing/tasks/ext/HgTasks/HgTestsHelper.php
  26. +1 −2 test/classes/phing/tasks/ext/HgTasks/HgUpdateTaskTest.php
  27. +2 −3 test/classes/phing/tasks/ext/svn/AbstractSvnTaskTest.php
  28. +1 −1 test/classes/phing/tasks/ext/svn/SvnLastRevisionTaskTest.php
  29. +1 −1 test/classes/phing/tasks/ext/svn/SvnListTaskTest.php
  30. +2 −3 test/classes/phing/tasks/ext/svn/SvnSwitchTaskTest.php
  31. +53 −27 test/etc/tasks/ext/git/GitBranchTaskTest.xml
  32. +26 −7 test/etc/tasks/ext/git/GitCheckoutTaskTest.xml
  33. +6 −7 test/etc/tasks/ext/git/GitCloneTaskTest.xml
  34. +4 −7 test/etc/tasks/ext/git/GitDescribeTaskTest.xml
  35. +11 −8 test/etc/tasks/ext/git/GitFetchTaskTest.xml
  36. +16 −10 test/etc/tasks/ext/git/GitGcTaskTest.xml
  37. +5 −6 test/etc/tasks/ext/git/GitInitTaskTest.xml
  38. +7 −10 test/etc/tasks/ext/git/GitLogTaskTest.xml
  39. +21 −25 test/etc/tasks/ext/git/GitMergeTaskTest.xml
  40. +18 −22 test/etc/tasks/ext/git/GitPullTaskTest.xml
  41. +30 −19 test/etc/tasks/ext/git/GitPushTaskTest.xml
  42. +52 −56 test/etc/tasks/ext/git/GitTagTaskTest.xml
  43. +25 −0 test/etc/tasks/ext/git/GitTestFunction.xml
@@ -397,6 +397,84 @@ protected function getResource($resource)
//assertNotNull("Could not find resource :" + resource, url);
//return url;
}
+
+ protected function rmdir($dir)
+ {
+ if (!file_exists($dir)) {
+ return true;
+ }
+ if (!is_dir($dir)) {
+ return unlink($dir);
+ }
+ foreach (scandir($dir) as $item) {
+ if ($item === '.' || $item === '..') {
+ continue;
+ }
+ if (!$this->rmdir($dir . DIRECTORY_SEPARATOR . $item)) {
+ return false;
+ }
+ }
+
+ return rmdir($dir);
+ }
+
+ /**
+ * Get relative date
+ *
+ * @param int $timestamp Timestamp to us as pin-point
+ * @param string $type Whether 'fulldate' or 'time'
+ * @return string
+ */
+ protected function getRelativeDate($timestamp, $type = 'fulldate')
+ {
+ // calculate the diffrence
+ $timediff = time() - $timestamp;
+
+ if ($timediff < 3600) {
+ if ($timediff < 120) {
+ $returndate = "1 minute ago";
+ } else {
+ $returndate = ceil($timediff / 60) . " minutes ago";
+ }
+ } else {
+ if ($timediff < 7200) {
+ $returndate = "1 hour ago.";
+ } else {
+ if ($timediff < 86400) {
+ $returndate = ceil($timediff / 3600) . " hours ago";
+ } else {
+ if ($timediff < 172800) {
+ $returndate = "1 day ago.";
+ } else {
+ if ($timediff < 604800) {
+ $returndate = ceil($timediff / 86400) . " days ago";
+ } else {
+ if ($timediff < 1209600) {
+ $returndate = "1 week ago.";
+ $returndate = ceil($timediff / 86400) . " days ago";
+ } else {
+ if ($timediff < 2629744) {
+ $returndate = ceil($timediff / 86400) . " days ago";
+ } else {
+ if ($timediff < 3024000) {
+ $returndate = ceil($timediff / 604900) . " weeks ago";
+ } else {
+ if ($timediff > 5259486) {
+ $returndate = ceil($timediff / 2629744) . " months ago";
+ } else {
+ $returndate = ceil($timediff / 604900) . " weeks ago";
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return $returndate;
+ }
}
/**
@@ -33,12 +33,6 @@ class GitBaseTest extends BuildFileTest
public function setUp()
{
- // the pear git package hardcodes the path to git to /usr/bin/git and will therefore
- // not work on Windows.
- if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
- $this->markTestSkipped('Testing not on a windows os.');
- }
-
$this->configureProject(
PHING_TEST_BASE
. "/etc/tasks/ext/git/GitBaseTest.xml"
@@ -21,7 +21,6 @@
require_once 'phing/BuildFileTest.php';
require_once '../classes/phing/tasks/ext/git/GitBranchTask.php';
-require_once __DIR__ . '/GitTestsHelper.php';
/**
* @author Victor Farazdagi <simple.square@gmail.com>
@@ -32,16 +31,10 @@ class GitBranchTaskTest extends BuildFileTest
{
public function setUp()
{
- // the pear git package hardcodes the path to git to /usr/bin/git and will therefore
- // not work on Windows.
- if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
- $this->markTestSkipped('Testing not on a windows os.');
- }
-
if (is_readable(PHING_TEST_BASE . '/tmp/git')) {
// make sure we purge previously created directory
// if left-overs from previous run are found
- GitTestsHelper::rmdir(PHING_TEST_BASE . '/tmp/git');
+ $this->rmdir(PHING_TEST_BASE . '/tmp/git');
}
// set temp directory used by test cases
mkdir(PHING_TEST_BASE . '/tmp/git', 0777, true);
@@ -54,7 +47,7 @@ public function setUp()
public function tearDown()
{
- GitTestsHelper::rmdir(PHING_TEST_BASE . '/tmp/git');
+ $this->rmdir(PHING_TEST_BASE . '/tmp/git');
}
public function testAllParamsSet()
@@ -21,7 +21,6 @@
require_once 'phing/BuildFileTest.php';
require_once '../classes/phing/tasks/ext/git/GitCheckoutTask.php';
-require_once __DIR__ . '/GitTestsHelper.php';
/**
* @author Victor Farazdagi <simple.square@gmail.com>
@@ -32,16 +31,10 @@ class GitCheckoutTaskTest extends BuildFileTest
{
public function setUp()
{
- // the pear git package hardcodes the path to git to /usr/bin/git and will therefore
- // not work on Windows.
- if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
- $this->markTestSkipped('Testing not on a windows os.');
- }
-
if (is_readable(PHING_TEST_BASE . '/tmp/git')) {
// make sure we purge previously created directory
// if left-overs from previous run are found
- GitTestsHelper::rmdir(PHING_TEST_BASE . '/tmp/git');
+ $this->rmdir(PHING_TEST_BASE . '/tmp/git');
}
// set temp directory used by test cases
mkdir(PHING_TEST_BASE . '/tmp/git');
@@ -54,7 +47,7 @@ public function setUp()
public function tearDown()
{
- GitTestsHelper::rmdir(PHING_TEST_BASE . '/tmp/git');
+ $this->rmdir(PHING_TEST_BASE . '/tmp/git');
}
public function testCheckoutExistingBranch()
@@ -21,7 +21,6 @@
require_once 'phing/BuildFileTest.php';
require_once '../classes/phing/tasks/ext/git/GitCloneTask.php';
-require_once __DIR__ . '/GitTestsHelper.php';
/**
* @author Victor Farazdagi <simple.square@gmail.com>
@@ -32,12 +31,6 @@ class GitCloneTaskTest extends BuildFileTest
{
public function setUp()
{
- // the pear git package hardcodes the path to git to /usr/bin/git and will therefore
- // not work on Windows.
- if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
- $this->markTestSkipped('Testing not on a windows os.');
- }
-
// set temp directory used by test cases
mkdir(PHING_TEST_BASE . '/tmp/git');
@@ -49,7 +42,7 @@ public function setUp()
public function tearDown()
{
- GitTestsHelper::rmdir(PHING_TEST_BASE . '/tmp/git');
+ $this->rmdir(PHING_TEST_BASE . '/tmp/git');
}
public function testWrongRepository()
@@ -19,7 +19,6 @@
require_once 'phing/BuildFileTest.php';
require_once '../classes/phing/tasks/ext/git/GitDescribeTask.php';
-require_once __DIR__ . '/GitTestsHelper.php';
/**
* @package phing.tasks.ext
@@ -28,16 +27,10 @@ class GitDescribeTaskTest extends BuildFileTest
{
public function setUp()
{
- // the pear git package hardcodes the path to git to /usr/bin/git and will therefore
- // not work on Windows.
- if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
- $this->markTestSkipped('Testing not on a windows os.');
- }
-
if (is_readable(PHING_TEST_BASE . '/tmp/git')) {
// make sure we purge previously created directory
// if left-overs from previous run are found
- GitTestsHelper::rmdir(PHING_TEST_BASE . '/tmp/git');
+ $this->rmdir(PHING_TEST_BASE . '/tmp/git');
}
// set temp directory used by test cases
mkdir(PHING_TEST_BASE . '/tmp/git');
@@ -50,7 +43,7 @@ public function setUp()
public function tearDown()
{
- GitTestsHelper::rmdir(PHING_TEST_BASE . '/tmp/git');
+ $this->rmdir(PHING_TEST_BASE . '/tmp/git');
}
public function testGitDescribeTask()
@@ -21,7 +21,6 @@
require_once 'phing/BuildFileTest.php';
require_once '../classes/phing/tasks/ext/git/GitFetchTask.php';
-require_once __DIR__ . '/GitTestsHelper.php';
/**
* @author Victor Farazdagi <simple.square@gmail.com>
@@ -32,16 +31,10 @@ class GitFetchTaskTest extends BuildFileTest
{
public function setUp()
{
- // the pear git package hardcodes the path to git to /usr/bin/git and will therefore
- // not work on Windows.
- if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
- $this->markTestSkipped('Testing not on a windows os.');
- }
-
if (is_readable(PHING_TEST_BASE . '/tmp/git')) {
// make sure we purge previously created directory
// if left-overs from previous run are found
- GitTestsHelper::rmdir(PHING_TEST_BASE . '/tmp/git');
+ $this->rmdir(PHING_TEST_BASE . '/tmp/git');
}
// set temp directory used by test cases
mkdir(PHING_TEST_BASE . '/tmp/git');
@@ -54,7 +47,7 @@ public function setUp()
public function tearDown()
{
- GitTestsHelper::rmdir(PHING_TEST_BASE . '/tmp/git');
+ $this->rmdir(PHING_TEST_BASE . '/tmp/git');
}
public function testAllParamsSet()
@@ -21,7 +21,6 @@
require_once 'phing/BuildFileTest.php';
require_once '../classes/phing/tasks/ext/git/GitGcTask.php';
-require_once __DIR__ . '/GitTestsHelper.php';
/**
* @author Victor Farazdagi <simple.square@gmail.com>
@@ -32,16 +31,10 @@ class GitGcTaskTest extends BuildFileTest
{
public function setUp()
{
- // the pear git package hardcodes the path to git to /usr/bin/git and will therefore
- // not work on Windows.
- if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
- $this->markTestSkipped('Testing not on a windows os.');
- }
-
if (is_readable(PHING_TEST_BASE . '/tmp/git')) {
// make sure we purge previously created directory
// if left-overs from previous run are found
- GitTestsHelper::rmdir(PHING_TEST_BASE . '/tmp/git');
+ $this->rmdir(PHING_TEST_BASE . '/tmp/git');
}
// set temp directory used by test cases
mkdir(PHING_TEST_BASE . '/tmp/git');
@@ -54,7 +47,7 @@ public function setUp()
public function tearDown()
{
- GitTestsHelper::rmdir(PHING_TEST_BASE . '/tmp/git');
+ $this->rmdir(PHING_TEST_BASE . '/tmp/git');
}
public function testAllParamsSet()
@@ -21,7 +21,6 @@
require_once 'phing/BuildFileTest.php';
require_once '../classes/phing/tasks/ext/git/GitInitTask.php';
-require_once __DIR__ . '/GitTestsHelper.php';
/**
* @author Victor Farazdagi <simple.square@gmail.com>
@@ -32,12 +31,6 @@ class GitInitTaskTest extends BuildFileTest
{
public function setUp()
{
- // the pear git package hardcodes the path to git to /usr/bin/git and will therefore
- // not work on Windows.
- if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
- $this->markTestSkipped('Testing not on a windows os.');
- }
-
// set temp directory used by test cases
mkdir(PHING_TEST_BASE . '/tmp/git');
@@ -49,7 +42,7 @@ public function setUp()
public function tearDown()
{
- GitTestsHelper::rmdir(PHING_TEST_BASE . '/tmp/git');
+ $this->rmdir(PHING_TEST_BASE . '/tmp/git');
}
public function testWrongRepository()
@@ -21,7 +21,6 @@
require_once 'phing/BuildFileTest.php';
require_once '../classes/phing/tasks/ext/git/GitLogTask.php';
-require_once __DIR__ . '/GitTestsHelper.php';
/**
* @author Victor Farazdagi <simple.square@gmail.com>
@@ -102,16 +101,10 @@ class GitLogTaskTest extends BuildFileTest
public function setUp()
{
- // the pear git package hardcodes the path to git to /usr/bin/git and will therefore
- // not work on Windows.
- if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
- $this->markTestSkipped('Testing not on a windows os.');
- }
-
if (is_readable(PHING_TEST_BASE . '/tmp/git')) {
// make sure we purge previously created directory
// if left-overs from previous run are found
- GitTestsHelper::rmdir(PHING_TEST_BASE . '/tmp/git');
+ $this->rmdir(PHING_TEST_BASE . '/tmp/git');
}
// set temp directory used by test cases
mkdir(PHING_TEST_BASE . '/tmp/git');
@@ -124,7 +117,7 @@ public function setUp()
public function tearDown()
{
- GitTestsHelper::rmdir(PHING_TEST_BASE . '/tmp/git');
+ $this->rmdir(PHING_TEST_BASE . '/tmp/git');
}
public function testGitLogWithoutParams()
@@ -183,7 +176,7 @@ public function testGitDateRelative()
$this->executeTarget('gitLogDateRelative');
foreach ($this->testCommits as $commit) {
$timestamp = strtotime($commit['date']);
- $this->assertInLogs(GitTestsHelper::getRelativeDate($timestamp));
+ $this->assertInLogs($this->getRelativeDate($timestamp));
}
}
Oops, something went wrong.

0 comments on commit 097a544

Please sign in to comment.