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: require_once "alchemy/alchemy.php";
 5: 
 6: use Alchemy\engine\Engine;
 7: use Alchemy\dialect\SQLiteCompiler;
 8: use Alchemy\dialect\MySQLCompiler;
 9: 
10: 
11: date_default_timezone_set('UTC');
12: ini_set('display_errors', '1');
13: error_reporting(E_ALL | E_STRICT);
14: 
15: // Update include path so that the following includes work
16: set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__));
17: 
18: require_once 'resources/UploadedFile.php';
19: require_once 'resources/Language.php';
20: 
21: 
22: 
23: abstract class BaseTest extends \PHPUnit_Framework_TestCase {
24: 
25:     protected $fnCallback;
26: 
27:     public function assertExpectedString($file, $str) {
28:         $file = dirname(__FILE__)
29:               . DIRECTORY_SEPARATOR
30:               . "expected"
31:               . DIRECTORY_SEPARATOR
32:               . $file;
33:         return $this->assertStringEqualsFile($file, $str);
34:     }
35: 
36: 
37:     protected function getMySQLEngine() {
38:         return new Engine(new MySQLCompiler(), "mysql:dbname=myapp_test;host=127.0.0.1", 'travis');
39:     }
40: 
41: 
42:     protected function getSQLiteEngine() {
43:         return new Engine(new SQLiteCompiler(), 'sqlite::memory:');
44:     }
45: 
46: 
47:     /**
48:      * Assert that a callable throws an exception of a particular type when called
49:      */
50:     protected function assertThrows($exception, $fnSubject) {
51:         $args = func_get_args();
52:         array_shift($args);
53:         array_shift($args);
54: 
55:         try {
56:             call_user_func_array($fnSubject, $args);
57:         } catch(\Exception $e) {
58:             return is_string($exception)
59:                 ? $this->assertInstanceOf($exception, $e)
60:                 : $this->assertSame($exception, $e);
61:         }
62: 
63:         return $this->fail("{$exception} was not thrown.");
64:     }
65: 
66: 
67:     /**
68:      * Use this method to start a mock expects() builder, then pass
69:      * $this->fnCallback to the function you want to test
70:      */
71:     protected function expectsCallback($times) {
72:         $this->fnCallback = $this->getMock('stdClass', array('__invoke'));
73:         return $this->fnCallback->expects($times)->method('__invoke');
74:     }
75: }
76: 
API documentation generated by ApiGen 2.8.0