Skip to content

Commit

Permalink
Fix travis setup
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyFreeAgent committed Sep 17, 2012
1 parent 117608c commit def306c
Show file tree
Hide file tree
Showing 20 changed files with 141 additions and 41 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ env:

before_script:
# MySQL
- sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'create database test; create schema bookstore_schemas; create schema contest; create schema second_hand_books;'; fi"
- sh -c "if [ '$DB' = 'mysql' ]; then mysql -u$DB_USER -e 'SET FOREIGN_KEY_CHECKS = 0; DROP DATABASE IF EXISTS test; DROP SCHEMA IF EXISTS second_hand_books; DROP SCHEMA IF EXISTS contest; DROP SCHEMA IF EXISTS bookstore_schemas; SET FOREIGN_KEY_CHECKS = 1;'; fi"
- sh -c "if [ '$DB' = 'mysql' ]; then mysql -u$DB_USER -e 'CREATE DATABASE test; CREATE SCHEMA bookstore_schemas; CREATE SCHEMA contest; CREATE SCHEMA second_hand_books;'; fi"

# Composer
- wget http://getcomposer.org/composer.phar
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ three database schemas: `bookstore_schemas`, `contest`, and `second_hand_books`.

Here is the set of commands to run in order to setup MySQL:

mysql -uroot -e 'create database test'
mysql -uroot -e 'create schema bookstore_schemas'
mysql -uroot -e 'create schema contest'
mysql -uroot -e 'create schema second_hand_books'
mysql -uroot -e 'SET FOREIGN_KEY_CHECKS = 0; DROP DATABASE IF EXISTS test; DROP SCHEMA IF EXISTS second_hand_books; DROP SCHEMA IF EXISTS contest; DROP SCHEMA IF EXISTS bookstore_schemas; SET FOREIGN_KEY_CHECKS = 1;'
mysql -uroot -e 'CREATE DATABASE test; CREATE SCHEMA bookstore_schemas; CREATE SCHEMA contest; CREATE SCHEMA second_hand_books;'

Once done, build fixtures (default vendor is `mysql`):

bin/propel test:prepare

To match Travis CI MySQL configuration, you must set `@@sql_mode` to `STRICT_ALL_TABLES` in yours.

#### PostgreSQL ####

Create mandatory databases, then run:
Expand Down
7 changes: 4 additions & 3 deletions src/Propel/Generator/Behavior/Sluggable/SluggableBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ public function modifyTable()

