isEnabled() public méthode

The method {@link load()} needs to be called before calling this method, otherwise an exception is thrown.
See also: PathMappingState::ENABLED
public isEnabled ( ) : boolean
Résultat boolean Returns `true` if the state is {@link PathMappingState::ENABLED}.
Exemple #1
0
 public function testLoadStoresErrorIfPackageNotFound()
 {
     $mapping = new PathMapping('/path', array('@foo:resources', 'assets'));
     $mapping->load($this->package1, $this->packages);
     $this->assertSame(array('@foo:resources', 'assets'), $mapping->getPathReferences());
     $this->assertSame(array($this->packageDir1 . '/assets'), $mapping->getFilesystemPaths());
     // there's at least one found path, so the mapping is still enabled
     $this->assertTrue($mapping->isEnabled());
     $loadErrors = $mapping->getLoadErrors();
     $this->assertCount(1, $loadErrors);
     $this->assertInstanceOf('Puli\\Manager\\Api\\Package\\NoSuchPackageException', $loadErrors[0]);
 }
 public function testRemoveRootPathMappingRestoresResourcesIfSavingFails1()
 {
     $this->initDefaultManager();
     $this->repo->expects($this->at(0))->method('remove')->with('/path1');
     $this->repo->expects($this->at(1))->method('add')->with('/path1', new DirectoryResource($this->packageDir1 . '/resources'));
     $this->repo->expects($this->at(2))->method('remove')->with('/path2');
     $this->repo->expects($this->at(3))->method('add')->with('/path2', new DirectoryResource($this->packageDir1 . '/resources'));
     // Restore: only add root mappings
     $this->repo->expects($this->at(4))->method('add')->with('/path2', new DirectoryResource($this->rootDir . '/resources'));
     $this->repo->expects($this->at(5))->method('add')->with('/path1', new DirectoryResource($this->rootDir . '/resources'));
     $this->packageFileStorage->expects($this->once())->method('saveRootPackageFile')->willThrowException(new TestException('Cannot save'));
     $this->rootPackageFile->addPathMapping($mapping1 = new PathMapping('/path1', 'resources'));
     $this->rootPackageFile->addPathMapping($mapping2 = new PathMapping('/path2', 'resources'));
     $this->rootPackageFile->setOverriddenPackages(array('vendor/package1'));
     $this->packageFile1->addPathMapping($mapping3 = new PathMapping('/path1', 'resources'));
     $this->packageFile1->addPathMapping($mapping4 = new PathMapping('/path2', 'resources'));
     try {
         $this->manager->removeRootPathMappings(Expr::startsWith('/path', PathMapping::REPOSITORY_PATH));
         $this->fail('Expected a TestException');
     } catch (TestException $e) {
     }
     $this->assertTrue($mapping1->isEnabled());
     $this->assertTrue($mapping2->isEnabled());
     $this->assertTrue($mapping3->isEnabled());
     $this->assertTrue($mapping4->isEnabled());
     $this->assertCount(0, $this->manager->getPathConflicts());
 }