Guest User

Untitled

a guest
Feb 12th, 2019
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.10 KB | None | 0 0
  1. use ModuleNameEntityUser;
  2.  
  3. $user = new User;
  4. $user->username = 'john.doe';
  5. $user->password = md5('password');
  6. $this->_getEntityManager()->persist($user);
  7. $this->_getEntityManager()->flush();
  8.  
  9. class_parents(): Class User does not exist and could not be loaded
  10. /Users/richardknop/Projects/myproject/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/RuntimeReflectionService.php:40
  11. /Users/richardknop/Projects/myproject/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:257
  12.  
  13. #!/usr/bin/env php
  14. <?php
  15.  
  16. chdir(__DIR__);
  17. $paths = array();
  18. if ($argc > 1) {
  19. foreach ($argv as $key => $path) {
  20.  
  21. if (!$key) continue;
  22. system('phpunit -c '. __DIR__ . DIRECTORY_SEPARATOR . 'phpunit.xml '. __DIR__ . DIRECTORY_SEPARATOR . $path, $result);
  23. echo $result;
  24. }
  25.  
  26. } else {
  27.  
  28. system('phpunit -c '. __DIR__ . DIRECTORY_SEPARATOR . 'phpunit.xml '. __DIR__, $result);
  29. echo $result;
  30. }
  31.  
  32. <phpunit
  33. bootstrap="./Bootstrap.php"
  34. backupGlobals="false"
  35. backupStaticAttributes="false"
  36. cacheTokens="true"
  37. colors="true"
  38. convertErrorsToExceptions="true"
  39. convertNoticesToExceptions="true"
  40. convertWarningsToExceptions="true"
  41. forceCoversAnnotation="false"
  42. mapTestClassNameToCoveredClassName="false"
  43. processIsolation="false"
  44. stopOnError="false"
  45. stopOnFailure="false"
  46. stopOnIncomplete="false"
  47. stopOnSkipped="false"
  48. strict="false"
  49. verbose="true"
  50. >
  51. <testsuites>
  52. <testsuite name="Module Test Suite">
  53. <directory>./</directory>
  54. </testsuite>
  55. </testsuites>
  56. </phpunit>
  57.  
  58. <?php
  59.  
  60. return array(
  61. 'output_buffering' => false, // required for testing sessions
  62. 'modules' => array(
  63. //'DoctrineModule',
  64. //'DoctrineORMModule',
  65. 'Base',
  66. ),
  67. 'module_listener_options' => array(
  68. 'config_glob_paths' => array(
  69. 'config/autoload/{,*.}{global,local}.php',
  70. ),
  71. 'module_paths' => array(
  72. './module',
  73. './vendor',
  74. ),
  75. ),
  76. );
  77.  
  78. <?php
  79.  
  80. use ZendServiceManagerServiceManager;
  81. use ZendMvcMvcEvent;
  82. use ZendMvcServiceServiceManagerConfig;
  83. use BaseModuleTestTestCase;
  84.  
  85. error_reporting( E_ALL | E_STRICT );
  86. chdir(__DIR__);
  87.  
  88. $configuration = @include __DIR__ . '/TestConfiguration.php';
  89. if (isset($configuration['output_buffering']) && $configuration['output_buffering']) {
  90.  
  91. ob_start(); // required to test sessions
  92. }
  93.  
  94. spl_autoload_register('loadTestClass', true, false);
  95. function loadTestClass($classname) {
  96.  
  97. $file = __DIR__ . DIRECTORY_SEPARATOR . str_replace('\', DIRECTORY_SEPARATOR, $classname) . '.php';
  98. if (is_file($file) && is_readable($file)) {
  99.  
  100. require_once $file;
  101. }
  102. }
  103.  
  104.  
  105. $previousDir = '.';
  106. while (!file_exists('config/application.config.php')) {
  107. $dir = dirname(getcwd());
  108.  
  109. if ($previousDir === $dir) {
  110. throw new RuntimeException(
  111. 'Unable to locate "config/application.config.php":'
  112. . ' is DoctrineORMModule in a sub-directory of your application skeleton?'
  113. );
  114. }
  115.  
  116. $previousDir = $dir;
  117. chdir($dir);
  118. }
  119.  
  120. /////////////////////////////////////////////////////////////
  121.  
  122. require './module/Base/src/functions.php';
  123.  
  124. if (!@include_once 'vendor/autoload.php') {
  125. throw new RuntimeException('vendor/autoload.php could not be found. Did you run `php composer.phar install`?');
  126. }
  127.  
  128. $serviceManager = new ServiceManager(new ServiceManagerConfig(
  129. isset($configuration['service_manager']) ? $configuration['service_manager'] : array()
  130. ));
  131. $serviceManager->setService('ApplicationConfig', $configuration);
  132. $serviceManager->setFactory('ServiceListener', 'ZendMvcServiceServiceListenerFactory');
  133.  
  134. /** @var $moduleManager ZendModuleManagerModuleManager */
  135. $moduleManager = $serviceManager->get('ModuleManager');
  136. $moduleManager->loadModules();
  137. $serviceManager->setAllowOverride(true);
  138.  
  139. $application = $serviceManager->get('Application');
  140. $event = new MvcEvent();
  141. $event->setTarget($application);
  142. $event->setApplication($application)
  143. ->setRequest($application->getRequest())
  144. ->setResponse($application->getResponse())
  145. ->setRouter($serviceManager->get('Router'));
Add Comment
Please, Sign In to add comment