/** * @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')); }
public function testGetSerializerForContract() { $registry = new SerializerRegistry(); $registry->registerSerializerForContract(new Contract('Some\\Contract'), new PhpSerializer()); $serializer = $registry->getSerializerForContract(new Contract('Some\\Contract')); $this->assertInstanceOf(PhpSerializer::class, $serializer); }
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)); }
/** * @return SerializerRegistry */ public function getSerializerRegistry() { $registry = new SerializerRegistry(); $registry->registerSerializerForContract(new Contract(PhpSerializer::class), new PhpSerializer()); return $registry; }