Inheritance: extends Dumplie\SharedKernel\Domain\Identity\UUID
コード例 #1
0
ファイル: MetadataTestCase.php プロジェクト: dumplie/dumplie
 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));
 }
コード例 #2
0
ファイル: MapTypeTestCase.php プロジェクト: dumplie/dumplie
 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);
 }
コード例 #3
0
ファイル: TextTypeTestCase.php プロジェクト: dumplie/dumplie
 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);
 }
コード例 #4
0
 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);
 }
コード例 #5
0
 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'));
 }
コード例 #6
0
 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);
 }
コード例 #7
0
 function it_allows_metadata_value()
 {
     $metadata = new Metadata(MetadataId::generate(), 'bar');
     $this->isValid($metadata)->shouldReturn(true);
 }
コード例 #8
0
ファイル: MetadataSpec.php プロジェクト: dumplie/dumplie
 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()])]);
 }
コード例 #9
0
ファイル: MetadataExtension.php プロジェクト: dumplie/dumplie
 /**
  * @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]));
 }
コード例 #10
0
 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));
 }