Skip to content

Commit

Permalink
add action delete repository
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtARTs36 committed Aug 19, 2020
1 parent 88a2d4a commit b765c99
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
11 changes: 11 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,14 @@ $action = new \ArtARTs36\GitHandler\Action($git);
$action->createFile('file.php', 'echo hello world');
$action->createFile('file.php', 'echo hello world', 'folder_name');
```

#### delete repository:

```php
use ArtARTs36\GitHandler\Git;

$git = new Git('/var/web/project');
$action = new \ArtARTs36\GitHandler\Action($git);

$action->delete();
```
10 changes: 10 additions & 0 deletions src/Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace ArtARTs36\GitHandler;

use ArtARTs36\GitHandler\Support\FileSystem;

/**
* Class Action
* @package ArtARTs36\GitHandler
Expand Down Expand Up @@ -57,4 +59,12 @@ public function createFile(string $name, string $content, string $folder = null)

return $path;
}

/**
* @return bool
*/
public function delete(): bool
{
return FileSystem::removeDir($this->git->getDir());
}
}
16 changes: 16 additions & 0 deletions tests/ActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,22 @@ public function testCreateFile(): void
);
}

/**
* @covers \ArtARTs36\GitHandler\Action::delete
*/
public function testDelete(): void
{
$action = $this->mock();

self::assertFileExists($this->getTmpDir());

//

$action->delete();

self::assertFileDoesNotExist($this->getTmpDir());
}

private function mock(): Action
{
$dir = $this->getTmpDir();
Expand Down

0 comments on commit b765c99

Please sign in to comment.