public function testMatch() { $packageFile = new PackageFile('vendor/name'); $package = new Package($packageFile, __DIR__); $this->assertFalse($package->match(Expr::same('foobar', Package::NAME))); $this->assertTrue($package->match(Expr::same('vendor/name', Package::NAME))); $this->assertFalse($package->match(Expr::same('/path/foo', Package::INSTALL_PATH))); $this->assertTrue($package->match(Expr::same(__DIR__, Package::INSTALL_PATH))); $this->assertFalse($package->match(Expr::same(PackageState::NOT_LOADABLE, Package::STATE))); $this->assertTrue($package->match(Expr::same(PackageState::ENABLED, Package::STATE))); $this->assertFalse($package->match(Expr::same('webmozart', Package::INSTALLER))); // Packages without install info (= the root package) are assumed to be // installed in the production environment $this->assertTrue($package->match(Expr::same(Environment::PROD, Package::ENVIRONMENT))); $installInfo = new InstallInfo('vendor/install-info', '/path'); $installInfo->setInstallerName('webmozart'); $packageWithInstallInfo = new Package($packageFile, __DIR__, $installInfo); $this->assertFalse($packageWithInstallInfo->match(Expr::same('foobar', Package::INSTALLER))); $this->assertTrue($packageWithInstallInfo->match(Expr::same('webmozart', Package::INSTALLER))); $this->assertTrue($packageWithInstallInfo->match(Expr::notsame(Environment::DEV, Package::ENVIRONMENT))); $installInfo2 = new InstallInfo('vendor/install-info', '/path'); $installInfo2->setEnvironment(Environment::DEV); $packageWithInstallInfo2 = new Package($packageFile, __DIR__, $installInfo2); $this->assertTrue($packageWithInstallInfo2->match(Expr::same(Environment::DEV, Package::ENVIRONMENT))); }