You are here

public function ServicesClientPluginsTestCase::testServicesClientPropertyReader in Services Client 7.2

File

tests/plugin.test, line 202
Rules tests.

Class

ServicesClientPluginsTestCase
@file Rules tests.

Code

public function testServicesClientPropertyReader() {
  $event = $this
    ->createFakeEvent();
  $reader = new ServicesClientPropertyReader($event, $event->config);
  $this
    ->assertIdentical("[PropertyReader - not configured]", $reader
    ->getSummary(), "Not configured property reader returns correct summary");
  $reader
    ->setConfiguration(array(
    'property' => 'test',
  ));
  $this
    ->assertIdentical("\$source-><b>test</b>", $reader
    ->getSummary(), "Configured property reader returns correct summary");
  $fake_entity = new stdClass();
  $result = $reader
    ->read($fake_entity);
  $this
    ->assertIdentical(get_class($result), "ServicesClientMappingValue", "Property reader returns correct result object.");
  $this
    ->assertIdentical($result
    ->isEmpty(), TRUE, "Non existing property will result in empty value");
  $fake_entity->different_property = 1;
  $result = $reader
    ->read($fake_entity);
  $this
    ->assertIdentical($result
    ->isEmpty(), TRUE, "Non existing property will result in empty value");
  $fake_entity->test = 1;
  $result = $reader
    ->read($fake_entity);
  $this
    ->assertIdentical($result
    ->isEmpty(), FALSE, "Existing property will result in non empty value");
  $this
    ->assertIdentical($result
    ->getValue(), array(
    1,
  ), "Array value is returned from simple property.");
  $fake_entity->test = array(
    1,
    2,
  );
  $result = $reader
    ->read($fake_entity);
  $this
    ->assertIdentical($result
    ->getValue(), array(
    1,
    2,
  ), "Array value is returned from array property.");
}