ServiceProviderTest.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace Elgg\Di;
  3. class ServiceProviderTest extends \PHPUnit_Framework_TestCase {
  4. public function testPropertiesReturnCorrectClassNames() {
  5. $mgr = $this->getMock('\Elgg\AutoloadManager', array(), array(), '', false);
  6. $sp = new \Elgg\Di\ServiceProvider($mgr);
  7. $sp->setValue('session', \ElggSession::getMock());
  8. $svcClasses = array(
  9. 'accessCache' => '\ElggStaticVariableCache',
  10. 'accessCollections' => '\Elgg\Database\AccessCollections',
  11. 'actions' => '\Elgg\ActionsService',
  12. 'adminNotices' => '\Elgg\Database\AdminNotices',
  13. // requires _elgg_get_simplecache_root() to be defined
  14. //'amdConfig' => '\Elgg\Amd\Config',
  15. 'annotations' => '\Elgg\Database\Annotations',
  16. 'autoP' => '\ElggAutoP',
  17. 'autoloadManager' => '\Elgg\AutoloadManager',
  18. 'config' => '\Elgg\Config',
  19. 'configTable' => '\Elgg\Database\ConfigTable',
  20. 'context' => '\Elgg\Context',
  21. 'datalist' => '\Elgg\Database\Datalist',
  22. 'db' => '\Elgg\Database',
  23. 'entityTable' => '\Elgg\Database\EntityTable',
  24. 'events' => '\Elgg\EventsService',
  25. 'externalFiles' => '\Elgg\Assets\ExternalFiles',
  26. 'hooks' => '\Elgg\PluginHooksService',
  27. 'input' => '\Elgg\Http\Input',
  28. 'logger' => '\Elgg\Logger',
  29. 'metadataCache' => '\Elgg\Cache\MetadataCache',
  30. 'metadataTable' => '\Elgg\Database\MetadataTable',
  31. 'metastringsTable' => '\Elgg\Database\MetastringsTable',
  32. 'passwords' => '\Elgg\PasswordService',
  33. 'plugins' => '\Elgg\Database\Plugins',
  34. 'request' => '\Elgg\Http\Request',
  35. 'relationshipsTable' => '\Elgg\Database\RelationshipsTable',
  36. 'router' => '\Elgg\Router',
  37. 'session' => '\ElggSession',
  38. 'simpleCache' => '\Elgg\Cache\SimpleCache',
  39. 'siteSecret' => '\Elgg\Database\SiteSecret',
  40. 'stickyForms' => '\Elgg\Forms\StickyForms',
  41. 'subtypeTable' => '\Elgg\Database\SubtypeTable',
  42. 'systemCache' => '\Elgg\Cache\SystemCache',
  43. 'translator' => '\Elgg\I18n\Translator',
  44. 'usersTable' => '\Elgg\Database\UsersTable',
  45. 'views' => '\Elgg\ViewsService',
  46. 'widgets' => '\Elgg\WidgetsService',
  47. );
  48. foreach ($svcClasses as $key => $class) {
  49. $obj1 = $sp->{$key};
  50. $obj2 = $sp->{$key};
  51. $this->assertInstanceOf($class, $obj1);
  52. $this->assertSame($obj1, $obj2);
  53. }
  54. }
  55. }