canMoveTo() public method

Check if this member can move archive into the environment.
public canMoveTo ( DNEnvironment $targetEnv, Member | null $member = null ) : boolean
$targetEnv DNEnvironment Environment to check.
$member Member | null The {@link Member} object to test against. If null, uses Member::currentMember();
return boolean true if $member can upload archives linked to this environment, false if they can't.
Ejemplo n.º 1
0
 public function testCanMoveTo()
 {
     $samantha = $this->objFromFixture('Member', 'project1-samantha');
     $sarah = $this->objFromFixture('Member', 'project1-sarah');
     $eva = $this->objFromFixture('Member', 'eva');
     $uat1 = $this->objFromFixture('DNEnvironment', 'project1-uat');
     $live1 = $this->objFromFixture('DNEnvironment', 'project1-live');
     $uat2 = $this->objFromFixture('DNEnvironment', 'project2-uat');
     $live2 = $this->objFromFixture('DNEnvironment', 'project2-live');
     $archive = new DNDataArchive();
     $archive->EnvironmentID = $uat1->ID;
     $archive->write();
     // Samantha doesn't have upload permission to live1.
     $this->assertFalse($archive->canMoveTo($live1, $samantha));
     // Cross-project moves are forbidden.
     $this->assertFalse($archive->canMoveTo($uat2, $samantha));
     // Eva has upload permission to live1.
     $this->assertTrue($archive->canMoveTo($live1, $eva));
     // Cross-project moves are forbidden.
     $this->assertFalse($archive->canMoveTo($uat2, $eva));
     // Sarah has upload permission to live1, but not download to uat1.
     $this->assertFalse($archive->canMoveTo($live1, $sarah));
 }