aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilly Micieli <micieli@laposte.net>2019-11-05 17:46:20 +0100
committerWilly Micieli <micieli@laposte.net>2019-11-05 17:46:20 +0100
commit0268298fa8498b6c3c07cb1384a136fb8801a9ea (patch)
treef2ff5c063bad2a7b5e5ddb3ae3a316ede9800980
parent01d4af0d79aae7b18b27f7d4edc53c786b062724 (diff)
downloadimperium-0268298fa8498b6c3c07cb1384a136fb8801a9ea.zip
imperium-0268298fa8498b6c3c07cb1384a136fb8801a9ea.tar.gz
add test fix bugs
-rw-r--r--imperium/Versioning/Git.php19
-rw-r--r--tests/FileTest.php25
-rw-r--r--tests/Versioning/GitTest.php11
3 files changed, 32 insertions, 23 deletions
diff --git a/imperium/Versioning/Git.php b/imperium/Versioning/Git.php
index 8c62b77..cd8af2b 100644
--- a/imperium/Versioning/Git.php
+++ b/imperium/Versioning/Git.php
@@ -3,7 +3,6 @@
namespace Imperium\Versioning;
use Imperium\Collection\Collect;
- use Imperium\Directory\Dir;
use Imperium\Exception\Kedavra;
use Imperium\Html\Pagination\Pagination;
use Imperium\Redis\Redis;
@@ -173,17 +172,29 @@
$x = collect($this->releases());
return $this->diff($x->get(0),$x->get(1));
}
- public function log(int $current_page)
+
+ /**
+ *
+ * Show logs
+ *
+ * @param int $current_page
+ *
+ * @param string $branch
+ * @return string
+ *
+ * @throws Kedavra
+ */
+ public function log(int $current_page,string $branch)
{
$format = '<div class="card"><div class="card-header" id="commit-%h"><h2 class="mb-0"><button class="btn btn-link" type="button" data-toggle="collapse" data-target="#commit-%H" aria-controls="commit-%H">%s</button></h2></div><div id="commit-%H" class="collapse" aria-labelledby="commit-%H" data-parent="#logs"><div class="card-body"><p>%s</p><div class="text-center"><a href="mailto:%ae" class="btn btn-outline-primary">%an</a></div></div><div class="card-footer text-muted">%cr</div></div></div>';
- $pagination = (new Pagination($current_page,100,$this->commits_size($this->current_branch())))->paginate();
+ $pagination = (new Pagination($current_page,100,$this->commits_size($branch)))->paginate();
$html = '<div class="accordion" id="logs">';
if (equal($current_page,0))
{
- append($html,html_entity_decode($this->execute("git log -n 100 --pretty=format:'$format'")->join('')));
+ append($html,html_entity_decode($this->execute("git log -n 100 --pretty=format:'$format' $branch" )->join('')));
}else{
$x = 100 * $current_page;
append($html,html_entity_decode($this->execute("git log --skip=$x -n 100 --pretty=format:'$format'")->join('')));
diff --git a/tests/FileTest.php b/tests/FileTest.php
index e29d2e4..30c8b07 100644
--- a/tests/FileTest.php
+++ b/tests/FileTest.php
@@ -251,23 +251,7 @@ class FileTest extends Unit
}
- /**
- * @throws Kedavra
- */
- public function test_copy()
- {
- $this->assertTrue($this->file('.env.example')->copy('.env'));
- $this->assertEquals('Shaolin',env('app'));
- $this->assertTrue($this->file('.env')->remove());
-
- $this->assertTrue($this->file('.env.example')->copy('.env'));
- $this->assertEquals('Shaolin',env('app'));
- $this->assertTrue($this->file('.env')->remove());
-
- $this->assertTrue($this->file('.env.example')->copy('.env'));
- $key = Crypt::generateKey();
- $this->assertTrue($this->file('.env',EMPTY_AND_WRITE_FILE_MODE)->write("APP_KEY=$key")->flush());
- }
+
/**
* @throws Kedavra
@@ -277,6 +261,13 @@ class FileTest extends Unit
$this->assertIsString($this->file('grumphp.yml')->path());
}
+ public function test_copy()
+ {
+ $this->assertTrue($this->file('README.md')->copy('TODO.md'));
+ $this->assertTrue(file_exists('TODO.md'));
+ $this->assertNotEmpty($this->file('TODO.md')->read());
+ $this->assertTrue($this->file('TODO.md')->remove());
+ }
/**
* @throws Kedavra
*/
diff --git a/tests/Versioning/GitTest.php b/tests/Versioning/GitTest.php
index b69f99b..630f88b 100644
--- a/tests/Versioning/GitTest.php
+++ b/tests/Versioning/GitTest.php
@@ -63,11 +63,18 @@ class GitTest extends Unit
public function test_log()
{
- $first = $this->git->log(0);
- $second = $this->git->log(1);
+ $first = $this->git->log(0,'master');
+ $second = $this->git->log(1,'master');
$this->assertNotEmpty($first);
$this->assertNotEmpty($second);
$this->assertTrue(different($first,$second));
+ $first_develop = $this->git->log(0,'develop');
+ $second_develop = $this->git->log(1,'develop');
+ $this->assertNotEmpty($first_develop);
+ $this->assertNotEmpty($second_develop);
+ $this->assertTrue(different($first,$first_develop));
+
+
}
public function test_releases()