if (!$table->hasColumn($this->getParameter('slug_column'))) {
$table->addColumn(array(
'name' => $this->getParameter('slug_column'),
'type' => 'VARCHAR',
'size' => 255
'name' => $this->getParameter('slug_column'),
'type' => 'VARCHAR',
'size' => 255,
'required' => false,
));
// add a unique to column
$unique = new Unique($this->getColumnForParameter('slug_column'));
Expand Down
16 changes: 8 additions & 8 deletions tests/Fixtures/bookstore/behavior-sluggable-schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
<parameter name="replace_pattern" value="/[^\w\/]+/" />
<parameter name="separator" value="/" />
<parameter name="permanent" value="true" />
</behavior>
</table>
</behavior>
</table>

<table name="table_with_scope">
<column name="id" required="true" primaryKey="true" autoIncrement="true" type="INTEGER" />
<column name="scope" required="true" type="INTEGER" />
<column name="title" type="VARCHAR" size="100" primaryString="true" />
<behavior name="sluggable">
<parameter name="scope_column" value="scope" />
<table name="table_with_scope">
<column name="id" required="true" primaryKey="true" autoIncrement="true" type="INTEGER" />
<column name="scope" type="INTEGER" required="false" />
<column name="title" type="VARCHAR" size="100" primaryString="true" />
<behavior name="sluggable">
<parameter name="scope_column" value="scope" />
</behavior>
</table>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public function testComputeWithSchema()
BookstoreContestQuery::create()->deleteAll($this->con);

$store = new Bookstore();
$store->setStoreName('FreeAgent Bookstore');
$store->save($this->con);
$this->assertEquals(0, $store->computeTotalContestEntries($this->con), 'The compute method returns 0 for objects with no related objects');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,16 +266,20 @@ public function testQueryFindOneBySlug()

public function testUniqueViolationWithoutScope()
{
$this->markTestSkipped('Skipping...');

TableWithScopeQuery::create()->deleteAll();
$t = new TableWithScope();
$t->setTitle('Hello, World');
$t->save();
$this->assertEquals('hello-world', $t->getSlug());

$this->setExpectedException('Propel\Runtime\Exception\PropelException');

$t = new TableWithScope();
$t->setTitle('Hello, World');
$t->save();

}

public function testNoUniqueViolationWithScope()
Expand Down
24 changes: 21 additions & 3 deletions tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectRelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,7 @@ public function testSetterCollectionSavesForeignObjects()

$book = new Book();
$book->setTitle('My Book');
$book->setISBN('FA404');
$book->save();

// Modify it but don't save it
Expand All @@ -544,6 +545,7 @@ public function testSetterCollectionSavesForeignObjects()
$book = BookQuery::create()->findPk($book->getPrimaryKey());

$bookClubList1 = new BookClubList();
$bookClubList1->setGroupLeader('fabpot');
$bookClubList1->setBooks($coll);
$bookClubList1->save();

Expand All @@ -569,11 +571,16 @@ public function testSetterCollectionWithNewObjects()
$coll = new ObjectCollection();
$coll->setModel('Book');

$coll[] = new Book();
$coll[] = new Book();
$coll[] = new Book();
for ($i = 0; $i < 3; $i++) {
$b = new Book();
$b->setTitle('Title ' . $i);
$b->setIsbn('1245' . $i);

$coll[] = $b;
}

$bookClubList = new BookClubList();
$bookClubList->setGroupLeader('fabpot');
$bookClubList->setBooks($coll);
$bookClubList->save();

Expand All @@ -595,13 +602,15 @@ public function testSetterCollectionWithExistingObjects()
for ($i = 0; $i < 3; $i++) {
$b = new Book();
$b->setTitle('Book ' . $i);
$b->setIsbn($i);
$b->save();
}

BookPeer::clearInstancePool();
$books = BookQuery::create()->find();

$bookClubList = new BookClubList();
$bookClubList->setGroupLeader('fabpot');
$bookClubList->setBooks($books);
$bookClubList->save();

Expand All @@ -624,6 +633,7 @@ public function testSetterCollectionWithEmptyCollection()
BookListRelQuery::create()->deleteAll();

$bookClubList = new BookClubList();
$bookClubList->setGroupLeader('fabpot');
$bookClubList->setBooks(new ObjectCollection());
$bookClubList->save();

Expand All @@ -645,10 +655,13 @@ public function testSetterCollectionReplacesOldObjectsByNewObjects()
foreach (array('foo', 'bar') as $title) {
$b = new Book();
$b->setTitle($title);
$b->setIsbn('FA404');

$books[] = $b;
}

$bookClubList = new BookClubList();
$bookClubList->setGroupLeader('fabpot');
$bookClubList->setBooks($books);
$bookClubList->save();

Expand All @@ -660,6 +673,8 @@ public function testSetterCollectionReplacesOldObjectsByNewObjects()
foreach (array('bam', 'bom') as $title) {
$b = new Book();
$b->setTitle($title);
$b->setIsbn('FA404');

$books[] = $b;
}

Expand Down Expand Up @@ -687,10 +702,13 @@ public function testSetterCollectionWithCustomNamedFKs()
foreach (array('foo', 'bar', 'test') as $title) {
$b = new Book();
$b->setTitle($title);
$b->setIsbn('FA404');

$books[] = $b;
}

$bookClubList = new BookClubList();
$bookClubList->setGroupLeader('fabpot');
$bookClubList->setFavoriteBooks($books);
$bookClubList->save();

Expand Down
56 changes: 40 additions & 16 deletions tests/Propel/Tests/Generator/Builder/Om/GeneratedObjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -461,18 +461,11 @@ public function testSaveReturnValues()

}

public function testSaveCanInsertEmptyObjects()
{
$b = new Book();
$b->save();
$this->assertFalse($b->isNew());
$this->assertNotNull($b->getId());
}

