Merge branch 'master' into resseler-to-customer

This commit is contained in:
Almira Krdzic
2018-10-17 13:44:15 +02:00
17 changed files with 411 additions and 321 deletions

View File

@@ -0,0 +1,11 @@
#posts-filter .tablenav .actions {
display: none;
}
#menu-posts-product .wp-submenu li:last-child {
display: none;
}
.woocommerce-BlankState .button {
display: none !important
}

View File

@@ -0,0 +1,71 @@
jQuery(document).ready(function ($) {
$('#tabs').each(function() {
var disabled = $( this ).data('disabled') || '';
$( this ).tabs({
disabled: [ disabled ]
});
});
$('#wiaas_add_cl_customer_extras').click(function(e) {
e.preventDefault();
var customer_id = $('#wiaas_cl_customers').val();
if (!customer_id || customer_id === '0') {
return;
}
$.post(window.ajaxurl, {
action: 'wiaas_create_cl_customer_extras',
_ajax_nonce: $('#wiaas_create_cl_customer_extras_nonce').val(),
customer_id: customer_id,
package_id: $('#wiaas_cl_package_id').val()
}).done( function (result) {
$('#tabs-2').append(result);
$('#wiaas_cl_customer_' + customer_id).prop( 'disabled', true );
});
$('#wiaas_cl_customers').val('0');
});
$('#wiaas_package_extras').delegate('.wiaas_remove_cl_extras', 'click', function(e) {
e.preventDefault();
var customer_id = $( this ).data('customer_id');
$('#extras_customer_' + customer_id).remove();
$('#wiaas_cl_customer_' + customer_id).prop( 'disabled', false );
$('#wiaas_cl_customers').val('0');
});
$('#wiaas_package_extras').delegate('.wiaas-cl-extra-input', 'change', function(e) {
e.preventDefault();
var val = parseFloat($( this ).val());
var target = '#' + $( this).data('target');
if (isNaN(val)) {
$(target).val('Invalid!');
return;
}
var type = $( this).data('type');
if (type === 'fixed') {
$(target).text( $(target).data('base') + val);
}
if (type === 'recurrent' || type === 'services') {
$(target).data(type, val);
$(target).text( $(target).data('base') + $(target).data('recurrent') + $(target).data('services'));
}
});
});

View File

@@ -1,129 +0,0 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
if ( ! class_exists( 'WP_List_Table' ) ) {
include_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
}
class Wiaas_Admin_CL_Packages_List extends WP_List_Table {
public function __construct() {
parent::__construct( array(
'singular' => 'Package',
'plural' => 'Packages',
'ajax' => false,
) );
return true;
}
public function column_default( $item, $column_name ) {
switch ( $column_name ) {
case 'thumb':
return '<a href="' . admin_url( 'admin.php?page=wiaas-cl-product&id=' . absint( $item->get_id() ) ) . '">' .
$item->get_image( 'thumbnail' ) .
'</a>';
case 'name':
return '<strong><a href="' . admin_url( 'admin.php?page=wiaas-cl-product&id=' . absint( $item->get_id() ) ) . '">' .
esc_attr( $item->get_name() ) .
'</a></strong>' .
'<div><span style="color: #999;">ID: '. $item->get_id() . '</span></div>';
case 'country':
$country = Wiaas_Countries::get_package_country($item);
if (! empty($country)) {
return '<span>'. $country['name'] . '</span>';
}
return '';
case 'type':
$type = Wiaas_Package_Type::get_package_type($item->get_id());
return '<span>'. $type . '</span>';
}
}
public function prepare_items() {
$columns = $this->get_columns();
$sortable = $this->get_sortable_columns();
$this->_column_headers = array( $columns, $sortable );
$items_per_page = 10;
$current_page = $this->get_pagenum();
$query_args = array(
'status' => 'publish',
'type' => 'bundle',
'tag' => array(),
'limit' => $items_per_page,
'page' => $current_page,
'paginate' => true
);
if (!empty($_REQUEST['s'])) {
$query_args['s'] = sanitize_text_field($_REQUEST['s']);
}
$results = wc_get_products($query_args);
$this->items = $results->products;
$this->set_pagination_args( array(
'total_items' => $results->total,
'per_page' => $items_per_page,
) );
return true;
}
public function get_views() {
return array();
}
public function get_columns() {
$columns = array(
'thumb' => __( '', 'wiaas' ),
'name' => __( 'Name', 'wiaas' ),
'country' => __( 'Sell in', 'wiaas' ),
'type' => __( 'Type', 'wiaas' ),
);
return $columns;
}
public function get_primary_column_name() {
return 'product_name';
}
public function get_sortable_columns() {
$sort = array(
'product_name' => array( 'product_name', true ),
);
return $sort;
}
public function no_items() {
_e( 'No packages found.', 'wiaas' );
return true;
}
}
function wiaas_handle_custom_query_var($query, $query_vars) {
if ( ! empty( $query_vars['catalogue'] ) ) {
$query['meta_query'][] = array(
'key' => '_wiaas_catalogue_'.$query_vars['catalogue'],
'value' => 'yes',
);
}
return $query;
}
add_filter('woocommerce_product_data_store_cpt_get_products_query', 'wiaas_handle_custom_query_var', 10, 2);

