Skip to content
This repository has been archived by the owner on Apr 16, 2024. It is now read-only.

File permission task logging #212

Merged
merged 2 commits into from Aug 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Task/FilePermissionTask.php
Expand Up @@ -42,7 +42,7 @@ public static function getSubscribedEvents()
*
* @param array $paths
*/
public function __construct($paths)
public function __construct(array $paths)
{
$this->paths = $paths;
}
Expand All @@ -61,7 +61,7 @@ public function onInstallReleaseUpdateFilePermissions(InstallReleaseEvent $event
$host = $event->getRelease()->getWorkspace()->getHost();
$connection = $this->ensureConnection($host);

$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::INFO, 'Updating permissions for configured paths...', $eventName, $this, array('event.task.action' => TaskInterface::ACTION_IN_PROGRESS)));
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Updating permissions for the configured paths...', $eventName, $this, array('event.task.action' => TaskInterface::ACTION_IN_PROGRESS)));

$releasePath = $event->getRelease()->getPath();

Expand All @@ -71,9 +71,9 @@ public function onInstallReleaseUpdateFilePermissions(InstallReleaseEvent $event
}

if ($result === true) {
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::INFO, 'Updated permissions for configured paths.', $eventName, $this, array('event.task.action' => TaskInterface::ACTION_COMPLETED, 'output.resetLine' => true)));
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Updated permissions for the configured paths.', $eventName, $this, array('event.task.action' => TaskInterface::ACTION_COMPLETED, 'output.resetLine' => true)));
} else {
throw new TaskRuntimeException('Failed updating the permissions for configured paths.', $this);
throw new TaskRuntimeException('Failed updating the permissions for the configured paths.', $this);
}
}

Expand Down
7 changes: 5 additions & 2 deletions tests/Task/FilePermissionTaskTest.php
Expand Up @@ -80,9 +80,10 @@ public function testOnInstallReleaseUpdateFilePermissionsThrowsRuntimeException(

$event = new InstallReleaseEvent($releaseMock);

$this->setExpectedException(TaskRuntimeException::class, 'Failed updating the permissions for configured paths.');
$this->setExpectedException(TaskRuntimeException::class, 'Failed updating the permissions for the configured paths.');

$paths = array('invalid' => array());

$task = new FilePermissionTask($paths);
$task->onInstallReleaseUpdateFilePermissions($event, AccompliEvents::INSTALL_RELEASE, $eventDispatcherMock);
}
Expand Down Expand Up @@ -131,6 +132,7 @@ public function testOnInstallUpdateFilePermissions()
$event = new InstallReleaseEvent($releaseMock);

$paths = array('var/cache' => array('recursive' => true, 'permissions' => '-rwxrwx---'));

$task = new FilePermissionTask($paths);
$task->onInstallReleaseUpdateFilePermissions($event, AccompliEvents::INSTALL_RELEASE, $eventDispatcherMock);
}
Expand Down Expand Up @@ -178,9 +180,10 @@ public function testOnInstallUpdateFilePermissionsWhenPermissionsCannotBeChanged

$event = new InstallReleaseEvent($releaseMock);

$this->setExpectedException(TaskRuntimeException::class, 'Failed updating the permissions for configured paths.');
$this->setExpectedException(TaskRuntimeException::class, 'Failed updating the permissions for the configured paths.');

$paths = array('var/cache' => array('permissions' => '-rwxrwx'));

$task = new FilePermissionTask($paths);
$task->onInstallReleaseUpdateFilePermissions($event, AccompliEvents::INSTALL_RELEASE, $eventDispatcherMock);
}
Expand Down