Skip to content

Commit

Permalink
Added brand names to printer models
Browse files Browse the repository at this point in the history
  • Loading branch information
mazinsw committed Aug 23, 2019
1 parent 93802c2 commit 596808c
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 5 deletions.
24 changes: 20 additions & 4 deletions src/Thermal/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Model
/**
* Model profile
*
* @var \Thermal\Profile\Profile
* @var Profile
*/
private $profile;

Expand Down Expand Up @@ -65,7 +65,7 @@ private static function expandCapabilities($model, $capabilities, $data)
*
* @param string $profile_name
* @param array $capabilities
* @return \Thermal\Profile\Profile
* @return Profile
*/
private static function newProfile($profile_name, $capabilities)
{
Expand Down Expand Up @@ -104,14 +104,23 @@ private static function newProfile($profile_name, $capabilities)
default:
return new Epson($capabilities);
}

}

/**
* Load all models and capabilities and return
*
* @return array
*/
private static function loadCapabilities()
{
return require(__DIR__ . '/resources/capabilities.php');
}

/**
* Get all models and capabilities
*
* @return array
*/
public static function getAll()
{
$data = self::loadCapabilities();
Expand All @@ -123,13 +132,20 @@ public static function getAll()
return $data['models'];
}

/**
* Selected profile name
*
* @return string
*/
public function getName()
{
return $this->profile->getName();
}

/**
* @return \Thermal\Profile\Profile
* Selected profile
*
* @return Profile
*/
public function getProfile()
{
Expand Down
2 changes: 2 additions & 0 deletions src/Thermal/resources/capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@
'brand' => 'Dataregis'
],
'daruma' => [
'brand' => 'Daruma',
'profile' => 'epson',
'columns' => 48,
'codepage' => 'CP850',
Expand All @@ -165,6 +166,7 @@
]
],
'diebold' => [
'brand' => 'Diebold',
'profile' => 'daruma',
'codepages' => [
'ABICOMP' => "\et\x01",
Expand Down
39 changes: 38 additions & 1 deletion tests/Thermal/ModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,45 @@ class ModelTest extends \PHPUnit_Framework_TestCase
{
public function testGetAll()
{
$expected = [
'MP-5100 TH' => ['brand' => 'Bematech'],
'MP-4200 TH' => ['brand' => 'Bematech'],
'MP-20 MI' => ['brand' => 'Bematech'],
'MP-100S TH' => ['brand' => 'Bematech'],
'TM-T20' => ['brand' => 'Epson'],
'TM-T81' => ['brand' => 'Epson'],
'TM-T88' => ['brand' => 'Epson'],
'NIX' => ['brand' => 'Elgin'],
'VOX+' => ['brand' => 'Elgin'],
'VOX' => ['brand' => 'Elgin'],
'I9' => ['brand' => 'Elgin'],
'I7' => ['brand' => 'Elgin'],
'DS300' => ['brand' => 'Daruma'],
'DS348' => ['brand' => 'Daruma'],
'DR600' => ['brand' => 'Daruma'],
'DR700' => ['brand' => 'Daruma'],
'DR800' => ['brand' => 'Daruma'],
'IM113' => ['brand' => 'Diebold'],
'IM402' => ['brand' => 'Diebold'],
'IM433' => ['brand' => 'Diebold'],
'IM453' => ['brand' => 'Diebold'],
'TSP-143' => ['brand' => 'Diebold'],
'SI-250' => ['brand' => 'Sweda'],
'SI-300L' => ['brand' => 'Sweda'],
'SI-300S' => ['brand' => 'Sweda'],
'SI-300W' => ['brand' => 'Sweda'],
'E-3202' => ['brand' => 'Dataregis'],
'DT200' => ['brand' => 'Dataregis'],
'IM833' => ['brand' => 'Diebold'],
'PrintiD' => ['brand' => 'ControliD'],
'PertoPrinter' => ['brand' => 'Perto'],
'CMP-20' => ['brand' => 'Citizen'],
];
$list = Model::getAll();
$this->assertInternalType('array', $list);
$list = array_map(function ($value) {
return [ 'brand' => $value['brand'] ];
}, $list);
$this->assertEquals($expected, $list);
}

public function testGetName()
Expand Down

0 comments on commit 596808c

Please sign in to comment.