Пример #1
0
 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
 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
 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
 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));
 }
Пример #8
0
 /**
  * @param Connection $connection
  * @param MetadataAccessRegistry $accessRegistry
  */
 public function __construct(Connection $connection, MetadataAccessRegistry $accessRegistry)
 {
     $this->connection = $connection;
     $this->mao = $accessRegistry->getMAO(Metadata::TYPE_NAME);
 }
Пример #9
0
 public function test_changing_default_form_type()
 {
     $this->builder->addType(new Schema\TypeSchema("form", ['text_field' => new Schema\Field\TextField()]));
     $form = $this->factory->create(MetadataType::class, null, ['mao' => $this->registry->getMAO('form'), 'type_forms' => ['text_field' => TextareaType::class]]);
     $this->assertInstanceOf(TextareaType::class, $form->get('text_field')->getConfig()->getType()->getInnerType());
 }