Skip to content

Commit

Permalink
Fixed some tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
peterborodatyy committed Aug 29, 2017
1 parent eb8f0c4 commit e4935d2
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 19 deletions.
16 changes: 7 additions & 9 deletions tests/autoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ class Autoloader
/**
* @param string $baseDirectory Base directory where the source files are located.
*/
public function __construct($baseDirectory = __DIR__)
{
public function __construct($baseDirectory = __DIR__) {
$this->directory = $baseDirectory;
$this->prefix = __NAMESPACE__.'\\';
$this->prefix = 'Mintance\\';
$this->prefixLength = strlen($this->prefix);
}

Expand All @@ -21,8 +20,7 @@ public function __construct($baseDirectory = __DIR__)
*
* @param bool $prepend Prepend the autoloader on the stack instead of appending it.
*/
public static function register($prepend = false)
{
public static function register($prepend = false) {
spl_autoload_register(array(new self(), 'autoload'), true, $prepend);
}

Expand All @@ -31,15 +29,15 @@ public static function register($prepend = false)
*
* @param string $className Fully qualified name of a class.
*/
public function autoload($className)
{
public function autoload($className) {
if (0 === strpos($className, $this->prefix)) {
$parts = explode('\\', substr($className, $this->prefixLength));
$filepath = $this->directory.DIRECTORY_SEPARATOR.implode(DIRECTORY_SEPARATOR, $parts).'.php';

$filepath = $this->directory.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.implode(DIRECTORY_SEPARATOR, $parts).'.php';
if (is_file($filepath)) {
require $filepath;
}
}
}
}

Autoloader::register();
16 changes: 10 additions & 6 deletions tests/simple-event.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<?php
/**
* Created by PhpStorm.
* User: peterborodatyy
* Date: 4/2/17
* Time: 02:20
*/

require_once 'autoloader.php';

$mintance = new \Mintance\Mintance('d3be88e277c4d7a3b9f92c262d90683c1e49e5a1d50c464f771e264de43f56be', [
'url' => 'api.mintance.dev',
'protocol' => 'http'
]);

$mintance->track('Test Event');

25 changes: 21 additions & 4 deletions tests/track-custom-people-id.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
<?php

$people_id = rand(1, 100); // Id from e-commerce site.
require_once 'autoloader.php';

$mintance = new \Mintance\Mintance('API_KEY');
$mintance = new \Mintance\Mintance('d3be88e277c4d7a3b9f92c262d90683c1e49e5a1d50c464f771e264de43f56be', [
'url' => 'api.mintance.dev',
'protocol' => 'http'
]);


$people_id = '123'; // Id from e-commerce site.

$mintance->people->setIdentifier($people_id);
//
//$mintance->track('Add to Cart', [
// 'product_id' => 1
//]);
//
//if($mintance->people->get()['id'] != '58e0be1f48177e953b8b473d') {
// throw new \Exception('Invalid people_id');
//}


$mintance->track('Add to Cart', [
'product_id' => 1
$mintance->people->set([
'email' => 'test@email.com',
'name' => '',
'phone' => '23'
]);

0 comments on commit e4935d2

Please sign in to comment.