Development

Changeset 6818 for plugins/sfAmazonSimpleDBPlugin/trunk/test

You must first sign up to be able to contribute.

Show
Ignore:
Timestamp:
12/29/07 22:44:41 (1 year ago)
Author:
nicolas
Message:

sfAmazonSimpleDBPlugin:

  • Added pagination capabilities
  • Removed unused files provided with the official Amazon SimpleDB PHP library
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfAmazonSimpleDBPlugin/trunk/test/unit/sfAmazonSimpleDBTest.php

    r6815 r6818  
    66require_once($sf_root.'/lib/symfony/vendor/lime/lime.php'); 
    77 
    8 $t = new lime_test(44, new lime_output_color()); 
     8$t = new lime_test(54, new lime_output_color()); 
    99 
    1010$service = sfAmazonSimpleDBClient::getInstance(); 
     
    1414try 
    1515{ 
    16   $domainCreation = $service->createDomain('sfAmazonSimpleDBPluginTestDomain'); 
    17   $t->ok($domainCreation, 'createDomain() confirms domain has been created'); 
     16  $domainCreation1 = $service->createDomain('sfAmazonSimpleDBPluginTestDomain'); 
     17  $domainCreation2 = $service->createDomain('sfAmazonSimpleDBPluginTestDomain2'); 
     18  $domainCreation3 = $service->createDomain('sfAmazonSimpleDBPluginTestDomain3'); 
     19  $t->ok($domainCreation1 && $domainCreation2 && $domainCreation3, 'createDomain() confirms domain has been created'); 
    1820  $t->pass('createDomain() does not throw an exception'); 
    1921} 
     
    2628try 
    2729{ 
    28   $domainsList = $service->listDomains(); 
     30  $domainsResults = $service->listDomains(); 
     31  $domainsList = $domainsResults['results']; 
    2932  $t->isa_ok($domainsList, 'array', 'listDomains() returns an array'); 
    3033  $t->ok(in_array('sfAmazonSimpleDBPluginTestDomain', $domainsList), 'listDomains() lists new created domain'); 
     34  $t->ok(in_array('sfAmazonSimpleDBPluginTestDomain2', $domainsList), 'listDomains() lists new created domain'); 
     35  $t->ok(in_array('sfAmazonSimpleDBPluginTestDomain3', $domainsList), 'listDomains() lists new created domain'); 
     36   
     37  $t->diag('Testing limit and offseting for domains list'); 
     38  $domainsResults = $service->listDomains(2); 
     39  $domainsList = $domainsResults['results']; 
     40  $t->is(count($domainsList), 2, 'listDomains() retrieves the correct limited number of results'); 
     41  $t->ok(isset($domainsResults['next_token']), 'listDomains() returns a next token'); 
     42   
     43  $domainsResultsNext = $service->listDomains(2, $domainsResults['next_token']); 
     44  $domainsResultsListNext = $domainsResultsNext['results']; 
     45  $t->is(count($domainsResultsListNext), 1, 'listDomains() retrieves the correct limited number of results with an offset'); 
     46   
    3147  $t->pass('listDomains() does not throw an exception'); 
    3248} 
     
    8399{ 
    84100  $t->diag(' 1. Getting all data'); 
    85   $query = $service->query(); 
    86   $t->isa_ok($query, 'array', 'query() retrieves results as an array'); 
    87   $t->is(count($query), 3, 'query() retrieves the correct number of results'); 
     101  $queryResults = $service->query(); 
     102  $queryResultsList = $queryResults['results']; 
     103  $t->isa_ok($queryResultsList, 'array', 'query() retrieves results as an array'); 
     104  $t->is(count($queryResultsList), 3, 'query() retrieves the correct number of results'); 
    88105   
    89106  $t->diag(' 2. Filtering one attribute'); 
    90   $query = $service->query("['Color' = 'Red']"); 
    91   $t->isa_ok($query, 'array', 'query() retrieves results as an array'); 
    92   $t->is(count($query), 1, 'query() retrieves the correct number of results'); 
    93   $t->is($query[0], 'Entry #2', 'query() retrieves the correct result'); 
     107  $queryResults = $service->query("['Color' = 'Red']"); 
     108  $queryResultsList = $queryResults['results']; 
     109  $t->isa_ok($queryResultsList, 'array', 'query() retrieves results as an array'); 
     110  $t->is(count($queryResultsList), 1, 'query() retrieves the correct number of results'); 
     111  $t->is($queryResultsList[0], 'Entry #2', 'query() retrieves the correct result'); 
    94112   
    95113  $t->diag(' 3. Filtering multiple attributes'); 
    96   $query = $service->query("['Color' = 'Green'] intersection ['Size' = 'Small']"); 
    97   $t->is(count($query), 1, 'query() retrieves the correct number of results'); 
    98   $t->is($query[0], 'Entry #3', 'query() retrieves the correct result'); 
     114  $queryResults = $service->query("['Color' = 'Green'] intersection ['Size' = 'Small']"); 
     115  $queryResultsList = $queryResults['results']; 
     116  $t->is(count($queryResultsList), 1, 'query() retrieves the correct number of results'); 
     117  $t->is($queryResultsList[0], 'Entry #3', 'query() retrieves the correct result'); 
     118   
     119  $t->diag(' 4. Testing limit and offseting for results list'); 
     120  $queryResults = $service->query(null, 2); 
     121  $queryResultsList = $queryResults['results']; 
     122  $t->is(count($queryResultsList), 2, 'query() retrieves the correct limited number of results'); 
     123  $t->ok(isset($queryResults['next_token']), 'query() retrieves a next token attribute'); 
     124     
     125  $queryResultsNext = $service->query(null, 2, $queryResults['next_token']); 
     126  $queryResultsListNext = $queryResultsNext['results']; 
     127  $t->is(count($queryResultsListNext), 1, 'query() retrieves the correct limited number of results with an offset'); 
     128   
    99129  $t->pass('query() does not throw an exception'); 
    100130} 
     
    161191try 
    162192{ 
    163   $domainDeletion = $service->deleteDomain('sfAmazonSimpleDBPluginTestDomain'); 
    164   $t->ok($domainDeletion, 'deleteDomain() confirms domain has been deleted'); 
     193  $domainDeletion1 = $service->deleteDomain('sfAmazonSimpleDBPluginTestDomain'); 
     194  $domainDeletion2 = $service->deleteDomain('sfAmazonSimpleDBPluginTestDomain2'); 
     195  $domainDeletion3 = $service->deleteDomain('sfAmazonSimpleDBPluginTestDomain3'); 
     196  $t->ok($domainDeletion1 && $domainDeletion2 && $domainDeletion3, 'deleteDomain() confirms domain has been deleted'); 
    165197  $t->pass('deleteDomain() does not throw an exception'); 
    166198} 
     
    170202} 
    171203 
    172 $domainsList = $service->listDomains(); 
     204$domainsResults = $service->listDomains(); 
     205$domainsList = $domainsResults['results']; 
    173206$t->ok(!in_array('sfAmazonSimpleDBPluginTestDomain', $domainsList), 'listDomains() no more lists deleted domain'); 
     207$t->ok(!in_array('sfAmazonSimpleDBPluginTestDomain2', $domainsList), 'listDomains() no more lists deleted domain'); 
     208$t->ok(!in_array('sfAmazonSimpleDBPluginTestDomain3', $domainsList), 'listDomains() no more lists deleted domain'); 
    174209$t->is($service->getSelectedDomain(), null, 'getSelectedDomain() no more returns a deleted domain as selected');