-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Vendor class
shop_data
persistence is broken on save()
- Loading branch information
Showing
2 changed files
with
44 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
namespace Vendor; | ||
|
||
use WeDevs\Dokan\Vendor\Vendor; | ||
|
||
class UserToVendorTest extends \WP_UnitTestCase { | ||
|
||
/** | ||
* Check vendor class persists `shop_data` on save. | ||
* | ||
* @test | ||
*/ | ||
public function test_vendor_data_is_persisted_on_save() { | ||
$user = $this->factory()->user->create_and_get(); | ||
|
||
$data = [ | ||
'shopurl' => '', | ||
'fname' => 'John', | ||
'lname' => 'Doe', | ||
'shopname' => 'My Shop', | ||
'phone' => '+00000000000000', | ||
'address' => 'My Address', | ||
]; | ||
|
||
add_action( 'dokan_new_seller_created', function ( $user_id, $vendor_info ) use ( $data ) { | ||
$this->assertEquals( $data['shopname'], $vendor_info['store_name'] ); | ||
$this->assertEquals( $data['phone'], $vendor_info['phone'] ); | ||
}, 10, 2); | ||
|
||
dokan_user_update_to_seller( $user, $data ); | ||
|
||
$vendor = new Vendor( $user->ID ); | ||
$shop_info = $vendor->get_shop_info(); | ||
$this->assertEquals( $data['shopname'], $shop_info['store_name'] ); | ||
$this->assertEquals( $data['phone'], $shop_info['phone'] ); | ||
|
||
$this->assertTrue( !!did_action( 'dokan_new_seller_created' ) ); | ||
} | ||
} | ||
|