From 132b0fca1c9bfafd24b57baed016aefdfeed26d0 Mon Sep 17 00:00:00 2001 From: nathangray Date: Thu, 15 Nov 2018 15:11:52 -0700 Subject: [PATCH] Change tests to try and make Widget scan happy --- .../Etemplate/Widget/ContactEntryTest.php | 13 -- api/tests/Etemplate/Widget/EntryTest.php | 138 ------------------ 2 files changed, 151 deletions(-) delete mode 100644 api/tests/Etemplate/Widget/EntryTest.php diff --git a/api/tests/Etemplate/Widget/ContactEntryTest.php b/api/tests/Etemplate/Widget/ContactEntryTest.php index db65bb3f79..b130baf026 100644 --- a/api/tests/Etemplate/Widget/ContactEntryTest.php +++ b/api/tests/Etemplate/Widget/ContactEntryTest.php @@ -124,16 +124,3 @@ class EntryTest extends \EGroupware\Api\Etemplate\WidgetBaseTest { return $element_id; } } - -/** - * Testable entry widget - */ -class EntryTestWidget extends \EGroupware\Api\Etemplate\Widget\Entry -{ - public function get_entry($value, array $attrs) - { - $entry = EntryTest::getEntry($value, $attrs); - - return $entry; - } -} \ No newline at end of file diff --git a/api/tests/Etemplate/Widget/EntryTest.php b/api/tests/Etemplate/Widget/EntryTest.php deleted file mode 100644 index 3d8bcddc7f..0000000000 --- a/api/tests/Etemplate/Widget/EntryTest.php +++ /dev/null @@ -1,138 +0,0 @@ - 7, - 'entry_field_1' => 'Field 1', - 'entry_field_2' => 'Field 2', - 'entry_field_3' => 'Field 3', - 'entry_num_1' => 1, - 'entry_num_2' => 2, - 'entry_num_3' => 3, - 'entry_date' => '2018-11-12' - ); - return $entry[$value]; - } - /** - * Test that the correct value is extracted, based on the value attribute, - * or if it is missing try the ID - */ - public function testValueAttr() - { - // Instanciate the template - $etemplate = new Etemplate(); - $etemplate->read(static::TEST_TEMPLATE, 'test'); - - // Content - entry ID is important, it should match what getEntry() gives - $content = array( - 'entry_id' => '7', - 'not_entry_id' => '123' - ); - - $result = $this->mockedExec($etemplate, $content); - $data = array(); - foreach($result as $response) - { - if($response['type'] == 'et2_load') - { - $data = $response['data']['data']; - break; - } - } - - // Check that the entry was found - $this->assertNotEmpty($data['content'][Entry::ID_PREFIX.'widget']); - $this->assertNotEmpty($data['content'][Entry::ID_PREFIX.'entry_id']); - - // Check that the entry was not found - $this->assertEmpty($data['content'][Entry::ID_PREFIX.'no_value']); - - // Check that the value is present - exact value is pulled client side - $this->assertNotEmpty($data['content'][Entry::ID_PREFIX.'widget']['entry_field_1']); - $this->assertNotEmpty($data['content'][Entry::ID_PREFIX.'entry_id']['entry_field_2']); - - // No errors - $this->assertEmpty($data['validation_errors']); - } - - /** - * Check on compare attribute. - * Actual comparison is done client side, but here we check that the value is found. - */ - public function testCompareAttr() - { - // Instanciate the template - $etemplate = new Etemplate(); - $etemplate->read(static::TEST_TEMPLATE, 'test'); - - // Content - entry ID is important, it should match what getEntry() gives - $content = array( - 'entry_id' => '7', - ); - - $result = $this->mockedExec($etemplate, $content); - $data = array(); - foreach($result as $response) - { - if($response['type'] == 'et2_load') - { - $data = $response['data']['data']; - break; - } - } - - // Check that the value is present - exact value is pulled client side - $this->assertNotEmpty($data['content'][Entry::ID_PREFIX.'compare']['entry_num_1']); - } -} - -/** - * Testable entry widget - */ -class EntryTestWidget extends \EGroupware\Api\Etemplate\Widget\Entry -{ - public function get_entry($value, array $attrs) - { - $entry = EntryTest::getEntry($value, $attrs); - - return $entry; - } -} \ No newline at end of file