Skip to content

Commit

Permalink
Updating test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
akadlec committed Jan 23, 2022
1 parent a6790cd commit 5ffec1d
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 6 deletions.
4 changes: 4 additions & 0 deletions src/Entities/Devices/Device.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,15 @@ abstract class Device implements IDevice, DoctrineDynamicDiscriminatorMapEntitie

/**
* @param string $identifier
* @param Entities\Connectors\IConnector $connector
* @param string|null $name
* @param Uuid\UuidInterface|null $id
*
* @throws Throwable
*/
public function __construct(
string $identifier,
Entities\Connectors\IConnector $connector,
?string $name,
?Uuid\UuidInterface $id = null
) {
Expand All @@ -239,6 +241,8 @@ public function __construct(

$this->firmwareManufacturer = MetadataTypes\FirmwareManufacturerType::MANUFACTURER_GENERIC;

$this->connector = $connector;

$this->children = new Common\Collections\ArrayCollection();
$this->channels = new Common\Collections\ArrayCollection();
$this->controls = new Common\Collections\ArrayCollection();
Expand Down
19 changes: 13 additions & 6 deletions tests/cases/Unit/Subscribers/EntitiesSubscriberTest.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use FastyBird\Metadata;
use Mockery;
use Nette\Utils;
use Ninjify\Nunjuck\TestCase\BaseMockeryTestCase;
use Ramsey\Uuid;
use stdClass;
use Tester\Assert;

Expand Down Expand Up @@ -70,7 +71,7 @@ final class EntitiesSubscriberTest extends BaseMockeryTestCase
'hardware_mac_address' => null,
'firmware_manufacturer' => 'generic',
'firmware_version' => null,
'connector' => null,
'connector' => 'dd6aa4bc-2611-40c3-84ef-0a438cf51e67',
]), $data);

return true;
Expand All @@ -87,7 +88,9 @@ final class EntitiesSubscriberTest extends BaseMockeryTestCase
$publisher
);

$entity = new Entities\Devices\VirtualDevice('device-name', 'device-name');
$connectorEntity = new Entities\Connectors\VirtualConnector('virtual-connector-name', Uuid\Uuid::fromString('dd6aa4bc-2611-40c3-84ef-0a438cf51e67'));

$entity = new Entities\Devices\VirtualDevice('device-name', $connectorEntity, 'device-name');
$entity->setKey('bLikmS');
$entity->setName('Device custom name');

Expand Down Expand Up @@ -170,7 +173,7 @@ final class EntitiesSubscriberTest extends BaseMockeryTestCase
'hardware_mac_address' => null,
'firmware_manufacturer' => 'generic',
'firmware_version' => null,
'connector' => null,
'connector' => 'dd6aa4bc-2611-40c3-84ef-0a438cf51e67',
]), $data);

return true;
Expand All @@ -187,7 +190,9 @@ final class EntitiesSubscriberTest extends BaseMockeryTestCase
$publisher
);

$entity = new Entities\Devices\VirtualDevice('device-name', 'device-name');
$connectorEntity = new Entities\Connectors\VirtualConnector('virtual-connector-name', Uuid\Uuid::fromString('dd6aa4bc-2611-40c3-84ef-0a438cf51e67'));

$entity = new Entities\Devices\VirtualDevice('device-name', $connectorEntity, 'device-name');
$entity->setKey('bLikmS');
$entity->setName('Device custom name');

Expand Down Expand Up @@ -225,14 +230,16 @@ final class EntitiesSubscriberTest extends BaseMockeryTestCase
'hardware_mac_address' => null,
'firmware_manufacturer' => 'generic',
'firmware_version' => null,
'connector' => null,
'connector' => 'dd6aa4bc-2611-40c3-84ef-0a438cf51e67',
]), $data);

return true;
})
->times(1);

$entity = new Entities\Devices\VirtualDevice('device-name', 'device-name');
$connectorEntity = new Entities\Connectors\VirtualConnector('virtual-connector-name', Uuid\Uuid::fromString('dd6aa4bc-2611-40c3-84ef-0a438cf51e67'));

$entity = new Entities\Devices\VirtualDevice('device-name', $connectorEntity, 'device-name');
$entity->setKey('bLikmS');
$entity->setName('Device custom name');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@
],
"enabled" : true,
"name" : "Newly created device"
},
"relationships" : {
"connector" : {
"data" : {
"type" : "devices-module/connector-virtual",
"id" : "17c59dfa-2edd-438e-8c49-faa4e38e5a5e"
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@
],
"enabled" : true,
"name" : "Newly created device"
},
"relationships" : {
"connector" : {
"data" : {
"type" : "devices-module/connector-virtual",
"id" : "17c59dfa-2edd-438e-8c49-faa4e38e5a5e"
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@
],
"enabled" : true,
"name" : "Newly created device"
},
"relationships" : {
"connector" : {
"data" : {
"type" : "devices-module/connector-virtual",
"id" : "17c59dfa-2edd-438e-8c49-faa4e38e5a5e"
}
}
}
}
}

0 comments on commit 5ffec1d

Please sign in to comment.