Page MenuHomeDevCentral

D458.id1116.diff
No OneTemporary

D458.id1116.diff

diff --git a/tests/Providers/ProvidersFolderTest.php b/tests/Providers/ProvidersFolderTest.php
new file mode 100644
--- /dev/null
+++ b/tests/Providers/ProvidersFolderTest.php
@@ -0,0 +1,25 @@
+<?php
+
+class ProvidersFolderTest extends TestCase {
+
+ public function testOmittedFiles () {
+ $providers = [];
+
+ $namespace = $this->app->getInstance()->getNamespace() . 'Providers\\';
+ $files = File::allFiles(app_path('Providers'));
+ foreach ($files as $file) {
+ $class = $namespace . $file->getBasename('.php');
+ $providers[] = $class;
+ }
+
+ $configuredProviders = Config::get('app.providers');
+
+ $this->assertArrayContainsArrayItems(
+ $providers,
+ $configuredProviders,
+ "Provider missing in config/app.php (at providers key)"
+ );
+
+ }
+
+}
diff --git a/tests/TestCase.php b/tests/TestCase.php
--- a/tests/TestCase.php
+++ b/tests/TestCase.php
@@ -24,6 +24,41 @@
}
///
+ /// Custom assertions
+ ///
+
+ /**
+ * Asserts each value of an array are included in another array.
+ *
+ * @param array|Traversable $needles The values to search
+ * @param array|Traversable $haystack The array to check values exist
+ * @param string $message The test message
+ */
+ public static function assertArrayContainsArrayItems ($needles, $haystack, $message) {
+ self::assertThat(
+ self::arrayContainsArrayItems($needles, $haystack),
+ self::isTrue(),
+ $message
+ );
+ }
+
+ /**
+ * Checks if each value of an array are included in another array.
+ *
+ * @param array|Traversable $needles The values to search
+ * @param array|Traversable $haystack The array to check values exist
+ * @return bool true if each $needles value is found in $haystack; otherwise, false
+ */
+ public static function arrayContainsArrayItems ($needles, $haystack) {
+ foreach ($needles as $needle) {
+ if (!in_array($needle, $haystack)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ ///
/// Service providers
///

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 17, 09:49 (20 h, 49 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2248918
Default Alt Text
D458.id1116.diff (2 KB)

Event Timeline