public function setUp() { $serializer_registry = new SerializerRegistry(); $serializer_registry->registerSerializerForContract(new Contract(PhpSerializer::class), new PhpSerializer()); $this->serialization_strategy = new SerializationStrategy($serializer_registry, new Contract(PhpSerializer::class)); $this->commit = new Commit(CommitId::generate(), new \DateTimeImmutable(self::TEST_COMMIT_TIMESTAMP)); }
/** * @expectedException \hollodotme\MilestonES\Exceptions\SerializationContractIsNotRegistered */ public function testGetSerializerForContractFailsWhenContractIsNotRegistered() { $php_contract = new Contract(PhpSerializer::class); $this->registry->registerSerializerForContract($php_contract, new PhpSerializer()); $strategy = new SerializationStrategy($this->registry, $php_contract); $strategy->getSerializerForContract(new Contract('Some\\Not\\Registered\\Contract')); }
/** * @expectedException \hollodotme\MilestonES\Exceptions\SerializationContractIsNotRegistered */ public function testGetSerializerForContractFailsWhenContractIsNotRegistered() { $registry = new SerializerRegistry(); $registry->getSerializerForContract(new Contract('Some\\Contract')); }
/** * @return SerializerRegistry */ public function getSerializerRegistry() { $registry = new SerializerRegistry(); $registry->registerSerializerForContract(new Contract(PhpSerializer::class), new PhpSerializer()); return $registry; }
/** * @throws DefaultSerializationContractIsNotRegistered */ private function guardDefaultContractIsRegistered() { if (!$this->registry->isContractRegistered($this->defaultContract)) { throw new DefaultSerializationContractIsNotRegistered($this->defaultContract->toString()); } }