本文整理汇总了PHP中Webmozart\Expression\Expr::startsWith方法的典型用法代码示例。如果您正苦于以下问题:PHP Expr::startsWith方法的具体用法?PHP Expr::startsWith怎么用?PHP Expr::startsWith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Webmozart\Expression\Expr
的用法示例。
在下文中一共展示了Expr::startsWith方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testBuildExpressionWithCustomCriteria
public function testBuildExpressionWithCustomCriteria()
{
$expr1 = Expr::startsWith('abcd', AssetMapping::UUID)->orSame('local', AssetMapping::SERVER_NAME)->orX(Expr::same('/path', AssetMapping::GLOB)->andSame('css', AssetMapping::SERVER_PATH));
$expr2 = Expr::same(BindingState::ENABLED, BindingDescriptor::STATE)->andSame(DiscoveryUrlGenerator::BINDING_TYPE, BindingDescriptor::TYPE_NAME)->andEndsWith('{,/**/*}', BindingDescriptor::QUERY)->andX(Expr::startsWith('abcd', BindingDescriptor::UUID)->orKey(BindingDescriptor::PARAMETER_VALUES, Expr::key(DiscoveryUrlGenerator::SERVER_PARAMETER, Expr::same('local')))->orX(Expr::same('/path{,/**/*}', BindingDescriptor::QUERY)->andKey(BindingDescriptor::PARAMETER_VALUES, Expr::key(DiscoveryUrlGenerator::PATH_PARAMETER, Expr::same('css')))));
$this->assertEquals($expr2, $this->builder->buildExpression($expr1));
}
示例2: testRemoveServersRevertsIfSavingFails
public function testRemoveServersRevertsIfSavingFails()
{
$this->packageFileManager->expects($this->any())->method('getExtraKey')->with(PackageFileServerManager::SERVERS_KEY)->willReturn((object) array('localhost' => (object) array('installer' => 'symlink', 'document-root' => 'web', 'url-format' => '/public/%s'), 'cdn' => (object) array('installer' => 'rsync', 'document-root' => 'ssh://my.cdn.com', 'parameters' => (object) array('param' => 'value'))));
$this->packageFileManager->expects($this->once())->method('setExtraKey')->willThrowException(new TestException());
try {
$this->serverManager->removeServers(Expr::startsWith('localhost', Server::NAME));
$this->fail('Expected a TestException');
} catch (TestException $e) {
}
$this->assertTrue($this->serverManager->hasServer('localhost'));
$this->assertTrue($this->serverManager->hasServer('cdn'));
}
示例3: getMappingByUuidPrefix
/**
* @param string $uuidPrefix
*
* @return AssetMapping
*/
private function getMappingByUuidPrefix($uuidPrefix)
{
$expr = Expr::startsWith($uuidPrefix, AssetMapping::UUID);
$mappings = $this->assetManager->findAssetMappings($expr);
if (!$mappings) {
throw new RuntimeException(sprintf('The mapping with the UUID prefix "%s" does not exist.', $uuidPrefix));
}
if (count($mappings) > 1) {
throw new RuntimeException(sprintf('More than one mapping matches the UUID prefix "%s".', $uuidPrefix));
}
return reset($mappings);
}
示例4: testDeleteMappingFailsIfAmbiguous
/**
* @expectedException \RuntimeException
* @expectedExceptionMessage More than one mapping matches the UUID prefix "abcd".
*/
public function testDeleteMappingFailsIfAmbiguous()
{
$this->assetManager->expects($this->once())->method('findAssetMappings')->with(Expr::startsWith('abcd', AssetMapping::UUID))->willReturn(array(new AssetMapping('/app/public1', 'localhost', '/'), new AssetMapping('/app/public2', 'localhost', '/')));
$this->assetManager->expects($this->never())->method('removeRootAssetMapping');
$args = self::$deleteCommand->parseArgs(new StringArgs('abcd'));
$this->handler->handleDelete($args);
}
示例5: getBindingByUuidPrefix
/**
* @param string $uuidPrefix
*
* @return BindingDescriptor
*/
private function getBindingByUuidPrefix($uuidPrefix)
{
$expr = Expr::method('getUuid', Expr::startsWith($uuidPrefix));
$descriptors = $this->discoveryManager->findBindingDescriptors($expr);
if (0 === count($descriptors)) {
throw new RuntimeException(sprintf('The binding "%s" does not exist.', $uuidPrefix));
}
if (count($descriptors) > 1) {
throw new RuntimeException(sprintf('More than one binding matches the UUID prefix "%s".', $uuidPrefix));
}
return reset($descriptors);
}
示例6: testFindBindings
public function testFindBindings()
{
$this->initDefaultManager();
$binding1 = new BindingDescriptor('/path1', 'my/type', array(), 'glob', $uuid1 = Uuid::fromString('f966a2e1-4738-42ac-b007-1ac8798c1877'));
$binding2 = new BindingDescriptor('/path2', 'my/type', array(), 'glob', $uuid2 = Uuid::fromString('ecc5bb18-a4be-483d-9682-3999504b80d5'));
$binding3 = new BindingDescriptor('/path3', 'my/type', array(), 'glob', $uuid3 = Uuid::fromString('ecc0b0b5-67ff-4b01-9836-9aa4d5136af4'));
$this->rootPackageFile->addBindingDescriptor($binding1);
$this->packageFile1->addBindingDescriptor($binding2);
$this->packageFile2->addBindingDescriptor($binding3);
$expr1 = Expr::startsWith('ecc', BindingDescriptor::UUID);
$expr2 = $expr1->andSame('vendor/package1', BindingDescriptor::CONTAINING_PACKAGE);
$expr3 = $expr1->andSame('vendor/root', BindingDescriptor::CONTAINING_PACKAGE);
$this->assertSame(array($binding2, $binding3), $this->manager->findBindings($expr1));
$this->assertSame(array($binding2), $this->manager->findBindings($expr2));
$this->assertSame(array(), $this->manager->findBindings($expr3));
}
示例7: testFindExtraKeys
public function testFindExtraKeys()
{
$this->rootPackageFile->setExtraKey('key1', 'value1');
$this->rootPackageFile->setExtraKey('key2', 'value2');
$expr1 = Expr::same('key1');
$expr2 = Expr::startsWith('key');
$expr3 = Expr::same('foo');
$this->assertSame(array('key1' => 'value1'), $this->manager->findExtraKeys($expr1));
$this->assertSame(array('key1' => 'value1', 'key2' => 'value2'), $this->manager->findExtraKeys($expr2));
$this->assertSame(array(), $this->manager->findExtraKeys($expr3));
}
示例8: andStartsWith
public function andStartsWith($prefix)
{
return $this->andX(Expr::startsWith($prefix));
}
示例9: testMatch
public function testMatch()
{
$type = new BindingTypeDescriptor('vendor/type', null, array(new BindingParameterDescriptor('param')));
$type->load($this->package);
$uuid = Uuid::fromString('abcdb814-9dad-11d1-80b4-00c04fd430c8');
$this->package->getInstallInfo()->addEnabledBindingUuid($uuid);
$binding = new BindingDescriptor('/path', 'vendor/type', array('param' => 'value'), 'glob', $uuid);
$binding->load($this->package, $type);
$this->assertFalse($binding->match(Expr::same('foobar', BindingDescriptor::CONTAINING_PACKAGE)));
$this->assertTrue($binding->match(Expr::same($this->package->getName(), BindingDescriptor::CONTAINING_PACKAGE)));
$this->assertFalse($binding->match(Expr::same(BindingState::DISABLED, BindingDescriptor::STATE)));
$this->assertTrue($binding->match(Expr::same(BindingState::ENABLED, BindingDescriptor::STATE)));
$this->assertFalse($binding->match(Expr::startsWith('abce', BindingDescriptor::UUID)));
$this->assertTrue($binding->match(Expr::startsWith('abcd', BindingDescriptor::UUID)));
$this->assertFalse($binding->match(Expr::same('/path/nested', BindingDescriptor::QUERY)));
$this->assertTrue($binding->match(Expr::same('/path', BindingDescriptor::QUERY)));
$this->assertFalse($binding->match(Expr::same('xpath', BindingDescriptor::LANGUAGE)));
$this->assertTrue($binding->match(Expr::same('glob', BindingDescriptor::LANGUAGE)));
$this->assertFalse($binding->match(Expr::same('vendor/other', BindingDescriptor::TYPE_NAME)));
$this->assertTrue($binding->match(Expr::same('vendor/type', BindingDescriptor::TYPE_NAME)));
$this->assertFalse($binding->match(Expr::key(BindingDescriptor::PARAMETER_VALUES, Expr::key('param', Expr::same('foobar')))));
$this->assertTrue($binding->match(Expr::key(BindingDescriptor::PARAMETER_VALUES, Expr::key('param', Expr::same('value')))));
}
示例10: testRemovePackagesRevertsIfSavingNotPossible
public function testRemovePackagesRevertsIfSavingNotPossible()
{
$this->initDefaultManager();
$this->packageFileStorage->expects($this->once())->method('saveRootPackageFile')->willThrowException(new TestException());
try {
$this->manager->removePackages(Expr::startsWith('vendor/package', Package::NAME));
$this->fail('Expected a TestException');
} catch (TestException $e) {
}
$this->assertTrue($this->rootPackageFile->hasInstallInfo('vendor/package1'));
$this->assertTrue($this->rootPackageFile->hasInstallInfo('vendor/package2'));
$this->assertTrue($this->manager->hasPackage('vendor/package1'));
$this->assertTrue($this->manager->hasPackage('vendor/package2'));
$this->assertTrue($this->manager->getPackages()->contains('vendor/package1'));
$this->assertTrue($this->manager->getPackages()->contains('vendor/package2'));
}
示例11: testRemoveTargetsRevertsIfSavingFails
public function testRemoveTargetsRevertsIfSavingFails()
{
$this->packageFileManager->expects($this->any())->method('getExtraKey')->with(AssetPlugin::INSTALL_TARGETS_KEY)->willReturn((object) array('local' => (object) array('installer' => 'symlink', 'location' => 'web', 'url-format' => '/public/%s', 'default' => true), 'cdn' => (object) array('installer' => 'rsync', 'location' => 'ssh://my.cdn.com', 'parameters' => (object) array('param' => 'value'))));
$this->packageFileManager->expects($this->once())->method('setExtraKey')->willThrowException(new TestException());
try {
$this->targetManager->removeTargets(Expr::startsWith('local', InstallTarget::NAME));
$this->fail('Expected a TestException');
} catch (TestException $e) {
}
$this->assertTrue($this->targetManager->hasTarget('local'));
$this->assertTrue($this->targetManager->hasTarget('cdn'));
}
示例12: testMatch
public function testMatch()
{
$mapping = new PathMapping('/path', 'resources');
$mapping->load($this->package1, $this->packages);
$this->assertFalse($mapping->match(Expr::same('foobar', PathMapping::CONTAINING_PACKAGE)));
$this->assertTrue($mapping->match(Expr::same($this->package1->getName(), PathMapping::CONTAINING_PACKAGE)));
$this->assertFalse($mapping->match(Expr::same(PathMappingState::CONFLICT, PathMapping::STATE)));
$this->assertTrue($mapping->match(Expr::same(PathMappingState::ENABLED, PathMapping::STATE)));
$this->assertFalse($mapping->match(Expr::startsWith('/foo', PathMapping::REPOSITORY_PATH)));
$this->assertTrue($mapping->match(Expr::startsWith('/pa', PathMapping::REPOSITORY_PATH)));
}
示例13: testFindRootPathMappings
public function testFindRootPathMappings()
{
$this->initDefaultManager();
$this->rootPackageFile->addPathMapping($mapping1 = new PathMapping('/path1', 'resources'));
$this->rootPackageFile->addPathMapping($mapping2 = new PathMapping('/path2', 'resources'));
$this->packageFile1->addPathMapping($mapping3 = new PathMapping('/path1', 'resources'));
$expr1 = Expr::startsWith('/path', PathMapping::REPOSITORY_PATH);
$expr2 = Expr::same('/path2', PathMapping::REPOSITORY_PATH);
$this->assertSame(array($mapping1, $mapping2), $this->manager->findRootPathMappings($expr1));
$this->assertSame(array($mapping2), $this->manager->findRootPathMappings($expr2));
}
示例14: testFindConfigKeysReturnsParsedValuesIfEnabled
public function testFindConfigKeysReturnsParsedValuesIfEnabled()
{
$this->baseConfig->set(Config::FACTORY_AUTO_GENERATE, true);
$this->configFile->getConfig()->set(Config::PULI_DIR, 'my-puli-dir');
$this->configFile->getConfig()->set(Config::FACTORY_IN_CLASS, 'MyFactory');
$this->configFile->getConfig()->set(Config::FACTORY_IN_FILE, '{$puli-dir}/MyFactory.php');
$this->assertSame(array(Config::FACTORY_IN_CLASS => 'MyFactory', Config::FACTORY_IN_FILE => 'my-puli-dir/MyFactory.php'), $this->manager->findConfigKeys(Expr::startsWith('factory.'), false, false, false));
}
示例15: testRemoveRootInstallerDescriptorsRestoresPreviousInstallersIfSavingFails
public function testRemoveRootInstallerDescriptorsRestoresPreviousInstallersIfSavingFails()
{
$this->rootPackageFile->setExtraKey(AssetPlugin::INSTALLERS_KEY, (object) array('symlink' => (object) array('class' => 'SymlinkInstaller'), 'cdn' => (object) array('class' => 'CdnInstaller')));
$this->packageFileManager->expects($this->once())->method('setExtraKey')->with(AssetPlugin::INSTALLERS_KEY, (object) array('cdn' => (object) array('class' => 'CdnInstaller')))->willThrowException(new TestException());
try {
$this->manager->removeRootInstallerDescriptors(Expr::startsWith('symlink', InstallerDescriptor::NAME));
$this->fail('Expected a TestException');
} catch (TestException $e) {
}
$this->assertEquals((object) array('symlink' => (object) array('class' => 'SymlinkInstaller'), 'cdn' => (object) array('class' => 'CdnInstaller')), $this->rootPackageFile->getExtraKey(AssetPlugin::INSTALLERS_KEY));
$this->assertTrue($this->manager->hasInstallerDescriptor('symlink'));
$this->assertTrue($this->manager->hasInstallerDescriptor('cdn'));
}