Skip to content
This repository has been archived by the owner on Feb 8, 2023. It is now read-only.

Commit

Permalink
fix Call to a member function getValue() on string
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas GASC committed Nov 3, 2016
1 parent e987528 commit c8baee0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/Transport.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function subscribe(Properties $user, $idKey = 'ID')
case Response::SUCCESSFUL:
$properties = $response->getProperties();
if (isset($properties[$idKey])) {
$id = $properties[$idKey]->getValue();
$id = $properties[$idKey];
break;
} else {
throw new \UnexpectedValueException(sprintf(
Expand Down
28 changes: 24 additions & 4 deletions tests/CampaignTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,25 @@ public function testCampaign()
$list_id = getenv('selligent_listid');
$gate_name = getenv('selligent_gate');
$client = $this->getCLient();
$user_id = null;

$user = new Properties();
$user['NAME'] = 'Thomas Test G.';
$user['NAME'] = 'Thomas G.';
$user['MAIL'] = 'thomas.gasc+test@mediapart.fr';

// check the connection
$response = $client->GetSystemStatus();
$this->assertEquals('OK', $response->getStatus());
$this->assertEquals(Response::SUCCESSFUL, $response->getCode());

// check the list
$response = $client->GetLists();
$available_lists = [];
foreach ($response->getLists() as $list) {
$available_lists[$list->ID] = $list->Name;
}
$this->assertTrue(array_key_exists($list_id, $available_lists));

// check if the user already exists
$response = $client->GetUserByFilter([
'List' => $list_id,
Expand All @@ -66,7 +75,7 @@ public function testCampaign()
}

// retrieves the user id
if (Response::SUCCESSFUL !== $response) {
elseif (Response::SUCCESSFUL === $response->getCode()) {
$user_id = $response->getProperties()['ID']->getValue();
}

Expand All @@ -75,15 +84,26 @@ public function testCampaign()

// trigger the campaign
$data = new Properties();
$data['ID_UTILISATEUR'] = $user_id;
$data['ID'] = $user_id;
$data['TRANSAC.PRENOM_ACHETEUR'] = "prenom_acheteur";
$data['TRANSAC.NOM_ACHETEUR'] = "nom_acheteur";
$data['TRANSAC.PRENOM'] = "prenom";
$data['TRANSAC.NOM'] = "nom";
$data['TRANSAC.MESSAGE'] = "message";
$data['TRANSAC.DOMAINE'] = "domaine";
$data['TRANSAC.LINK'] = "link";
$data['TRANSAC.IDABONNEMENT'] = "idabonnement";
$data['TRANSAC.EMAIL'] = "email";
$data['TRANSAC.EMAIL_ACHETEUR'] = "email_acheteur";

$response = $client->TriggerCampaign([
$response = $client->TriggerCampaignWithResult([
'List' => $list_id,
'UserID' => $user_id,
'GateName' => $gate_name,
'InputData' => $data,
]);

$this->assertEquals(Response::SUCCESSFUL, $response->getCode());
$this->assertEquals('[OK]', $response->getResult());
}
}
6 changes: 3 additions & 3 deletions tests/TransportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ protected function buildClientForSubscribe($listId, $listName, $campaign, $user,
->method('getCode')
->willReturn($CreateUserResponseCode)
;
$id = isset($userProperties['ID']) ? $userProperties['ID']->getValue() : null;
$id = isset($userProperties['ID']) ? $userProperties['ID'] : null;
$CreateUserResponse
->method('getUserId')
->willReturn($id)
Expand Down Expand Up @@ -311,7 +311,7 @@ public function testSubscribeWithExistingUser()

$id = $transport->subscribe($user);

$this->assertEquals($userProperties['ID']->getValue(), $id);
$this->assertEquals($userProperties['ID'], $id);
}

/**
Expand Down Expand Up @@ -392,7 +392,7 @@ public function testSubscribeAndCreatingUser()

$id = $transport->subscribe($user);

$this->assertEquals($userProperties['ID']->getValue(), $id);
$this->assertEquals($userProperties['ID'], $id);
}

/**
Expand Down

0 comments on commit c8baee0

Please sign in to comment.