public function test_removing_metadata() { $mao = $this->registry->getMAO("product"); $id = MetadataId::generate(); $mao->save(new Metadata($id, "product", ["sku" => "DUMPLIE_SKU_1", "name" => "Super Product"])); $mao->delete($id); $this->assertFalse($this->storage->has("inventory", "product", (string) $id)); }
public function test_updating_metadata() { $mao = $this->registry->getMAO("test"); $id = MetadataId::generate(); $mao->save(new Metadata($id, "test", [])); $metadata = $mao->getBy(['id' => (string) $id]); $metadata->without_default = [1, "foo" => [2, "bar"]]; $mao->save($metadata); $metadata = $mao->getBy(['id' => (string) $id]); $this->assertSame([1, "foo" => [2, "bar"]], $metadata->without_default); }
public function test_updating_metadata() { $mao = $this->registry->getMAO("test"); $id = MetadataId::generate(); $mao->save(new Metadata($id, "test", [])); $metadata = $mao->getBy(["id" => (string) $id]); $metadata->without_default = "lorem ipsum"; $mao->save($metadata); $metadata = $mao->getBy(['id' => (string) $id]); $this->assertSame("lorem ipsum", $metadata->without_default); }
public function test_updating_metadata() { $mao = $this->registry->getMAO("test"); $id = MetadataId::generate(); $mao->save(new Metadata($id, "test", [])); $metadata = $mao->getBy(['id' => (string) $id]); $metadata->without_default = true; $mao->save($metadata); $metadata = $mao->getBy(['id' => (string) $id]); $this->assertEquals(true, $metadata->without_default); }
public function test_updating_metadata() { $mao = $this->registry->getMAO("test"); $id = MetadataId::generate(); $mao->save(new Metadata($id, "test", [])); $metadata = $mao->getBy(['id' => (string) $id]); $updatedDate = new \DateTimeImmutable(); $metadata->without_default = $updatedDate; $mao->save($metadata); $metadata = $mao->getBy(['id' => (string) $id]); $this->assertEquals($updatedDate->format('U'), $metadata->without_default->format('U')); }
public function test_updating_metadata() { $mao = $this->registry->getMAO("test"); $id = MetadataId::generate(); $mao->save(new Metadata($id, "test", [])); $metadata = $mao->getBy(['id' => (string) $id]); $metadata->without_default = 0; $metadata->with_integer = 123; $metadata->with_float = 123.456; $mao->save($metadata); $metadata = $mao->getBy(['id' => (string) $id]); $this->assertSame(0.0, $metadata->without_default); $this->assertSame(123.0, $metadata->with_integer); $this->assertSame(123.456, $metadata->with_float); }
function it_allows_metadata_value() { $metadata = new Metadata(MetadataId::generate(), 'bar'); $this->isValid($metadata)->shouldReturn(true); }
function it_throws_exception_when_validated_for_wrong_model() { $this->beConstructedWith(MetadataId::generate(), "product", ["sku" => "DUMPLIE_SKU_1"]); $this->shouldThrow(InvalidArgumentException::class)->during("isValid", [new TypeSchema("order", ["user_email" => new TextField()])]); }
/** * @param Command $command * @param ServiceLocator $serviceLocator */ public function post(Command $command, ServiceLocator $serviceLocator) { /* @var CreateProduct $command */ $serviceLocator->get(Services::KERNEL_METADATA_ACCESS_REGISTRY)->getMAO(InventoryMetadata::TYPE_NAME)->save(new Metadata(MetadataId::generate(), InventoryMetadata::TYPE_NAME, [InventoryMetadata::FIELD_SKU => $command->sku(), InventoryMetadata::FIELD_VISIBLE => false])); }
public function test_removing_metadata() { $mao = $this->registry->getMAO("product"); $productId = MetadataId::generate(); $categoryId = MetadataId::generate(); $mao->save(new Metadata($productId, "product", ["category" => new Metadata($categoryId, 'category', ["name" => "Fancy stuff"])])); $mao->delete($productId); $this->assertFalse($this->storage->has("association", "product", (string) $productId)); $this->assertTrue($this->storage->has("association", "category", (string) $categoryId)); }