Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kasparsd committed Dec 16, 2024
1 parent 424fded commit 8e46b7c
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions tests/phpunit/class-integration-tablepress-test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

use SebastianBergmann\RecursionContext\InvalidArgumentException;
use PHPUnit\Framework\ExpectationFailedException;

/**
* Test the main plugin class.
*/
class Integration_TablePress_Test extends WP_UnitTestCase {

/**
* Can merge form data with table data.
*/
public function test_can_merge_new_fields() {
$integration = new Cf7_Extras_Integration_TablePress();

$table = [
'data' => [
[
'',
'header cell',
],
[
'first_name',
''
]
]
];

$form_data = [
'first_name' => 'John ',
'age' => '25',
'food_preferences' => [
'pizza',
'pasta',
],
];

$this->assertEquals(
[
[ '', 'header cell', 'first_name', 'age', 'food_preferences' ],
[ 'first_name', '', '', '', '' ],
[ '', '', 'John ', '25', 'pizza, pasta' ],
],
$integration->get_data_for_table( $table, $form_data )['data']
);
}
}

0 comments on commit 8e46b7c

Please sign in to comment.