PluginProbe
QuadMenu – Mega Menu / 3.3.8
QuadMenu – Mega Menu v3.3.8
3.3.8 3.3.7 3.3.6 trunk 1.8.4 1.8.5 1.8.7 1.8.8 1.8.9 1.9.0 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 88 releases
quadmenu / vendor / franmastromarino / wp-orm / tests / Collection / CollectionMapperTest.php

CollectionMapperTest.php in QuadMenu – Mega Menu 3.3.8, at vendor/franmastromarino/wp-orm/tests/Collection/CollectionMapperTest.php

60 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace QuadLayers\WP_Orm\Tests\Collection\Mapper;
4
5 use PHPUnit\Framework\TestCase;
6 use QuadLayers\WP_Orm\Entity\CollectionEntity;
7 use QuadLayers\WP_Orm\Entity\EntityInterface;
8 use QuadLayers\WP_Orm\Factory\CollectionFactory;
9 use QuadLayers\WP_Orm\Mapper\CollectionMapper;
10 use QuadLayers\WP_Orm\Tests\Collection\CollectionEntityTest;
11
12 class CollectionMapperTest extends TestCase
13 {
14 private array $testValue;
15 private EntityInterface $entity;
16 private CollectionFactory $factory;
17 private CollectionMapper $mapper;
18
19 protected function setUp(): void
20 {
21
22 $entity = new CollectionEntityTest();
23
24 $this->testValue = $entity->getDefaults();
25
26 $this->factory = new CollectionFactory('\QuadLayers\WP_Orm\Tests\Collection\CollectionEntityTest');
27 $this->mapper = new CollectionMapper($this->factory);
28 $this->entity = $this->mapper->toEntity($this->testValue);
29 }
30
31 public function testToEntity()
32 {
33
34 $entity = $this->mapper->toEntity($this->testValue);
35
36 $this->assertInstanceOf(CollectionEntity::class, $entity);
37 $this->assertEquals($this->testValue['key1'], $entity->getKey1());
38 $this->assertEquals($this->testValue['key2'], $entity->getKey2());
39 }
40
41 public function testToArray()
42 {
43
44 // Then we convert the entity back to an array
45 $array = $this->mapper->toArray($this->entity);
46
47 // Check if the original array and the result are the same
48 $this->assertEquals(['id' => 0], $array);
49 }
50
51 public function testEntityHasDefaultAttributes()
52 {
53
54 $entity = $this->mapper->toEntity([]);
55
56 $this->assertEquals($this->testValue['key1'], $entity->getKey1());
57 $this->assertEquals($this->testValue['key2'], $entity->getKey2());
58 }
59 }
60