Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / modules / contrib / redirect / modules / redirect_404 / tests / src / Unit / SqlRedirectNotFoundStorageTest.php
index b9ba88f3d28120ea3628f5655cc9d776406f331e..42e0224e565a5a87e82918ac958ecf79d8fb7175 100644 (file)
@@ -21,6 +21,13 @@ class SqlRedirectNotFoundStorageTest extends UnitTestCase {
    */
   protected $database;
 
+  /**
+   * Mock config factory.
+   *
+   * @var \Drupal\Core\Config\ConfigFactoryInterface|\PHPUnit_Framework_MockObject_MockObject
+   */
+  protected $configFactory;
+
   /**
    * {@inheritdoc}
    */
@@ -51,4 +58,21 @@ class SqlRedirectNotFoundStorageTest extends UnitTestCase {
     $storage->logRequest("Caf\xc3", LanguageInterface::LANGCODE_DEFAULT);
   }
 
+  /**
+   * Tests that all logs are kept if row limit config is "All".
+   */
+  public function testPurgeOldRequests() {
+    $this->configFactory = $this->getConfigFactoryStub(
+      [
+        'redirect_404.settings' => [
+          'row_limit' => 0,
+        ],
+      ]
+    );
+    $storage = new SqlRedirectNotFoundStorage($this->database, $this->configFactory);
+    $storage->purgeOldRequests();
+    $this->database->expects($this->never())
+      ->method('select');
+  }
+
 }