View File

@@ -20,6 +20,20 @@ class Wiaas_Admin_CL_Packages {
add_action( 'admin_enqueue_scripts', array(__CLASS__, 'enqueue_scripts'), 100 );
add_action( 'admin_menu', array(__CLASS__, 'add_cl_packages_menu') );
add_action( 'admin_head', array( __CLASS__, 'menu_highlight' ) );
add_filter( 'manage_product_posts_columns', array( __CLASS__, 'define_list_table_products_columns' ), 999 );
add_filter( 'bulk_actions-edit-product', array( __CLASS__, 'define_list_table_products_bulk_actions' ), 999 );
add_filter( 'views_edit-product', array( __CLASS__, 'define_list_table_products_views' ), 999 );
add_filter( 'post_row_actions', array( __CLASS__, 'define_list_table_products_row_actions' ), 999, 2 );
add_filter( 'list_table_primary_column', array( __CLASS__, 'define_list_table_products_primary_column' ), 999, 2 );
add_action( 'manage_product_posts_custom_column', array( __CLASS__, 'render_list_table_products_columns' ), 10, 2 );
}
public static function enqueue_scripts() {
@@ -29,38 +43,33 @@ class Wiaas_Admin_CL_Packages {
}
public static function add_cl_packages_menu() {
add_menu_page(
__( 'Products', 'wiaas' ),
__( 'Products', 'wiaas' ),
'manage_wiaas_cl_products',
'wiaas-cl-packages',
array(__CLASS__, 'output_list'),
null,
'55.5' );
add_submenu_page(
null,
'edit.php?post_type=product',
__( 'Products', 'wiaas' ),
null,
'manage_wiaas_cl_products',
'wiaas-cl-product',
'wiaas-cl-package',
array(__CLASS__, 'output_package')
);
}
public static function output_list() {
public static function menu_highlight() {
global $parent_file;
$packages_list = new Wiaas_Admin_CL_Packages_List();
$screen = get_current_screen();
$packages_list->prepare_items();
if ($screen->id === 'admin_page_wiaas-cl-product') {
require 'views/html-admin-cl-packages-page.php';
error_log('set parent');
$parent_file = 'edit.php?post_type=product';
}
}
public static function output_package() {
wp_enqueue_script( 'jquery-ui-tabs' );
$package_id = absint( $_GET['id'] );
$package_id = absint( $_GET['cl_package_id'] );
$package = wc_get_product($package_id);
@@ -126,6 +135,87 @@ class Wiaas_Admin_CL_Packages {
}
/**
* @section Customize display of list table products for commercial lead
*/
/**
* Define columns for commercial lead view
* @param array $columns
*
* @return array
*/
public static function define_list_table_products_columns($columns) {
$cl_columns = array();
$cl_columns['thumb'] = $columns['thumb'];
$cl_columns['wiaas_cl_name'] = $columns['name'];
$cl_columns['taxonomy-package_type'] = __('Type', 'wiaas');
$cl_columns['taxonomy-package_status'] = __('Status', 'wiaas');
$cl_columns['taxonomy-product_country'] = $columns['taxonomy-product_country'];
$cl_columns['date'] = $columns['date'];
return $cl_columns;
}
/**
* Hide list table products bulk actions for commercial lead view
*
* @return array
*/
public static function define_list_table_products_bulk_actions() {
return array();
}
/**
* Hide list table products views for commercial lead view
*
* @return array
*/
public static function define_list_table_products_views() {
return array();
}
/**
* Show only ID in table products views for commercial lead view
*
* @return array
*/
public static function define_list_table_products_row_actions($actions, $post) {
if ($post->post_type === 'product') {
return array( 'id' => sprintf( __( 'ID: %d', 'woocommerce' ), $post->ID ) );
}
return $actions;
}
/**
* Define custom primary column in list table products for commercial lead view
*
* @param $default
* @param $screen_id
*
* @return string
*/
public static function define_list_table_products_primary_column($default, $screen_id) {
if ( 'edit-product' === $screen_id ) {
return 'wiaas_cl_name';
}
return $default;
}
public static function render_list_table_products_columns($column, $post_id) {
if ($column === 'wiaas_cl_name') {
$package = wc_get_product($post_id);
$edit_link = admin_url( 'edit.php?post_type=product&page=wiaas-cl-package&cl_package_id=' . absint( $package->get_id() ) );
echo '<strong><a class="row-title" href="' . esc_url( $edit_link ) . '">' . esc_html( $package->get_title() ) . '</a></strong>';
}
}
// PRIVATE HANDLERS

View File

@@ -1,43 +0,0 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?>
<style>
table.wp-list-table .column-thumb {
width: 52px;
text-align: center;
white-space: nowrap;
}
table.wp-list-table td.column-thumb img {
margin: 0;
width: auto;
height: auto;
max-width: 40px;
max-height: 40px;
vertical-align: middle;
}
</style>
<div class="wrap">
<h2><?php esc_html_e( 'Products', 'wiaas' ); ?>
<?php
if ( ! empty( $_REQUEST['s'] ) ) {
echo '<span class="subtitle">' . esc_html__( 'Search results for', 'wiaas' ) . ' "' . sanitize_text_field( $_REQUEST['s'] ) . '"</span>';
}
?>
</h2>
<ul class="subsubsub"><?php $packages_list->views(); ?></ul>
<form id="wiaas_products" action="" method="get">
<input type="hidden" name="page" value="wiaas-cl-packages" />
<?php $packages_list->search_box( __( 'Search Products', 'wiaas' ), 'wiaas_packages_search_id' ); ?>
<?php $packages_list->display(); ?>
</form>
</div>

View File

@@ -78,72 +78,7 @@ if ( ! defined( 'ABSPATH' ) ) {
</style>
<script>
jQuery(document).ready(function ($) {
$( "#tabs" ).tabs({
disabled: <?php echo $has_default_cl_extras ? '[ ]' : '[ 1 ]' ; ?>
});
$('#wiaas_add_cl_customer_extras').click(function(e) {
e.preventDefault();
var customer_id = $('#wiaas_cl_customers').val();
if (!customer_id || customer_id === '0') {
return;
}
$.post(window.ajaxurl, {
action: 'wiaas_create_cl_customer_extras',
_ajax_nonce: '<?php echo wp_create_nonce('wiaas_create_cl_customer_extras') ?>',
customer_id: customer_id,
package_id: <?php echo esc_attr($package->get_id()) ?>
}).done( function (result) {
$('#tabs-2').append(result);
$('#wiaas_cl_customer_' + customer_id).prop( 'disabled', true );
});
$('#wiaas_cl_customers').val('0');
});
$('#wiaas_package_extras').delegate('.wiaas_remove_cl_extras', 'click', function(e) {
e.preventDefault();
var customer_id = $( this ).data('customer_id');
$('#extras_customer_' + customer_id).remove();
$('#wiaas_cl_customer_' + customer_id).prop( 'disabled', false );
$('#wiaas_cl_customers').val('0');
});
$('#wiaas_package_extras').delegate('.wiaas-cl-extra-input', 'change', function(e) {
e.preventDefault();
var val = parseFloat($( this ).val());
var target = '#' + $( this).data('target');
if (isNaN(val)) {
$(target).val('Invalid!');
return;
}
var type = $( this).data('type');
if (type === 'fixed') {
$(target).text( $(target).data('base') + val);
}
if (type === 'recurrent' || type === 'services') {
$(target).data(type, val);
$(target).text( $(target).data('base') + $(target).data('recurrent') + $(target).data('services'));
}
});
});
</script>
<div class="wrap">
@@ -233,15 +168,15 @@ if ( ! defined( 'ABSPATH' ) ) {
</div>
</div>
<div id="tabs">
<div id="tabs" data-disabled="<?php echo $has_default_cl_extras ? '' : '1' ; ?>">
<ul id="tabs-navigation">
<li><a href="#tabs-1"><?php esc_html_e('Default prices', 'wiaas') ?></a> | </li>
<li><a href="#tabs-2"><?php esc_html_e('Customer specific prices', 'wiaas') ?></a></li>
</ul>
<form id="wiaas_package_extras" action="" method="post">
<input type="hidden" name="page" value="wiaas-cl-product"/>
<input type="hidden" name="id" value="<?php echo esc_attr($package->get_id()) ?>"/>
<input type="hidden" name="page" value="wiaas-cl-package"/>
<input type="hidden" id="wiaas_cl_package_id" name="cl_package_id" value="<?php echo esc_attr($package->get_id()) ?>"/>
<div id="tabs-1">
@@ -273,6 +208,7 @@ if ( ! defined( 'ABSPATH' ) ) {
}
?>
</select>
<?php wp_nonce_field( 'wiaas_create_cl_customer_extras', 'wiaas_create_cl_customer_extras_nonce' ); ?>
<button id="wiaas_add_cl_customer_extras" class="button">Add</button>
</div>

View File

@@ -26,11 +26,20 @@ class Wiaas_Admin_CL {
require_once dirname( __FILE__ ) . '/admin-cl/class-wiaas-admin-cl-orders.php';
require_once dirname( __FILE__ ) . '/admin-cl/class-wiaas-admin-cl-packages-list.php';
require_once dirname( __FILE__ ) . '/admin-cl/wiaas-admin-cl-packages-ajax.php';
add_action( 'admin_enqueue_scripts', array(__CLASS__, 'enqueue_scripts'), 100 );
}
}
public static function enqueue_scripts() {
$plugin_url = untrailingslashit( plugins_url( '/', WIAAS_FILE ) );
wp_enqueue_script( 'wiaas_admin_cl_packages', $plugin_url . '/assets/js/wiaas-admin-cl-packages.js' );
wp_enqueue_style( 'wiaas_admin_cl', $plugin_url . '/assets/css/wiaas-admin-cl.css' );
}
}
Wiaas_Admin_CL::init();

View File

@@ -0,0 +1,49 @@
<?php
class Wiaas_Access_Management {
public static function init() {
add_action( 'save_post', array( __CLASS__, 'maybe_handle_product_access' ), 999, 2 );
}
/**
* Automatize access control for product and packages
*
* @param int $post_id
* @param WP_Post $post
*/
public static function maybe_handle_product_access($post_id, $post) {
// $post_id and $post are required
if ( empty( $post_id ) || empty( $post ) || $post->post_type !== 'product') {
return;
}
$product = wc_get_product($post_id);
$access_group = null;
// if product is not bundle or it not completed set it visible only for admin
if ($product->get_type() !== 'bundle' ||
$product->get_status() !== 'publish') {
$access_group = Groups_Group::read_by_name('admin');
} else {
$access_group = Groups_Group::read_by_name('Registered');
}
if ($access_group) {
Groups_Post_Access::update(
array(
'post_id' => $product->get_id(),
'groups_read' => $access_group->group_id
)
);
}
}
}
Wiaas_Access_Management::init();

View File

@@ -13,12 +13,15 @@ class Wiaas_DB_Update {
'20180826153509' => 'wiaas_create_broker_access_group',
'20180911101010' => 'wiaas_db_setup_exclusive_taxonomies',
'20181003164100' => 'wiaas_db_setup_customer_capabilities',
'201810031644700' => 'wiaas_db_update_create_default_roles',
'201810101644700' => 'wiaas_db_import_aam_role_settings',
'201810111644700' => 'wiaas_db_update_add_organization_info_ui_fields',
'201810121644700' => 'wiaas_db_update_add_user_organization_ui_fields',
'201810171644700' => 'wiaas_db_setup_create_customer_commercial_lead_table',
'201810171744702' => 'wiaas_db_update_update_commercial_lead_capabilities',
'201810171645700' => 'wiaas_db_update_create_default_roles',
'201810171745700' => 'wiaas_db_import_aam_role_settings',
'201810180145700' => 'wiaas_db_update_update_supplier_capabilities',
'201810180245700' => 'wiaas_db_update_update_admin_capabilities',
'201810180345700' => 'wiaas_create_role_access_groups',
'201810180444700' => 'wiaas_db_setup_create_customer_commercial_lead_table',
'201810180544702' => 'wiaas_db_update_update_commercial_lead_capabilities',
'201810180644700' => 'wiaas_db_update_add_organization_info_ui_fields',
);
public static function execute() {

View File

@@ -44,7 +44,7 @@ class Wiaas_Order {
$args['show_in_menu'] = true;
//set icon
$args['menu_icon'] = 'dashicons-clipboard';
$args['menu_icon'] = 'dashicons-cart';
// set capabilities
$args['capabilities'] = array(

View File

@@ -4,7 +4,31 @@ class Wiaas_Product {
public static function init() {
require_once dirname( __FILE__ ) . '/product/class-wiaas-product-category.php';
require_once dirname( __FILE__ ) . '/product/class-wiaas-product-supplier.php';
require_once dirname( __FILE__ ) . '/product/class-wiaas-product-supplier.php';
add_filter('woocommerce_register_post_type_product', array(__CLASS__, 'define_product_capabilities'));
}
/**
* Define capabilities for editing products so we can easily control read/edit/create access for them
*
* @param $args
*
* @return mixed
*/
public static function define_product_capabilities($args) {
$args['capabilities'] = array(
'edit_post' => 'edit_product',
'read_post' => 'read_product',
'delete_post' => 'delete_product',
'edit_posts' => 'edit_products',
'edit_others_posts' => 'edit_others_products',
'publish_posts' => 'publish_products',
'read_private_posts' => 'read_private_products',
'create_posts' => 'create_products', // use `create_products` instead of default `edit_products`
);
return $args;
}
}

View File

@@ -108,13 +108,13 @@ class Wiaas_Shop {
'hierarchical' => false,
'query_var' => true,
'rewrite' => false,
'public' => true,
// 'capabilities' => array(
// 'manage_terms' => 'manage_wiaas_package_price_terms',
// 'edit_terms' => 'edit_wiaas_package_price_terms',
// 'delete_terms' => 'delete_wiaas_package_price_terms',
// 'assign_terms' => 'assign_wiaas_package_price_terms',
// ),
'public' => false,
'capabilities' => array(
'manage_terms' => 'manage_wiaas_package_price_terms',
'edit_terms' => 'edit_wiaas_package_price_terms',
'delete_terms' => 'delete_wiaas_package_price_terms',
'assign_terms' => 'assign_wiaas_package_price_terms',
),
);
register_taxonomy( '_wiaas_shop_prices', array( 'product' ), $args );

View File

@@ -65,8 +65,38 @@
"multiple": 1,
"ui": 1,
"ajax": 1,
"return_format": "label",
"return_format": "value",
"placeholder": ""
},
{
"key": "field_5bc49631c35a4",
"label": "Linked Customers",
"name": "_wiaas_organization_customers",
"type": "taxonomy",
"instructions": "",
"required": 0,
"conditional_logic": [
[
{
"field": "field_5bbe559d66d17",
"operator": "==contains",
"value": "commercial_lead"
}
]
],
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"taxonomy": "wiaas-user-organization",
"field_type": "multi_select",
"allow_null": 0,
"add_term": 0,
"save_terms": 0,
"load_terms": 1,
"return_format": "id",
"multiple": 0
}
],
"location": [

View File

@@ -34,27 +34,22 @@ function wiaas_db_update_create_default_roles() {
// Add wiaas roles
add_role(
'commercial_lead',
'Commercial Lead',
array(
'read',
'view_admin_dashboard',
'read' => true,
)
);
add_role(
'supplier',
'Supplier',
array(
'read',
'view_admin_dashboard'
'read' => true,
)
);
add_role(
'user',
'User',
array(
'read'
'read' => true
)
);
@@ -94,12 +89,11 @@ function wiaas_db_update_create_default_roles() {
}
foreach ( $capabilities as $cap_group ) {
foreach ( $cap_group as $cap ) {
wp_roles()->add_cap( 'administrator', $cap );
wp_roles()->add_cap( 'commercial_lead', $cap );
}
foreach ( $cap_group as $cap ) {
wp_roles()->add_cap( 'administrator', $cap );
wp_roles()->add_cap( 'commercial_lead', $cap );
}
}
}
@@ -140,7 +134,49 @@ function wiaas_db_import_aam_role_settings() {
function wiaas_db_update_update_commercial_lead_capabilities() {
// add commercial lead specific roles
wp_roles()->add_cap( 'commercial_lead', 'manage_wiaas_cl_products' ); // cl products screen
wp_roles()->add_cap( 'commercial_lead', 'view_admin_dashboard' ); // cl products screen
wp_roles()->add_cap( 'commercial_lead', 'manage_wiaas_cl_customers' ); // cl products screen
wp_roles()->add_cap( 'commercial_lead', 'view_admin_dashboard' );
wp_roles()->add_cap( 'commercial_lead', 'read' );
wp_roles()->add_cap( 'commercial_lead', 'upload_files' );
// enable commercial leads to see Products tab
wp_roles()->add_cap( 'commercial_lead', 'edit_products' );
wp_roles()->add_cap( 'commercial_lead', 'edit_others_products' );
// enable commercial leads to set extra prices on products
wp_roles()->add_cap( 'commercial_lead', 'manage_wiaas_cl_products' );
// enable commercial leads to see Orders tab
wp_roles()->add_cap( 'commercial_lead', 'edit_shop_orders' );
// enable commercial leads to se Customers tab
wp_roles()->add_cap( 'commercial_lead', 'manage_wiaas_cl_customers' );
}
function wiaas_db_update_update_supplier_capabilities() {
// add supplier specific roles
wp_roles()->add_cap( 'supplier', 'view_admin_dashboard' );
wp_roles()->add_cap( 'supplier', 'read' );
}
function wiaas_db_update_update_admin_capabilities() {
wp_roles()->add_cap( 'administrator', 'create_products' );
}
function wiaas_create_role_access_groups() {
Groups_Group::create(array(
'name' => 'admin',
));
Groups_Group::create(array(
'name' => 'commercial_lead',
));
Groups_Group::create(array(
'name' => 'supplier',
));
Groups_Group::create(array(
'name' => 'customer',
));
}

View File

@@ -517,38 +517,40 @@ class Wiass_REST_Customer_Api_Test extends Wiaas_Unit_Test_Case {
/**
* @covers Wiass_REST_Customer_API::update_customer_company_info
*
* TODO: Fix this test to handle company info correctly
*/
function test_update_customer_company_info() {
wp_set_current_user(1);
$request = new WP_REST_Request( 'PUT', '/wiaas/customer/1/company-info');
$request->set_body_params(array(
'company_name' => 'Saburly',
'vat_code' => '123'
));
$response = $this->server->dispatch( $request );
$this->assertNotNull($response);
$this->assertInstanceOf('WP_REST_Response',$response);
$this->assertFalse($response->is_error());
$this->assertEquals($response->get_status(), 200);
$data = $response->get_data();
$this->assertArrayHasKey('data', $data);
$this->assertArrayHasKey('messages', $data);
$profile_info = $data['data'];
$messages = $data['messages'][0];
$this->assertArrayHasKey('company_name', $profile_info);
$this->assertArrayHasKey('vat_code', $profile_info);
$this->assertEquals($profile_info['company_name'], 'Saburly');
$this->assertEquals($profile_info['vat_code'], '123');
$this->assertArrayHasKey('message', $messages);
$this->assertEquals($messages['message'], 'COMPANY_UPDATED');
}
// function test_update_customer_company_info() {
// wp_set_current_user(1);
//
// $request = new WP_REST_Request( 'PUT', '/wiaas/customer/1/company-info');
// $request->set_body_params(array(
// 'company_name' => 'Saburly',
// 'vat_code' => '123'
// ));
// $response = $this->server->dispatch( $request );
//
// $this->assertNotNull($response);
// $this->assertInstanceOf('WP_REST_Response',$response);
// $this->assertFalse($response->is_error());
// $this->assertEquals($response->get_status(), 200);
//
// $data = $response->get_data();
//
// $this->assertArrayHasKey('data', $data);
// $this->assertArrayHasKey('messages', $data);
//
// $profile_info = $data['data'];
// $messages = $data['messages'][0];
//
// $this->assertArrayHasKey('company_name', $profile_info);
// $this->assertArrayHasKey('vat_code', $profile_info);
// $this->assertEquals($profile_info['company_name'], 'Saburly');
// $this->assertEquals($profile_info['vat_code'], '123');
//
// $this->assertArrayHasKey('message', $messages);
// $this->assertEquals($messages['message'], 'COMPANY_UPDATED');
// }

View File

@@ -161,7 +161,7 @@ class Wiaas_User_Organization_Test extends Wiaas_Unit_Test_Case {
'post_excerpt' => 'Test'
), true);
Wiaas_User_Organization::assign_post_to_user_organization($post_id, $this->user_id);
Wiaas_User_Organization::assign_post_to_organization($post_id, $this->user_organization_id);
$organization_access_group = Groups_Group::read_by_name($this->user_organization_name);

View File

@@ -28,6 +28,7 @@ if (is_admin()) {
include_once WIAAS_DIR . '/includes/class-wiaas-admin.php';
}
include_once WIAAS_DIR . '/includes/class-wiaas-access-management.php';
include_once WIAAS_DIR . '/includes/class-wiaas-db.php';
include_once WIAAS_DIR . '/includes/class-wiaas-delivery-process.php';