function test_store_user_social_profile()
 {
     $insert_id = wsl_store_hybridauth_user_profile($this->someUserID, $this->someUserIDP, $this->someUserProfile);
     $profile = (array) wsl_get_stored_hybridauth_user_profiles_by_user_id($this->someUserID);
     $this->assertEquals(1, count($profile));
     $this->assertEquals($this->someUserID, $profile[0]->user_id);
     $this->assertEquals($this->someUserIDP, $profile[0]->provider);
     $this->assertEquals($this->someUserProfile->identifier, $profile[0]->identifier);
     $this->assertEquals($this->someUserProfile->email, $profile[0]->email);
     $this->assertEquals($this->someUserProfile->emailVerified, $profile[0]->emailverified);
     $profile = (array) wsl_get_stored_hybridauth_user_id_by_email_verified($this->someUserProfile->emailVerified);
     $this->assertEquals(1, count($profile));
     $profile = (array) wsl_get_stored_hybridauth_user_id_by_provider_and_provider_uid($this->someUserIDP, $this->someUserProfile->identifier);
     $this->assertEquals(1, count($profile));
     $user_id = wsl_get_stored_hybridauth_user_id_by_provider_and_provider_uid($this->someUserIDP, $this->someUserProfile->identifier);
     $this->assertEquals($this->someUserID, $user_id);
     $count = wsl_get_wsl_users_count();
     $this->assertEquals(1, $count);
     $count = wsl_get_stored_hybridauth_user_profiles_count();
     $this->assertEquals(1, $count);
 }
function wsl_component_networks_sidebar_basic_insights()
{
    global $WORDPRESS_SOCIAL_LOGIN_PROVIDERS_CONFIG;
    $assets_base_url = WORDPRESS_SOCIAL_LOGIN_PLUGIN_URL . 'assets/img/32x32/icondock/';
    ?>
<div class="postbox">
	<div class="inside">
		<h3><?php 
    _wsl_e("Insights", 'wordpress-social-login');
    ?>
</h3>

		<div style="padding:0 20px">
			<?php 
    $total_users = wsl_get_wordpess_users_count();
    $total_users_wsl = wsl_get_wsl_users_count();
    if ($total_users && $total_users_wsl) {
        $users_conversion = 100 * $total_users_wsl / $total_users;
        ?>
						<!-- Insights - conversions -->
						<h4 style="border-bottom:1px solid #ccc"><?php 
        _wsl_e("Conversions", 'wordpress-social-login');
        ?>
</h4>
						<table width="90%">
							<tr>
								<td width="60%"><?php 
        _wsl_e("WP users", 'wordpress-social-login');
        ?>
</td><td><?php 
        echo $total_users;
        ?>
</td>
							</tr>
							<tr>
								<td><?php 
        _wsl_e("WSL users", 'wordpress-social-login');
        ?>
</td><td><?php 
        echo $total_users_wsl;
        ?>
</td>
							</tr>
							<tr>
								<td><?php 
        _wsl_e("Conversions", 'wordpress-social-login');
        ?>
</td><td style="border-top:1px solid #ccc">+<b><?php 
        echo number_format($users_conversion, 2, '.', '');
        ?>
</b> %</td>
							</tr>
						</table>

						<!-- Insights by provider -->
						<?php 
        $data = wsl_get_stored_hybridauth_user_profiles_count_by_field('provider');
        ?>
						<h4 style="border-bottom:1px solid #ccc"><?php 
        _wsl_e("By provider", 'wordpress-social-login');
        ?>
</h4>
						<table width="90%">
							<?php 
        $total_profiles_wsl = 0;
        foreach ($data as $item) {
            ?>
									<tr>
										<td width="60%">
											<img src="<?php 
            echo $assets_base_url . strtolower($item->provider) . '.png';
            ?>
" style="vertical-align:top;width:16px;height:16px;" /> <?php 
            _wsl_e($item->provider, 'wordpress-social-login');
            ?>
										</td>
										<td>
											<?php 
            echo $item->items;
            ?>
										</td>
									</tr>
								<?php 
            $total_profiles_wsl += (int) $item->items;
        }
        ?>
							<tr>
								<td align="right">&nbsp;</td><td style="border-top:1px solid #ccc"><b><?php 
        echo $total_profiles_wsl;
        ?>
</b> <?php 
        _wsl_e("WSL profiles", 'wordpress-social-login');
        ?>
</td>
							</tr>
							<tr>
								<td align="right">&nbsp;</td><td><b><?php 
        echo $total_users_wsl;
        ?>
</b> <?php 
        _wsl_e("WSL users", 'wordpress-social-login');
        ?>
</td>
							</tr>
						</table>

						<!-- Insights by gender -->
						<?php 
        $data = wsl_get_stored_hybridauth_user_profiles_count_by_field('gender');
        ?>
						<h4 style="border-bottom:1px solid #ccc"><?php 
        _wsl_e("By gender", 'wordpress-social-login');
        ?>
</h4>
						<table width="90%">
							<?php 
        foreach ($data as $item) {
            if (!$item->gender) {
                $item->gender = "Unknown";
            }
            ?>
									<tr>
										<td width="60%">
											<?php 
            echo ucfirst($item->gender);
            ?>
										</td>
										<td>
											<?php 
            echo $item->items;
            ?>
										</td>
									</tr>
								<?php 
        }
        ?>
						</table>

						<!-- Insights by age -->
						<?php 
        $data = wsl_get_stored_hybridauth_user_profiles_count_by_field('age');
        ?>
						<h4 style="border-bottom:1px solid #ccc"><?php 
        _wsl_e("By age", 'wordpress-social-login');
        ?>
</h4>
						<table width="90%">
							<?php 
        foreach ($data as $item) {
            if (!$item->age) {
                $item->age = "Unknown";
            }
            ?>
									<tr>
										<td width="60%">
											<?php 
            echo ucfirst($item->age);
            ?>
										</td>
										<td>
											<?php 
            echo $item->items;
            ?>
										</td>
									</tr>
								<?php 
        }
        ?>
						</table>
					<?php 
    } else {
        ?>
						<p>
							<?php 
        _wsl_e("There's no data yet", 'wordpress-social-login');
        ?>
.
						</p>
					<?php 
    }
    ?>
		</div>
	</div>
</div>
<?php 
}