/** * @testdox encode() properly encodes deduplicated config values */ public function testEncodeDeduplicatedConfigValue() { $configValue = new ConfigValue([0, 0], 'o82015558'); $configValue->incrementUseCount(); $configValue->incrementUseCount(); $configValue->deduplicate(); $encoder = new Encoder(); $this->assertSame('o82015558', $encoder->encode($configValue)); }
/** * @testdox deduplicate() decrements the use counter of config values contained in the instance */ public function testDeduplicateCascade2() { $sub = new ConfigValue([0, 0], 'sub'); $sub->incrementUseCount(); $sub->incrementUseCount(); $sub->incrementUseCount(); $sub->incrementUseCount(); $configValue = new ConfigValue([$sub, $sub], 'foo'); $configValue->incrementUseCount(); $configValue->incrementUseCount(); $configValue->deduplicate(); $this->assertSame(2, $sub->getUseCount()); }
/** * Encode a ConfigValue instance into JavaScript * * @param ConfigValue $configValue * @return string */ protected function encodeConfigValue(ConfigValue $configValue) { return $configValue->isDeduplicated() ? $configValue->getVarName() : $this->encode($configValue->getValue()); }