diff --git a/_support/Autoloader/UnnamespacedClass.php b/_support/Autoloader/UnnamespacedClass.php new file mode 100644 index 0000000..67b1ed3 --- /dev/null +++ b/_support/Autoloader/UnnamespacedClass.php @@ -0,0 +1,5 @@ +prefix . $key; + + return array_key_exists($key, $this->cache) + ? $this->cache[$key] + : false; + } + + //-------------------------------------------------------------------- + + /** + * Saves an item to the cache store. + * + * The $raw parameter is only utilized by Mamcache in order to + * allow usage of increment() and decrement(). + * + * @param string $key Cache item name + * @param $value the data to save + * @param null $ttl Time To Live, in seconds (default 60) + * @param boolean $raw Whether to store the raw value. + * + * @return mixed + */ + public function save(string $key, $value, int $ttl = 60, bool $raw = false) + { + $key = $this->prefix . $key; + + $this->cache[$key] = $value; + + return true; + } + + //-------------------------------------------------------------------- + + /** + * Deletes a specific item from the cache store. + * + * @param string $key Cache item name + * + * @return mixed + */ + public function delete(string $key) + { + unset($this->cache[$key]); + } + + //-------------------------------------------------------------------- + + /** + * Performs atomic incrementation of a raw stored value. + * + * @param string $key Cache ID + * @param integer $offset Step/value to increase by + * + * @return mixed + */ + public function increment(string $key, int $offset = 1) + { + $key = $this->prefix . $key; + + $data = $this->cache[$key] ?: null; + + if (empty($data)) + { + $data = 0; + } + elseif (! is_int($data)) + { + return false; + } + + return $this->save($key, $data + $offset); + } + + //-------------------------------------------------------------------- + + /** + * Performs atomic decrementation of a raw stored value. + * + * @param string $key Cache ID + * @param integer $offset Step/value to increase by + * + * @return mixed + */ + public function decrement(string $key, int $offset = 1) + { + $key = $this->prefix . $key; + + $data = $this->cache[$key] ?: null; + + if (empty($data)) + { + $data = 0; + } + elseif (! is_int($data)) + { + return false; + } + + return $this->save($key, $data - $offset); + } + + //-------------------------------------------------------------------- + + /** + * Will delete all items in the entire cache. + * + * @return mixed + */ + public function clean() + { + $this->cache = []; + } + + //-------------------------------------------------------------------- + + /** + * Returns information on the entire cache. + * + * The information returned and the structure of the data + * varies depending on the handler. + * + * @return mixed + */ + public function getCacheInfo() + { + return []; + } + + //-------------------------------------------------------------------- + + /** + * Returns detailed information about the specific item in the cache. + * + * @param string $key Cache item name. + * + * @return mixed + */ + public function getMetaData(string $key) + { + return false; + } + + //-------------------------------------------------------------------- + + /** + * Determines if the driver is supported on this system. + * + * @return boolean + */ + public function isSupported(): bool + { + return true; + } + + //-------------------------------------------------------------------- + +} diff --git a/_support/Commands/AbstractInfo.php b/_support/Commands/AbstractInfo.php new file mode 100644 index 0000000..2ca684e --- /dev/null +++ b/_support/Commands/AbstractInfo.php @@ -0,0 +1,13 @@ +showError($oops); + } + } + + public function helpme() + { + $this->call('help'); + } +} diff --git a/_support/Commands/CommandsTestStreamFilter.php b/_support/Commands/CommandsTestStreamFilter.php new file mode 100644 index 0000000..599075b --- /dev/null +++ b/_support/Commands/CommandsTestStreamFilter.php @@ -0,0 +1,18 @@ +data; + $consumed += $bucket->datalen; + } + return PSFS_PASS_ON; + } +} + +stream_filter_register('CommandsTestStreamFilter', 'CodeIgniter\Commands\CommandsTestStreamFilter'); diff --git a/_support/Config/BadRegistrar.php b/_support/Config/BadRegistrar.php new file mode 100644 index 0000000..877d7be --- /dev/null +++ b/_support/Config/BadRegistrar.php @@ -0,0 +1,18 @@ + [ + /* + * The log levels that this handler will handle. + */ + 'handles' => [ + 'critical', + 'alert', + 'emergency', + 'debug', + 'error', + 'info', + 'notice', + 'warning', + ], + ], + ]; + +} diff --git a/_support/Config/Registrar.php b/_support/Config/Registrar.php new file mode 100644 index 0000000..9d00c6a --- /dev/null +++ b/_support/Config/Registrar.php @@ -0,0 +1,27 @@ + [ + 'first', + 'second', + ], + 'format' => 'nice', + 'fruit' => [ + 'apple', + 'banana', + ], + ]; + } + +} diff --git a/_support/Config/Routes.php b/_support/Config/Routes.php new file mode 100644 index 0000000..2369e33 --- /dev/null +++ b/_support/Config/Routes.php @@ -0,0 +1,7 @@ +add('testing', 'TestController::index'); diff --git a/_support/Database/Migrations/20160428212500_Create_test_tables.php b/_support/Database/Migrations/20160428212500_Create_test_tables.php new file mode 100644 index 0000000..8d4a93a --- /dev/null +++ b/_support/Database/Migrations/20160428212500_Create_test_tables.php @@ -0,0 +1,113 @@ +db->DBDriver === 'SQLite3' ? 'unique' : 'auto_increment'; + + // User Table + $this->forge->addField([ + 'id' => [ + 'type' => 'INTEGER', + 'constraint' => 3, + $unique_or_auto => true, + ], + 'name' => [ + 'type' => 'VARCHAR', + 'constraint' => 80, + ], + 'email' => [ + 'type' => 'VARCHAR', + 'constraint' => 100, + ], + 'country' => [ + 'type' => 'VARCHAR', + 'constraint' => 40, + ], + 'deleted' => [ + 'type' => 'TINYINT', + 'constraint' => 1, + 'default' => '0', + ], + ]); + $this->forge->addKey('id', true); + $this->forge->createTable('user', true); + + // Job Table + $this->forge->addField([ + 'id' => [ + 'type' => 'INTEGER', + 'constraint' => 3, + $unique_or_auto => true, + ], + 'name' => [ + 'type' => 'VARCHAR', + 'constraint' => 40, + ], + 'description' => ['type' => 'TEXT'], + 'created_at' => [ + 'type' => 'DATETIME', + 'null' => true, + ], + ]); + $this->forge->addKey('id', true); + $this->forge->createTable('job', true); + + // Misc Table + $this->forge->addField([ + 'id' => [ + 'type' => 'INTEGER', + 'constraint' => 3, + $unique_or_auto => true, + ], + 'key' => [ + 'type' => 'VARCHAR', + 'constraint' => 40, + ], + 'value' => ['type' => 'TEXT'], + ]); + $this->forge->addKey('id', true); + $this->forge->createTable('misc', true); + + // Empty Table + $this->forge->addField([ + 'id' => [ + 'type' => 'INTEGER', + 'constraint' => 3, + $unique_or_auto => true, + ], + 'name' => [ + 'type' => 'VARCHAR', + 'constraint' => 40, + ], + ]); + $this->forge->addKey('id', true); + $this->forge->createTable('empty', true); + + //No Primary Key + $this->forge->addField([ + 'key' => [ + 'type' => 'VARCHAR', + 'constraint' => 40, + ], + 'value' => ['type' => 'TEXT'], + ]); + $this->forge->createTable('secondary', true); + } + + //-------------------------------------------------------------------- + + public function down() + { + $this->forge->dropTable('user'); + $this->forge->dropTable('job'); + $this->forge->dropTable('misc'); + $this->forge->dropTable('empty'); + $this->forge->dropTable('secondary'); + } + + //-------------------------------------------------------------------- + +} diff --git a/_support/Database/MockBuilder.php b/_support/Database/MockBuilder.php new file mode 100644 index 0000000..98c7fb6 --- /dev/null +++ b/_support/Database/MockBuilder.php @@ -0,0 +1,15 @@ +returnValues[$method] = $return; + + return $this; + } + + //-------------------------------------------------------------------- + + public function query(string $sql, $binds = null, bool $setEscapeFlags = true, $queryClass = 'CodeIgniter\\Database\\Query') + { + $queryClass = str_replace('Connection', 'Query', get_class($this)); + + $query = new $queryClass($this); + + $query->setQuery($sql, $binds, $setEscapeFlags); + + if (! empty($this->swapPre) && ! empty($this->DBPrefix)) + { + $query->swapPrefix($this->DBPrefix, $this->swapPre); + } + + $startTime = microtime(true); + + $this->lastQuery = $query; + + // Run the query + if (false === ($this->resultID = $this->simpleQuery($query->getQuery()))) + { + $query->setDuration($startTime, $startTime); + + // @todo deal with errors + + return false; + } + + $query->setDuration($startTime); + + $resultClass = str_replace('Connection', 'Result', get_class($this)); + + return new $resultClass($this->connID, $this->resultID); + } + + //-------------------------------------------------------------------- + + /** + * Connect to the database. + * + * @return mixed + */ + public function connect($persistent = false) + { + $return = $this->returnValues['connect'] ?? true; + + if (is_array($return)) + { + // By removing the top item here, we can + // get a different value for, say, testing failover connections. + $return = array_shift($this->returnValues['connect']); + } + + return $return; + } + + //-------------------------------------------------------------------- + + /** + * Keep or establish the connection if no queries have been sent for + * a length of time exceeding the server's idle timeout. + * + * @return mixed + */ + public function reconnect() + { + return true; + } + + //-------------------------------------------------------------------- + + /** + * Select a specific database table to use. + * + * @param string $databaseName + * + * @return mixed + */ + public function setDatabase(string $databaseName) + { + $this->database = $databaseName; + + return $this; + } + + //-------------------------------------------------------------------- + + /** + * Returns a string containing the version of the database being used. + * + * @return mixed + */ + public function getVersion() + { + return \CodeIgniter\CodeIgniter::CI_VERSION; + } + + //-------------------------------------------------------------------- + + /** + * Executes the query against the database. + * + * @param $sql + * + * @return mixed + */ + protected function execute($sql) + { + return $this->returnValues['execute']; + } + + //-------------------------------------------------------------------- + + /** + * Returns the total number of rows affected by this query. + * + * @return mixed + */ + public function affectedRows(): int + { + return 1; + } + + //-------------------------------------------------------------------- + + /** + * Returns the last error code and message. + * + * Must return an array with keys 'code' and 'message': + * + * return ['code' => null, 'message' => null); + * + * @return array + */ + public function error() + { + return [ + 'code' => null, + 'message' => null, + ]; + } + + //-------------------------------------------------------------------- + + /** + * Insert ID + * + * @return integer + */ + public function insertID() + { + return $this->connID->insert_id; + } + + //-------------------------------------------------------------------- + + /** + * Generates the SQL for listing tables in a platform-dependent manner. + * + * @param boolean $constrainByPrefix + * + * @return string + */ + protected function _listTables($constrainByPrefix = false): string + { + return ''; + } + + //-------------------------------------------------------------------- + + /** + * Generates a platform-specific query string so that the column names can be fetched. + * + * @param string $table + * + * @return string + */ + protected function _listColumns(string $table = ''): string + { + return ''; + } + + /** + * @param string $table + * @return array + */ + protected function _fieldData(string $table): array + { + return []; + } + + /** + * @param string $table + * @return array + */ + protected function _indexData(string $table): array + { + return []; + } + + /** + * @param string $table + * @return array + */ + protected function _foreignKeyData(string $table): array + { + return []; + } + + //-------------------------------------------------------------------- + + /** + * Close the connection. + */ + protected function _close() + { + return; + } + + //-------------------------------------------------------------------- + + /** + * Begin Transaction + * + * @return boolean + */ + protected function _transBegin(): bool + { + return true; + } + + //-------------------------------------------------------------------- + + /** + * Commit Transaction + * + * @return boolean + */ + protected function _transCommit(): bool + { + return true; + } + + //-------------------------------------------------------------------- + + /** + * Rollback Transaction + * + * @return boolean + */ + protected function _transRollback(): bool + { + return true; + } + + //-------------------------------------------------------------------- +} diff --git a/_support/Database/MockQuery.php b/_support/Database/MockQuery.php new file mode 100644 index 0000000..0008104 --- /dev/null +++ b/_support/Database/MockQuery.php @@ -0,0 +1,8 @@ + [ + [ + 'name' => 'Derek Jones', + 'email' => 'derek@world.com', + 'country' => 'US', + ], + [ + 'name' => 'Ahmadinejad', + 'email' => 'ahmadinejad@world.com', + 'country' => 'Iran', + ], + [ + 'name' => 'Richard A Causey', + 'email' => 'richard@world.com', + 'country' => 'US', + ], + [ + 'name' => 'Chris Martin', + 'email' => 'chris@world.com', + 'country' => 'UK', + ], + ], + 'job' => [ + [ + 'name' => 'Developer', + 'description' => 'Awesome job, but sometimes makes you bored', + ], + [ + 'name' => 'Politician', + 'description' => 'This is not really a job', + ], + [ + 'name' => 'Accountant', + 'description' => 'Boring job, but you will get free snack at lunch', + ], + [ + 'name' => 'Musician', + 'description' => 'Only Coldplay can actually called Musician', + ], + ], + 'misc' => [ + [ + 'key' => '\\xxxfoo456', + 'value' => 'Entry with \\xxx', + ], + [ + 'key' => '\\%foo456', + 'value' => 'Entry with \\%', + ], + [ + 'key' => 'spaces and tabs', + 'value' => ' One two three tab', + ], + ], + ]; + + foreach ($data as $table => $dummy_data) + { + $this->db->table($table)->truncate(); + + foreach ($dummy_data as $single_dummy_data) + { + $this->db->table($table)->insert($single_dummy_data); + } + } + } + + //-------------------------------------------------------------------- + +} diff --git a/_support/Database/SupportMigrations/001_Some_migration.php b/_support/Database/SupportMigrations/001_Some_migration.php new file mode 100644 index 0000000..2b98498 --- /dev/null +++ b/_support/Database/SupportMigrations/001_Some_migration.php @@ -0,0 +1,24 @@ +forge->addField([ + 'key' => [ + 'type' => 'VARCHAR', + 'constraint' => 255, + ], + ]); + $this->forge->createTable('foo', true); + + $this->db->table('foo')->insert([ + 'key' => 'foobar', + ]); + } + + public function down() + { + $this->forge->dropTable('foo'); + } +} diff --git a/_support/Events/MockEvents.php b/_support/Events/MockEvents.php new file mode 100644 index 0000000..ce30d4f --- /dev/null +++ b/_support/Events/MockEvents.php @@ -0,0 +1,66 @@ +output = $output; + + return $this; + } + + //-------------------------------------------------------------------- + + protected function sendRequest(array $curl_options = []): string + { + // Save so we can access later. + $this->curl_options = $curl_options; + + return $this->output; + } + + //-------------------------------------------------------------------- + // for testing purposes only + public function getBaseURI() + { + return $this->baseURI; + } + + // for testing purposes only + public function getDelay() + { + return $this->delay; + } + +} diff --git a/_support/HTTP/MockIncomingRequest.php b/_support/HTTP/MockIncomingRequest.php new file mode 100644 index 0000000..627fc9a --- /dev/null +++ b/_support/HTTP/MockIncomingRequest.php @@ -0,0 +1,17 @@ +pretend; + } + + // artificial error for testing + public function misbehave() + { + $this->statusCode = 0; + } + +} diff --git a/_support/Images/EXIFsamples/down-mirrored.jpg b/_support/Images/EXIFsamples/down-mirrored.jpg new file mode 100644 index 0000000..34a7b1d --- /dev/null +++ b/_support/Images/EXIFsamples/down-mirrored.jpg Binary files differ diff --git a/_support/Images/EXIFsamples/down.jpg b/_support/Images/EXIFsamples/down.jpg new file mode 100644 index 0000000..9077a7c --- /dev/null +++ b/_support/Images/EXIFsamples/down.jpg Binary files differ diff --git a/_support/Images/EXIFsamples/left-mirrored.jpg b/_support/Images/EXIFsamples/left-mirrored.jpg new file mode 100644 index 0000000..1832702 --- /dev/null +++ b/_support/Images/EXIFsamples/left-mirrored.jpg Binary files differ diff --git a/_support/Images/EXIFsamples/left.jpg b/_support/Images/EXIFsamples/left.jpg new file mode 100644 index 0000000..ad1f898 --- /dev/null +++ b/_support/Images/EXIFsamples/left.jpg Binary files differ diff --git a/_support/Images/EXIFsamples/right-mirrored.jpg b/_support/Images/EXIFsamples/right-mirrored.jpg new file mode 100644 index 0000000..cc8a29a --- /dev/null +++ b/_support/Images/EXIFsamples/right-mirrored.jpg Binary files differ diff --git a/_support/Images/EXIFsamples/right.jpg b/_support/Images/EXIFsamples/right.jpg new file mode 100644 index 0000000..183ffeb --- /dev/null +++ b/_support/Images/EXIFsamples/right.jpg Binary files differ diff --git a/_support/Images/EXIFsamples/up-mirrored.jpg b/_support/Images/EXIFsamples/up-mirrored.jpg new file mode 100644 index 0000000..e1865a5 --- /dev/null +++ b/_support/Images/EXIFsamples/up-mirrored.jpg Binary files differ diff --git a/_support/Images/EXIFsamples/up.jpg b/_support/Images/EXIFsamples/up.jpg new file mode 100644 index 0000000..70fc26f --- /dev/null +++ b/_support/Images/EXIFsamples/up.jpg Binary files differ diff --git a/_support/Images/Steveston_dusk.JPG b/_support/Images/Steveston_dusk.JPG new file mode 100644 index 0000000..c3b9b12 --- /dev/null +++ b/_support/Images/Steveston_dusk.JPG Binary files differ diff --git a/_support/Images/ci-logo.gif b/_support/Images/ci-logo.gif new file mode 100644 index 0000000..3001b2f --- /dev/null +++ b/_support/Images/ci-logo.gif Binary files differ diff --git a/_support/Images/ci-logo.jpeg b/_support/Images/ci-logo.jpeg new file mode 100644 index 0000000..1b0178b --- /dev/null +++ b/_support/Images/ci-logo.jpeg Binary files differ diff --git a/_support/Images/ci-logo.png b/_support/Images/ci-logo.png new file mode 100644 index 0000000..34fb010 --- /dev/null +++ b/_support/Images/ci-logo.png Binary files differ diff --git a/_support/Language/MockLanguage.php b/_support/Language/MockLanguage.php new file mode 100644 index 0000000..49301db --- /dev/null +++ b/_support/Language/MockLanguage.php @@ -0,0 +1,61 @@ +language[$locale ?? $this->locale][$file] = $data; + + return $this; + } + + //-------------------------------------------------------------------- + + /** + * Provides an override that allows us to set custom + * data to be returned easily during testing. + * + * @param string $path + * + * @return array|mixed + */ + protected function requireFile(string $path): array + { + return $this->data ?? []; + } + + //-------------------------------------------------------------------- + + /** + * Arbitrarily turnoff internationalization support for testing + */ + public function disableIntlSupport() + { + $this->intlSupport = false; + } + +} diff --git a/_support/Language/SecondMockLanguage.php b/_support/Language/SecondMockLanguage.php new file mode 100644 index 0000000..7142885 --- /dev/null +++ b/_support/Language/SecondMockLanguage.php @@ -0,0 +1,27 @@ +load($file, $locale, $return); + } + + //-------------------------------------------------------------------- + + /** + * Expose the loaded language files + */ + public function loaded(string $locale = 'en') + { + return $this->loadedFiles[$locale]; + } + +} diff --git a/_support/Language/ab-CD/Allin.php b/_support/Language/ab-CD/Allin.php new file mode 100644 index 0000000..3b15388 --- /dev/null +++ b/_support/Language/ab-CD/Allin.php @@ -0,0 +1,8 @@ + 'Pyramid of Giza', + 'tre' => 'Colossus of Rhodes', + 'fiv' => 'Temple of Artemis', + 'sev' => 'Hanging Gardens of Babylon', +]; diff --git a/_support/Language/ab/Allin.php b/_support/Language/ab/Allin.php new file mode 100644 index 0000000..6912075 --- /dev/null +++ b/_support/Language/ab/Allin.php @@ -0,0 +1,8 @@ + 'gluttony', + 'tre' => 'greed', + 'six' => 'envy', + 'sev' => 'pride', +]; diff --git a/_support/Language/en-ZZ/More.php b/_support/Language/en-ZZ/More.php new file mode 100644 index 0000000..6681020 --- /dev/null +++ b/_support/Language/en-ZZ/More.php @@ -0,0 +1,6 @@ + 'These are not the droids you are looking for', + 'notaMoon' => "It's made of cheese", + 'wisdom' => 'There is no try', +]; diff --git a/_support/Language/en/Allin.php b/_support/Language/en/Allin.php new file mode 100644 index 0000000..6a10dcc --- /dev/null +++ b/_support/Language/en/Allin.php @@ -0,0 +1,8 @@ + 'four calling birds', + 'fiv' => 'five golden rings', + 'six' => 'six geese a laying', + 'sev' => 'seven swans a swimming', +]; diff --git a/_support/Language/en/Core.php b/_support/Language/en/Core.php new file mode 100644 index 0000000..4d03510 --- /dev/null +++ b/_support/Language/en/Core.php @@ -0,0 +1,20 @@ + '{0} extension could not be found.', + 'bazillion' => 'billions and billions', // adds a new setting +]; diff --git a/_support/Language/en/More.php b/_support/Language/en/More.php new file mode 100644 index 0000000..5b4eaea --- /dev/null +++ b/_support/Language/en/More.php @@ -0,0 +1,7 @@ + 'These are not the droids you are looking for', + 'notaMoon' => "That's no moon... it's a space station", + 'cannotMove' => 'I have a very bad feeling about this', +]; diff --git a/_support/Language/ru/Language.php b/_support/Language/ru/Language.php new file mode 100644 index 0000000..d6c6632 --- /dev/null +++ b/_support/Language/ru/Language.php @@ -0,0 +1,5 @@ + 'Whatever this would be, translated', +]; diff --git a/_support/Log/Handlers/MockChromeHandler.php b/_support/Log/Handlers/MockChromeHandler.php new file mode 100644 index 0000000..1a64b22 --- /dev/null +++ b/_support/Log/Handlers/MockChromeHandler.php @@ -0,0 +1,25 @@ +json['rows'][0]; + } + +} diff --git a/_support/Log/Handlers/MockFileHandler.php b/_support/Log/Handlers/MockFileHandler.php new file mode 100644 index 0000000..efd72a9 --- /dev/null +++ b/_support/Log/Handlers/MockFileHandler.php @@ -0,0 +1,25 @@ +handles = $config['handles'] ?? []; + $this->destination = $this->path . 'log-' . date('Y-m-d') . '.' . $this->fileExtension; + } + +} diff --git a/_support/Log/Handlers/TestHandler.php b/_support/Log/Handlers/TestHandler.php new file mode 100644 index 0000000..e22559c --- /dev/null +++ b/_support/Log/Handlers/TestHandler.php @@ -0,0 +1,64 @@ +handles = $config['handles'] ?? []; + $this->destination = $this->path . 'log-' . date('Y-m-d') . '.' . $this->fileExtension; + + self::$logs = []; + } + + //-------------------------------------------------------------------- + + /** + * Handles logging the message. + * If the handler returns false, then execution of handlers + * will stop. Any handlers that have not run, yet, will not + * be run. + * + * @param $level + * @param $message + * + * @return boolean + */ + public function handle($level, $message): bool + { + $date = date($this->dateFormat); + + self::$logs[] = strtoupper($level) . ' - ' . $date . ' --> ' . $message; + + return true; + } + + //-------------------------------------------------------------------- + + public static function getLogs() + { + return self::$logs; + } + + //-------------------------------------------------------------------- +} diff --git a/_support/Log/TestLogger.php b/_support/Log/TestLogger.php new file mode 100644 index 0000000..a88eb62 --- /dev/null +++ b/_support/Log/TestLogger.php @@ -0,0 +1,82 @@ +assertLogged() methods. + * + * @param string $level + * @param string $message + * @param array $context + * + * @return boolean + */ + public function log($level, $message, array $context = []): bool + { + // While this requires duplicate work, we want to ensure + // we have the final message to test against. + $log_message = $this->interpolate($message, $context); + + // Determine the file and line by finding the first + // backtrace that is not part of our logging system. + $trace = debug_backtrace(); + $file = null; + + foreach ($trace as $row) + { + if (! in_array($row['function'], ['log', 'log_message'])) + { + $file = basename($row['file'] ?? ''); + break; + } + } + + self::$op_logs[] = [ + 'level' => $level, + 'message' => $log_message, + 'file' => $file, + ]; + + // Let the parent do it's thing. + return parent::log($level, $message, $context); + } + + //-------------------------------------------------------------------- + + /** + * Used by CIUnitTestCase class to provide ->assertLogged() methods. + * + * @param string $level + * @param string $message + * + * @return boolean + */ + public static function didLog(string $level, $message) + { + foreach (self::$op_logs as $log) + { + if (strtolower($log['level']) === strtolower($level) && $message === $log['message']) + { + return true; + } + } + + return false; + } + + //-------------------------------------------------------------------- + // Expose cleanFileNames() + public function cleanup($file) + { + return $this->cleanFileNames($file); + } + +} diff --git a/_support/MockCodeIgniter.php b/_support/MockCodeIgniter.php new file mode 100644 index 0000000..3e31d00 --- /dev/null +++ b/_support/MockCodeIgniter.php @@ -0,0 +1,11 @@ +tokens[] = 'beforeInsert'; + + return $data; + } + + protected function afterInsertMethod(array $data) + { + $this->tokens[] = 'afterInsert'; + + return $data; + } + + protected function beforeUpdateMethod(array $data) + { + $this->tokens[] = 'beforeUpdate'; + + return $data; + } + + protected function afterUpdateMethod(array $data) + { + $this->tokens[] = 'afterUpdate'; + + return $data; + } + + protected function afterFindMethod(array $data) + { + $this->tokens[] = 'afterFind'; + + return $data; + } + + protected function afterDeleteMethod(array $data) + { + $this->tokens[] = 'afterDelete'; + + return $data; + } + + public function hasToken(string $token) + { + return in_array($token, $this->tokens); + } + +} diff --git a/_support/Models/JobModel.php b/_support/Models/JobModel.php new file mode 100644 index 0000000..cdda38f --- /dev/null +++ b/_support/Models/JobModel.php @@ -0,0 +1,19 @@ + [], + 'dates' => [ + 'created_at', + 'updated_at', + 'deleted_at', + ], + 'casts' => [], + ]; +} diff --git a/_support/Models/UserModel.php b/_support/Models/UserModel.php new file mode 100644 index 0000000..c84ca1a --- /dev/null +++ b/_support/Models/UserModel.php @@ -0,0 +1,21 @@ + [ + 'required', + 'min_length[10]', + 'errors' => [ + 'min_length' => 'Minimum Length Error', + ] + ], + 'token' => 'in_list[{id}]', + ]; +} diff --git a/_support/Models/ValidModel.php b/_support/Models/ValidModel.php new file mode 100644 index 0000000..a252120 --- /dev/null +++ b/_support/Models/ValidModel.php @@ -0,0 +1,34 @@ + [ + 'required', + 'min_length[3]', + ], + 'token' => 'in_list[{id}]', + ]; + + protected $validationMessages = [ + 'name' => [ + 'required' => 'You forgot to name the baby.', + 'min_length' => 'Too short, man!', + ], + ]; +} diff --git a/_support/Security/MockSecurity.php b/_support/Security/MockSecurity.php new file mode 100644 index 0000000..7a9239f --- /dev/null +++ b/_support/Security/MockSecurity.php @@ -0,0 +1,17 @@ +CSRFHash; + + return $this; + } + + //-------------------------------------------------------------------- + +} diff --git a/_support/Services.php b/_support/Services.php new file mode 100644 index 0000000..48e8283 --- /dev/null +++ b/_support/Services.php @@ -0,0 +1,70 @@ +driver, true); + } + + //-------------------------------------------------------------------- + + /** + * Starts the session. + * Extracted for testing reasons. + */ + protected function startSession() + { + // session_start(); + } + + //-------------------------------------------------------------------- + + /** + * Takes care of setting the cookie on the client side. + * Extracted for testing reasons. + */ + protected function setCookie() + { + $this->cookies[] = [ + $this->sessionCookieName, + session_id(), + (empty($this->sessionExpiration) ? 0 : time() + $this->sessionExpiration), + $this->cookiePath, + $this->cookieDomain, + $this->cookieSecure, + true, + ]; + } + + //-------------------------------------------------------------------- + + public function regenerate(bool $destroy = false) + { + $this->didRegenerate = true; + $_SESSION['__ci_last_regenerate'] = time(); + } + + //-------------------------------------------------------------------- +} diff --git a/_support/SomeEntity.php b/_support/SomeEntity.php new file mode 100644 index 0000000..70ddc4d --- /dev/null +++ b/_support/SomeEntity.php @@ -0,0 +1,13 @@ + \ No newline at end of file diff --git a/_support/View/Views/simpler.php b/_support/View/Views/simpler.php new file mode 100644 index 0000000..0588b62 --- /dev/null +++ b/_support/View/Views/simpler.php @@ -0,0 +1 @@ +

