SObjectTest.php in Salesforce Suite 5.0.x
File
tests/src/Unit/SObjectTest.php
View source
<?php
namespace Drupal\Tests\salesforce\Unit;
use Drupal\Tests\UnitTestCase;
use Drupal\salesforce\SObject;
class SObjectTest extends UnitTestCase {
protected static $modules = [
'salesforce',
];
public function testObject() {
$sobject = new SObject([
'id' => '1234567890abcde',
'attributes' => [
'type' => 'dummy',
],
]);
$this
->assertTrue($sobject instanceof SObject);
$this
->assertEquals('1234567890abcdeAAA', $sobject
->id());
}
public function testObjectNoId() {
$this
->expectException(\Exception::class);
new SObject([
'attributes' => [
'type' => 'dummy',
],
]);
}
public function testObjectBadId() {
$this
->expectException(\Exception::class);
new SObject([
'id' => '1234567890',
'attributes' => [
'type' => 'dummy',
],
]);
}
public function testObjectNoType() {
$this
->expectException(\Exception::class);
new SObject([
'id' => '1234567890abcde',
]);
}
public function testFieldNotExists() {
$sobject = new SObject([
'id' => '1234567890abcde',
'attributes' => [
'type' => 'dummy',
],
]);
$this
->assertNull($sobject
->field('key'));
}
public function testFieldExists() {
$sobject = new SObject([
'id' => '1234567890abcde',
'attributes' => [
'type' => 'dummy',
],
'name' => 'Example',
]);
$this
->assertEquals('Example', $sobject
->field('name'));
}
}