Overview

Namespaces

  • Alchemy
    • core
      • query
      • schema
    • dialect
    • engine
    • orm
    • tests
    • util
      • promise
  • PHP

Classes

  • ANSICompilerTest
  • ANSIDeleteTest
  • ANSIInsertTest
  • ANSISelectTest
  • ANSIUpdateTest
  • BaseTest
  • ColumnTypeTest
  • CompilerTest
  • DataTypeLexerTest
  • ElementTest
  • ExpressionTest
  • ForeignTest
  • InsertTest
  • Language
  • MapperTest
  • MockElement
  • MockPromisable
  • ORMQueryTest
  • PromiseTest
  • QueryTest
  • RelationshipTest
  • ScalarTest
  • SessionIntegrationTest
  • SignalTest
  • UploadedFile
  • WaitableTest
  • Overview
  • Namespace
  • Class
  • Tree
 1: <?php
 2: 
 3: namespace Alchemy\tests;
 4: use Alchemy\core\schema\Column;
 5: 
 6: 
 7: class ColumnTypeTest extends BaseTest {
 8: 
 9:     public function testBool() {
10:         $col = Column::Bool();
11: 
12:         $this->assertEquals(false, $col->decode('0'));
13:         $this->assertEquals(true, $col->decode('1'));
14: 
15:         $this->assertEquals(false, $col->encode(false)->getValue());
16:         $this->assertEquals(true, $col->encode(1)->getValue());
17:     }
18: 
19:     public function testDecimal() {
20:         $col = Column::Decimal();
21: 
22:         $this->assertSame('53.5', $col->decode('53.5'));
23:         $this->assertSame('101', $col->decode('101'));
24: 
25:         $this->assertSame('56', $col->encode('56')->getValue());
26:         $this->assertSame('200.6789', $col->encode('200.6789')->getValue());
27:     }
28: 
29:     public function testInteger() {
30:         $col = Column::Integer();
31: 
32:         $this->assertEquals(53, $col->decode('53'));
33:         $this->assertEquals(101, $col->decode('101'));
34: 
35:         $this->assertEquals(56, $col->encode(56)->getValue());
36:         $this->assertEquals(200, $col->encode(200)->getValue());
37:     }
38: 
39:     public function testString() {
40:         $col = Column::String();
41: 
42:         $this->assertEquals('42', $col->decode(42));
43:         $this->assertEquals('hello', $col->decode('hello'));
44:         $this->assertEquals('hello', $col->encode('hello')->getValue());
45:     }
46: 
47:     public function testTimestamp() {
48:         $col = Column::Timestamp();
49: 
50:         $this->assertEquals(new \Datetime('2008-12-01 00:00:00'), $col->decode('2008-12-01 00:00:00'));
51:         $this->assertEquals('2008-12-01 00:00:00', $col->encode(new \Datetime('2008-12-01 00:00:00'))->getValue());
52:     }
53: }
54: 
API documentation generated by ApiGen 2.8.0