Skip to content

Conversation

@mpyw
Copy link
Owner

@mpyw mpyw commented Feb 27, 2020

Minor Breaking Changes

  • Assigning NULL throws InvalidArgumentException instead of PDOException without running queries.
     public function testAssigningNullThrowsExceptionOnNative(): void
     {
-        $this->expectException(PDOException::class);
-        $this->expectExceptionMessage("SQLSTATE[42000]: Syntax error or access violation: 1231 Variable 'foreign_key_checks' can't be set to the value of 'NULL'");
+        $this->expectException(InvalidArgumentException::class);
+        $this->expectExceptionMessage('The value must be a scalar or Mpyw\LaravelMySqlSystemVariableManager\ValueInterface instance.');
 
         $this->onNativeConnection(function (MySqlConnection $db) {
             $db->setSystemVariable('foreign_key_checks', null);
             $db->getPdo();
         });
     }
 
     public function testAssigningNullThrowsExceptionOnEmulation(): void
     {
-        $this->expectException(PDOException::class);
-        $this->expectExceptionMessage("SQLSTATE[42000]: Syntax error or access violation: 1231 Variable 'foreign_key_checks' can't be set to the value of 'NULL'");
+        $this->expectException(InvalidArgumentException::class);
+        $this->expectExceptionMessage('The value must be a scalar or Mpyw\LaravelMySqlSystemVariableManager\ValueInterface instance.');
 
         $this->onEmulatedConnection(function (MySqlConnection $db) {
             $db->setSystemVariable('foreign_key_checks', null);
             $db->getPdo();
         });
     }
  • Assigning NULL throws InvalidArgumentException even if the PDO connection is not established.
-    public function testAssigningNullDoesNotThrowOnUnresolvedConnection(): void
+    public function testAssigningNullThrowsOnUnresolvedNativeConnection(): void
     {
+        $this->expectException(InvalidArgumentException::class);
+        $this->expectExceptionMessage('The value must be a scalar or Mpyw\LaravelMySqlSystemVariableManager\ValueInterface instance.');
+
         $this->onNativeConnection(function (MySqlConnection $db) {
             $db->setSystemVariable('foreign_key_checks', null);
         });
+    }
+
+    public function testAssigningNullThrowsOnUnresolvedEmulatedConnection(): void
+    {
+        $this->expectException(InvalidArgumentException::class);
+        $this->expectExceptionMessage('The value must be a scalar or Mpyw\LaravelMySqlSystemVariableManager\ValueInterface instance.');
+
         $this->onEmulatedConnection(function (MySqlConnection $db) {
             $db->setSystemVariable('foreign_key_checks', null);
         });
-        $this->assertTrue(true);
     }

@mpyw mpyw force-pushed the refactor-scalar-wrapper-value-object branch from 2e5ea7f to bd53b91 Compare February 27, 2020 22:03
@mpyw mpyw merged commit 917c725 into master Feb 27, 2020
@mpyw mpyw deleted the refactor-scalar-wrapper-value-object branch November 19, 2021 02:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants