Skip to content

Commit

Permalink
43305 update unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
yeneastgate committed Jan 26, 2024
1 parent 40bd710 commit c8a8382
Showing 1 changed file with 26 additions and 30 deletions.
56 changes: 26 additions & 30 deletions tests/TestClassCustomlabelRead.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,56 +66,52 @@ public function prepare()
* @dataProvider dataProviderField
* @param int $formId
* @param array $rows
* @param CustomLabelModelField $pReference
*
*/

public function testReadCustomLabelsField(int $formId, array $rows, CustomLabelModelField $pReference)
public function testReadCustomLabelsField(int $formId, array $rows)
{
$this->_pWPDBMock->expects($this->once())->method('get_results')->will($this->returnValue($rows));
$pField = new Field('testField', 'testModule');
$pResult = $this->_pSubject->readCustomLabelsField($formId, [$pField],'oo_plugin_fieldconfig_form_customs_labels','oo_plugin_fieldconfig_form_translated_labels');

$pResult = $this->_pSubject->readCustomLabelsField($formId, $pField,'oo_plugin_fieldconfig_form_customs_labels','oo_plugin_fieldconfig_form_translated_labels');
$this->assertInstanceOf(CustomLabelModelField::class, $pResult);
$this->assertEquals($pReference, $pResult);
$this->assertEquals($rows, $pResult);
}

/**
*
* @return Generator
* @return array
*
*/

public function dataProviderField(): Generator
public function dataProviderField()
{
$pField = new Field('testField', 'testModule');
$rows = [
[123, ['customs_labels_id' => 1337, 'locale' => 'de_DE', 'value' => 'Deutschland', 'fieldname' => 'testField']]
];

$rows = [];
$pReference1 = new CustomLabelModelField(12, $pField);
yield [12, $rows, $pReference1];
$pReference2 = new CustomLabelModelField(13, $pField);
$pReference2->addValueByLocale('de_DE', 'Deutschland');
$pReference2->addValueByLocale('en_US', 'United States');
$pReference2->addValueByLocale('fr_BE', 'Belgique');
return $rows;
}

$rows = [
(object)[
'customs_labels_id' => 1337,
'locale' => 'de_DE',
'value' => 'Deutschland',
],
/**
*
*/
public function testGetCustomLabelsFieldsForAdmin()
{
$pField = new Field('testField', 'testModule');
$row = [
(object)[
'customs_labels_id' => 1338,
'defaults_id' => '13',
'value' => 'Spider Man',
'fieldname' => 'testField',
'type' => 'text',
'locale' => 'en_US',
'value' => 'United States',
],
(object)[
'customs_labels_id' => 1339,
'locale' => 'fr_BE',
'value' => 'Belgique',
],
];
yield [13, $rows, $pReference2];
}

$this->_pWPDBMock->expects($this->once())->method('get_results')->will($this->returnValue($row));
$result = $this->_pSubject->getCustomLabelsFieldsForAdmin(13, [$pField], 'en_US', 'oo_plugin_fieldconfig_form_customs_labels','oo_plugin_fieldconfig_form_translated_labels');

$this->assertEquals(['testField' => ['native' => 'Spider Man']], $result);
}
}

0 comments on commit c8a8382

Please sign in to comment.