This repository has been archived by the owner on Feb 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #86 from jongotlin/external-calls
External calls
- Loading branch information
Showing
4 changed files
with
77 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace Dizda\CloudBackupBundle\Event; | ||
|
||
use Symfony\Component\EventDispatcher\Event; | ||
|
||
class BackupEvent extends Event | ||
{ | ||
const BACKUP_COMPLETED = 'dizda.cloudbackup.backup_completed'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace Dizda\CloudBackupBundle\Tests\Manager; | ||
|
||
use Dizda\CloudBackupBundle\Event\BackupEvent; | ||
use Dizda\CloudBackupBundle\Manager\BackupManager; | ||
|
||
class BackupManagerTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
public function testBackupCompletedEventIsCalledOnSuccess() | ||
{ | ||
$loggerMock = $this->getMock('Psr\Log\LoggerInterface'); | ||
$databaseManagerMock = $this->getMockBuilder('Dizda\CloudBackupBundle\Manager\DatabaseManager') | ||
->disableOriginalConstructor()->getMock(); | ||
$clientManagerMock = $this->getMockBuilder('Dizda\CloudBackupBundle\Manager\ClientManager') | ||
->disableOriginalConstructor()->getMock(); | ||
$processorManagerMock = $this->getMockBuilder('Dizda\CloudBackupBundle\Manager\ProcessorManager') | ||
->disableOriginalConstructor()->getMock(); | ||
$eventDispatcherMock = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); | ||
$eventDispatcherMock->expects($this->once())->method('dispatch')->with(BackupEvent::BACKUP_COMPLETED); | ||
|
||
$backupManager = new BackupManager( | ||
$loggerMock, $databaseManagerMock, $clientManagerMock, $processorManagerMock, $eventDispatcherMock | ||
); | ||
$backupManager->execute(); | ||
} | ||
|
||
public function testBackupCompletedEventIsNotCalledWhenFailed() | ||
{ | ||
$loggerMock = $this->getMock('Psr\Log\LoggerInterface'); | ||
$databaseManagerMock = $this->getMockBuilder('Dizda\CloudBackupBundle\Manager\DatabaseManager') | ||
->disableOriginalConstructor()->getMock(); | ||
$clientManagerMock = $this->getMockBuilder('Dizda\CloudBackupBundle\Manager\ClientManager') | ||
->disableOriginalConstructor()->getMock(); | ||
$processorManagerMock = $this->getMockBuilder('Dizda\CloudBackupBundle\Manager\ProcessorManager') | ||
->disableOriginalConstructor()->getMock(); | ||
$processorManagerMock->expects($this->once())->method('copyFolders') | ||
->will($this->throwException(new \Exception())); | ||
$eventDispatcherMock = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); | ||
$eventDispatcherMock->expects($this->never())->method('dispatch')->with(BackupEvent::BACKUP_COMPLETED); | ||
|
||
$backupManager = new BackupManager( | ||
$loggerMock, $databaseManagerMock, $clientManagerMock, $processorManagerMock, $eventDispatcherMock | ||
); | ||
$backupManager->execute(); | ||
} | ||
} |