Permalink
Browse files

Tests: Database - normalize values

  • Loading branch information...
1 parent 3bd4e87 commit 54f2689654aa55da4fc867f46e696e94b392cf75 @juzna committed Oct 8, 2012
Showing with 32 additions and 0 deletions.
  1. +8 −0 tests/Nette/Database/mysql-nette_test1.sql
  2. +24 −0 tests/Nette/Database/normalize.phpt
@@ -78,4 +78,12 @@ INSERT INTO book_tag_alt (book_id, tag_id) VALUES (3, 22);
INSERT INTO book_tag_alt (book_id, tag_id) VALUES (3, 23);
INSERT INTO book_tag_alt (book_id, tag_id) VALUES (3, 24);
+DROP TABLE IF EXISTS bittest;
+CREATE TABLE bittest (
+ id int,
+ flag bit NOT NULL DEFAULT b'0'
+);
+INSERT INTO bittest (id, flag) VALUES (0, 0);
+INSERT INTO bittest (id, flag) VALUES (1, 1);
+
SET FOREIGN_KEY_CHECKS = 1;
@@ -0,0 +1,24 @@
+<?php
+
+/**
+ * Test: Nette\Database\Statement: normalize row converts database types properly to PHP types
+ *
+ * @author Jan Dolecek
+ * @package Nette\Database
+ * @multiple databases.ini
+ */
+
+require __DIR__ . '/connect.inc.php'; // create $connection
+
+Nette\Database\Helpers::loadFromFile($connection, __DIR__ . "/{$driverName}-nette_test1.sql");
+
+
+
+$res = $connection->query("SELECT * FROM bittest");
+$row = $res->fetch();
+Assert::same(0, $row->id);
+Assert::same(false, $row->flag);
+
+$row = $res->fetch();
+Assert::same(1, $row->id);
+Assert::same(true, $row->flag);

0 comments on commit 54f2689

Please sign in to comment.