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: 
 5: use Alchemy\dialect\Compiler;
 6: 
 7: 
 8: class CompilerTest extends BaseTest {
 9: 
10:     public function testConfigStack() {
11:         $comp = new Compiler(array('key' => true));
12: 
13:         $this->assertTrue($comp->getConfig('key'));
14: 
15:         $comp->pushConfig(array('key' => false));
16:         $this->assertFalse($comp->getConfig('key'));
17: 
18:         $comp->popConfig();
19:         $this->assertTrue($comp->getConfig('key'));
20: 
21:         $comp->popConfig();
22:         $this->assertEquals(null, $comp->getConfig('key'));
23:     }
24: 
25: 
26:     public function testFormatRecursion() {
27:         $sub = array('A', 'B', 'C', 'D');
28:         $elements = array('X', 'Y', 'Z', $sub, $sub, $sub);
29: 
30:         // applies /// to tail elements of array, and !!! to their sub-elements
31:         $format = "%s and %s recurse (%4/%s into %1!!!/, /)";
32:         $result = "X and Y recurse (A into ABCD, A into ABCD, A into ABCD)";
33: 
34:         $comp = new Compiler();
35:         $this->assertEquals($result, $comp->format($format, $elements));
36: 
37:         $elements = array('A', array('', 'B', ''), array('', ''));
38:         $format = "%s (%2/%!!+!/, /)";
39: 
40:         $this->assertEquals("A (B)", $comp->format($format, $elements));
41: 
42:         $elements = array('@', $sub, $sub);
43:         $format = "{%2$3//, /} %1\$s (%3$2// + /)";
44: 
45:         $this->assertEquals("{C, D} @ (B + C + D)", $comp->format($format, $elements));
46:     }
47: }
API documentation generated by ApiGen 2.8.0