public function testSaveCanInsertNonEmptyObjects()
{
$b = new Book();
$b->setTitle('foo');
$b->setISBN('FA404');
$b->save();
$this->assertFalse($b->isNew());
$this->assertNotNull($b->getId());
Expand Down Expand Up @@ -530,15 +523,19 @@ public function testIsModifiedIsFalseForSavedObjects()
{
$a = new Author();
$a->setFirstName('Foo');
$a->setLastName('Bar');
$a->save();
$this->assertFalse($a->isModified());
}

public function testIsModifiedIsTrueForSavedObjectsWithModifications()
{
$a = new Author();
$a->save();
$a->setFirstName('Foo');
$a->setLastName('Bar');
$a->save();
$a->setFirstName('Chuck');
$a->setLastName('Norris');
$this->assertTrue($a->isModified());
}

Expand Down Expand Up @@ -582,7 +579,8 @@ public function testIsModifiedIsFalseAfterChangingColumnTypeButNotValue()
public function testIsModifiedAndNullValues()
{
$a = new Author();
$a->setFirstName("");
$a->setFirstName('');
$a->setLastName('Bar');
$a->setAge(0);
$a->save();

Expand All @@ -592,8 +590,6 @@ public function testIsModifiedAndNullValues()
$a->setAge(null);
$this->assertTrue($a->isModified(), "Expected Author to be modified after changing 0-value int column to NULL.");

$a->save();

$a->setFirstName('');
$this->assertTrue($a->isModified(), "Expected Author to be modified after changing NULL column value to empty string.");

Expand Down Expand Up @@ -1080,12 +1076,18 @@ public function testSetterOneToMany()
$coll->setModel('\Propel\Tests\Bookstore\Book');

for ($i = 0; $i < 3; $i++) {
$coll[] = new Book();
$b = new Book();
$b->setTitle('Title ' . $i);
$b->setISBN($i);

$coll[] = $b;
}

$this->assertEquals(3, $coll->count());

$a = new Author();
$a->setFirstName('Chuck');
$a->setLastName('Norris');
$a->setBooks($coll);
$a->save();

Expand Down Expand Up @@ -1159,6 +1161,8 @@ public function testSetterOneToManyWithNoData()

// Basic usage
$a = new Author();
$a->setFirstName('Chuck');
$a->setLastName('Norris');
$a->setBooks($books);
$a->save();

Expand All @@ -1175,6 +1179,7 @@ public function testSetterOneToManySavesForeignObjects()

$book = new Book();
$book->setTitle('My Book');
$book->setISBN('FA404');
$book->save();

// Modify it but don't save it
Expand All @@ -1187,6 +1192,8 @@ public function testSetterOneToManySavesForeignObjects()
$book = BookQuery::create()->findPk($book->getPrimaryKey());

$a = new Author();
$a->setFirstName('Chuck');
$a->setLastName('Norris');
$a->setBooks($coll);
$a->save();

Expand All @@ -1210,11 +1217,17 @@ public function testSetterOneToManyWithNewObjects()
$coll = new ObjectCollection();
$coll->setModel('\Propel\Tests\Bookstore\Book');

$coll[] = new Book();
$coll[] = new Book();
$coll[] = new Book();
for ($i = 0; $i < 3; $i++) {
$b = new Book();
$b->setTitle('Title ' . $i);
$b->setISBN($i);

$coll[] = $b;
}

$a = new Author();
$a->setFirstName('Chuck');
$a->setLastName('Norris');
$a->setBooks($coll);
$a->save();

Expand All @@ -1234,13 +1247,16 @@ public function testSetterOneToManyWithExistingObjects()
for ($i = 0; $i < 3; $i++) {
$b = new Book();
$b->setTitle('Book ' . $i);
$b->setISBN('FA404-' . $i);
$b->save();
}

BookPeer::clearInstancePool();
$books = BookQuery::create()->find();

$a = new Author();
$a->setFirstName('Chuck');
$a->setLastName('Norris');
$a->setBooks($books);
$a->save();

Expand All @@ -1261,6 +1277,8 @@ public function testSetterOneToManyWithEmptyCollection()
AuthorQuery::create()->deleteAll();

$a = new Author();
$a->setFirstName('Chuck');
$a->setLastName('Norris');
$a->setBooks(new ObjectCollection());
$a->save();

Expand All @@ -1280,10 +1298,14 @@ public function testSetterOneToManyReplacesOldObjectsByNewObjects()
foreach (array('foo', 'bar') as $title) {
$b = new Book();
$b->setTitle($title);
$b->setISBN('FA404');

$books[] = $b;
}

$a = new Author();
$a->setFirstName('Chuck');
$a->setLastName('Norris');
$a->setBooks($books);
$a->save();

Expand All @@ -1295,6 +1317,8 @@ public function testSetterOneToManyReplacesOldObjectsByNewObjects()
foreach (array('bam', 'bom') as $title) {
$b = new Book();
$b->setTitle($title);
$b->setISBN('FA404');

$books[] = $b;
}

Expand Down
Loading

0 comments on commit def306c

Please sign in to comment.