| 
									
										
										
										
											2024-11-25 02:38:29 +00:00
										 |  |  | <?php | 
					
						
							| 
									
										
										
										
											2025-03-27 08:34:42 +00:00
										 |  |  | declare(strict_types=1); | 
					
						
							| 
									
										
										
										
											2024-11-25 02:38:29 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-26 07:07:05 +00:00
										 |  |  | use Cake\Cache\Cache; | 
					
						
							| 
									
										
										
										
											2025-03-27 08:34:42 +00:00
										 |  |  | use Cake\Chronos\Chronos; | 
					
						
							| 
									
										
										
										
											2025-03-26 07:07:05 +00:00
										 |  |  | use Cake\Core\Configure; | 
					
						
							|  |  |  | use Cake\Core\Plugin; | 
					
						
							| 
									
										
										
										
											2025-03-27 08:34:42 +00:00
										 |  |  | use Cake\Database\Connection; | 
					
						
							| 
									
										
										
										
											2025-03-26 07:07:05 +00:00
										 |  |  | use Cake\Datasource\ConnectionManager; | 
					
						
							| 
									
										
										
										
											2024-11-25 02:38:29 +00:00
										 |  |  | use Cake\TestSuite\Fixture\SchemaLoader; | 
					
						
							| 
									
										
										
										
											2025-03-26 07:07:05 +00:00
										 |  |  | use CakeProducts\CakeProductsPlugin; | 
					
						
							| 
									
										
										
										
											2025-03-27 08:34:42 +00:00
										 |  |  | use Migrations\TestSuite\Migrator; | 
					
						
							| 
									
										
										
										
											2025-03-26 07:07:05 +00:00
										 |  |  | use TestApp\Controller\AppController; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if (!defined('DS')) { | 
					
						
							|  |  |  |     define('DS', DIRECTORY_SEPARATOR); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2025-03-27 08:34:42 +00:00
										 |  |  | if (!defined('WINDOWS')) { | 
					
						
							|  |  |  |     if (DS === '\\' || substr(PHP_OS, 0, 3) === 'WIN') { | 
					
						
							|  |  |  |         define('WINDOWS', true); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         define('WINDOWS', false); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2025-03-26 07:07:05 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-27 08:34:42 +00:00
										 |  |  | define('PLUGIN_ROOT', dirname(__DIR__)); | 
					
						
							|  |  |  | define('ROOT', PLUGIN_ROOT . DS . 'tests' . DS . 'test_app'); | 
					
						
							|  |  |  | define('TMP', PLUGIN_ROOT . DS . 'tmp' . DS); | 
					
						
							| 
									
										
										
										
											2025-03-26 07:07:05 +00:00
										 |  |  | define('LOGS', TMP . 'logs' . DS); | 
					
						
							|  |  |  | define('CACHE', TMP . 'cache' . DS); | 
					
						
							| 
									
										
										
										
											2025-03-27 08:34:42 +00:00
										 |  |  | define('APP', ROOT . DS . 'src' . DS); | 
					
						
							|  |  |  | define('APP_DIR', 'src'); | 
					
						
							|  |  |  | define('CAKE_CORE_INCLUDE_PATH', PLUGIN_ROOT . '/vendor/cakephp/cakephp'); | 
					
						
							| 
									
										
										
										
											2025-03-26 07:07:05 +00:00
										 |  |  | define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS); | 
					
						
							|  |  |  | define('CAKE', CORE_PATH . APP_DIR . DS); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-27 08:34:42 +00:00
										 |  |  | define('WWW_ROOT', PLUGIN_ROOT . DS . 'webroot' . DS); | 
					
						
							|  |  |  | define('TESTS', __DIR__ . DS); | 
					
						
							|  |  |  | define('CONFIG', TESTS . 'config' . DS); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ini_set('intl.default_locale', 'de-DE'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | require PLUGIN_ROOT . '/vendor/autoload.php'; | 
					
						
							| 
									
										
										
										
											2025-03-26 07:07:05 +00:00
										 |  |  | require CORE_PATH . 'config/bootstrap.php'; | 
					
						
							| 
									
										
										
										
											2025-03-27 08:34:42 +00:00
										 |  |  | require CAKE . 'functions.php'; | 
					
						
							| 
									
										
										
										
											2025-03-26 07:07:05 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | Configure::write('App', [ | 
					
						
							| 
									
										
										
										
											2025-03-27 08:34:42 +00:00
										 |  |  |     'namespace' => 'TestApp', | 
					
						
							|  |  |  |     'encoding' => 'UTF-8', | 
					
						
							| 
									
										
										
										
											2025-03-26 07:07:05 +00:00
										 |  |  |     'paths' => [ | 
					
						
							| 
									
										
										
										
											2025-03-27 08:34:42 +00:00
										 |  |  |         'templates' => [ | 
					
						
							|  |  |  |             PLUGIN_ROOT . DS . 'tests' . DS . 'test_app' . DS . 'templates' . DS, | 
					
						
							|  |  |  |         ], | 
					
						
							| 
									
										
										
										
											2025-03-26 07:07:05 +00:00
										 |  |  |     ], | 
					
						
							|  |  |  | ]); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Configure::write('debug', true); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | $cache = [ | 
					
						
							|  |  |  |     'default' => [ | 
					
						
							|  |  |  |         'engine' => 'File', | 
					
						
							| 
									
										
										
										
											2025-03-27 08:34:42 +00:00
										 |  |  |         'path' => CACHE, | 
					
						
							| 
									
										
										
										
											2025-03-26 07:07:05 +00:00
										 |  |  |     ], | 
					
						
							|  |  |  |     '_cake_core_' => [ | 
					
						
							|  |  |  |         'className' => 'File', | 
					
						
							|  |  |  |         'prefix' => 'crud_myapp_cake_core_', | 
					
						
							|  |  |  |         'path' => CACHE . 'persistent/', | 
					
						
							|  |  |  |         'serialize' => true, | 
					
						
							|  |  |  |         'duration' => '+10 seconds', | 
					
						
							|  |  |  |     ], | 
					
						
							|  |  |  |     '_cake_model_' => [ | 
					
						
							|  |  |  |         'className' => 'File', | 
					
						
							|  |  |  |         'prefix' => 'crud_my_app_cake_model_', | 
					
						
							|  |  |  |         'path' => CACHE . 'models/', | 
					
						
							|  |  |  |         'serialize' => 'File', | 
					
						
							|  |  |  |         'duration' => '+10 seconds', | 
					
						
							|  |  |  |     ], | 
					
						
							|  |  |  | ]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Cache::setConfig($cache); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class_alias(AppController::class, 'App\Controller\AppController'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Plugin::getCollection()->add(new CakeProductsPlugin()); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-27 08:34:42 +00:00
										 |  |  | Chronos::setTestNow(Chronos::now()); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-26 07:07:05 +00:00
										 |  |  | if (!getenv('DB_URL')) { | 
					
						
							|  |  |  |     putenv('DB_URL=sqlite:///:memory:'); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ConnectionManager::setConfig('test', [ | 
					
						
							| 
									
										
										
										
											2025-03-27 08:34:42 +00:00
										 |  |  |     'className' => Connection::class, | 
					
						
							| 
									
										
										
										
											2025-03-26 07:07:05 +00:00
										 |  |  |     'url' => getenv('DB_URL') ?: null, | 
					
						
							|  |  |  |     'timezone' => 'UTC', | 
					
						
							| 
									
										
										
										
											2025-03-27 08:34:42 +00:00
										 |  |  |     'quoteIdentifiers' => false, | 
					
						
							| 
									
										
										
										
											2025-03-26 07:07:05 +00:00
										 |  |  |     'cacheMetadata' => true, | 
					
						
							|  |  |  | ]); | 
					
						
							| 
									
										
										
										
											2024-11-25 02:38:29 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-27 08:34:42 +00:00
										 |  |  | /** | 
					
						
							|  |  |  |  * Load schema from a SQL dump file. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * If your plugin does not use database fixtures you can | 
					
						
							|  |  |  |  * safely delete this. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * If you want to support multiple databases, consider | 
					
						
							|  |  |  |  * using migrations to provide schema for your plugin, | 
					
						
							|  |  |  |  * and using \Migrations\TestSuite\Migrator to load schema. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | // Load a schema dump file.
 | 
					
						
							|  |  |  | //(new SchemaLoader())->loadSqlFiles('tests/schema.sql', 'test');
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | $migrator = new Migrator(); | 
					
						
							|  |  |  | $migrator->run(['plugin' => 'CakeProducts']); |