Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
 
3
/*
4
 * This file is part of the symfony package.
5
 * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
 
11
$app = 'frontend';
12
$fixtures = 'fixtures/fixtures.yml';
13
require_once(dirname(__FILE__).'/../bootstrap/functional.php');
14
 
15
$t = new lime_test(22);
16
 
17
$authors = Doctrine_Core::getTable('Author')->findAll();
18
$t->is(count($authors), 2);
19
 
20
$author = new Author();
21
 
22
// Accessor overriding
23
$author->setName('Jonathan H. Wage');
24
$author->save();
25
 
26
// Propel style accessors with column name
27
$t->is($author->getName(), $author->name);
28
 
29
// Propel style accessors for id
30
// Also check new author was not created since Jonathan H. Wage exists in fixtures/fixtures.yml
31
$t->is($author->getId(), 1);
32
 
33
// Make sure we still have only 2 authors
34
$authors = Doctrine_Core::getTable('Author')->findAll();
35
$t->is(count($authors), 2);
36
 
37
$article = new Article();
38
$article->title = 'test';
39
 
40
// __toString() automatic column finder
41
$t->is((string) $article, 'test');
42
 
43
// Different style accessors
44
$t->is($article->getAuthor_id(), $article->author_id);
45
$t->is($article->getAuthorId(), $article->author_id);
46
$t->is($article->getauthorId(), $article->author_id);
47
$t->is($article->getAuthorID(), $article->author_id);
48
$t->is($article->getauthor_id(), $article->author_id);
49
 
50
// Camel case columns
51
$camelCase = new CamelCase();
52
$camelCase->testCamelCase = 'camel';
53
$camelCase->setTestCamelCase('camel');
54
 
55
$t->is($camelCase->getTestCamelCase(), 'camel');
56
$t->is($camelCase->gettestCamelCase(), 'camel');
57
$t->is($camelCase->gettestcamelcase(), 'camel');
58
$t->is($camelCase->gettest_camel_case(), 'camel');
59
$t->is($camelCase->getTest_camel_case(), 'camel');
60
 
61
// Propel style accessors work with relationships
62
$article->setAuthor($author);
63
$t->is($article->Author, $author);
64
$t->is($article->getAuthor(), $author);
65
 
66
// Camel case with relationships
67
$t->is($article->getCamelCase()->getTable()->getOption('name'), 'CamelCase');
68
 
69
// Test getDateTimeObject()
70
$dateTime = $article->getDateTimeObject('created_at');
71
$t->is($dateTime instanceof DateTime, true);
72
$t->is($dateTime->format('m/d/Y'), date('m/d/Y'));
73
 
74
try {
75
  $article->getDateTimeObject('author_id');
76
  $t->fail();
77
} catch (Exception $e) {
78
  $t->pass();
79
}
80
 
81
$article->setDateTimeObject('created_at', new DateTime('1985-09-01'));
82
$t->is($article->getDateTimeObject('created_at')->format('m/d/Y'), '09/01/1985');