{testString}

\ No newline at end of file diff --git a/_support/_bootstrap.php b/_support/_bootstrap.php new file mode 100644 index 0000000..65dd9a1 --- /dev/null +++ b/_support/_bootstrap.php @@ -0,0 +1,32 @@ + null, 'port' => 6379, 'timeout' => 0, + 'database' => 0, ]; /* diff --git a/app/Config/Paths.php b/app/Config/Paths.php index 6251124..5ef168c 100644 --- a/app/Config/Paths.php +++ b/app/Config/Paths.php @@ -20,7 +20,7 @@ * Include the path if the folder is not in the same directory * as this file. */ - public $systemDirectory = __DIR__ . '/../../vendor/codeigniter4/framework/system'; + public $systemDirectory = __DIR__ . '/../../system'; /* *--------------------------------------------------------------- diff --git a/app/Views/welcome_message.php b/app/Views/welcome_message.php index 2939098..ad6168e 100644 --- a/app/Views/welcome_message.php +++ b/app/Views/welcome_message.php @@ -12,8 +12,9 @@ height: 200px; width: 155px; display: inline-block; - opacity: 0.08; + opacity: 0.12; position: absolute; + z-index: 0; top: 2rem; left: 50%; margin-left: -73px; @@ -32,6 +33,8 @@ margin-top: 145px; margin-bottom: 0; color: #222; + position: relative; + z-index: 1; } .wrap { max-width: 1024px; @@ -81,15 +84,11 @@
-

Welcome to CodeIgniter

- -

version

-