Commit 379fcba8 authored by Jens Segers's avatar Jens Segers

Fixes #100

parent dfa9ff2a
......@@ -78,11 +78,21 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint {
{
$columns = $this->fluent($columns);
// Columns are passed as a default array
if (is_array($columns) && is_int(key($columns)))
{
// Transform the columns to the required array format
$transform = array();
foreach ($columns as $column)
{
$this->collection->deleteIndex($column);
$transform[$column] = 1;
}
$columns = $transform;
}
$this->collection->deleteIndex($columns);
return $this;
}
......
......@@ -34,6 +34,14 @@ class SchemaTest extends PHPUnit_Framework_TestCase {
$index = $this->getIndex('newcollection', 'mykey');
$this->assertEquals(1, $index['key']['mykey']);
Schema::collection('newcollection', function($collection)
{
$collection->index(array('mykey'));
});
$index = $this->getIndex('newcollection', 'mykey');
$this->assertEquals(1, $index['key']['mykey']);
}
public function testUnique()
......@@ -57,6 +65,15 @@ class SchemaTest extends PHPUnit_Framework_TestCase {
$index = $this->getIndex('newcollection', 'uniquekey');
$this->assertEquals(null, $index);
Schema::collection('newcollection', function($collection)
{
$collection->unique('uniquekey');
$collection->dropIndex(array('uniquekey'));
});
$index = $this->getIndex('newcollection', 'uniquekey');
$this->assertEquals(null, $index);
}
public function testBackground()
......
......@@ -9,8 +9,7 @@ use Illuminate\Container\Container;
use Illuminate\Database\DatabaseManager;
use Illuminate\Database\Connectors\ConnectionFactory;
use Illuminate\Events\Dispatcher;
use Illuminate\Cache\ArrayStore;
use Illuminate\Cache\Repository;
use Illuminate\Cache\CacheManager;
# Fake app class
class App extends ArrayObject {
......@@ -20,12 +19,6 @@ class App extends ArrayObject {
# Fake app
$app = new App;
# Event dispatcher
$app['events'] = new Dispatcher;
# Cache driver
$app['cache'] = new Repository(new ArrayStore);
# Load database configuration
$config = require 'config/database.php';
foreach ($config as $key => $value)
......@@ -33,6 +26,13 @@ foreach ($config as $key => $value)
$app['config']["database.$key"] = $value;
}
# Event dispatcher
$app['events'] = new Dispatcher;
# Cache driver
$app['config']['cache.driver'] = 'array';
$app['cache'] = new CacheManager($app);
# Initialize database manager
$app['db.factory'] = new ConnectionFactory(new Container);
$app['db'] = new DatabaseManager($app, $app['db.factory']);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment