更新代码
This commit is contained in:
26
vendor/xethron/laravel-4-generators/spec/Way/Generators/Compilers/TemplateCompilerSpec.php
vendored
Normal file
26
vendor/xethron/laravel-4-generators/spec/Way/Generators/Compilers/TemplateCompilerSpec.php
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace spec\Way\Generators\Compilers;
|
||||
|
||||
use PhpSpec\ObjectBehavior;
|
||||
use Prophecy\Argument;
|
||||
|
||||
class TemplateCompilerSpec extends ObjectBehavior
|
||||
{
|
||||
function it_is_initializable()
|
||||
{
|
||||
$this->shouldHaveType('Way\Generators\Compilers\TemplateCompiler');
|
||||
}
|
||||
|
||||
function it_compiles_a_template_with_data()
|
||||
{
|
||||
$data = [
|
||||
'NAME' => 'Foo',
|
||||
'PARENT' => 'Bar'
|
||||
];
|
||||
|
||||
$this->compile(
|
||||
'class $NAME$ extends $PARENT$ {}', $data
|
||||
) ->shouldBe('class Foo extends Bar {}');
|
||||
}
|
||||
}
|
||||
41
vendor/xethron/laravel-4-generators/spec/Way/Generators/GeneratorSpec.php
vendored
Normal file
41
vendor/xethron/laravel-4-generators/spec/Way/Generators/GeneratorSpec.php
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace spec\Way\Generators;
|
||||
|
||||
use PhpSpec\ObjectBehavior;
|
||||
use Prophecy\Argument;
|
||||
use Way\Generators\Filesystem\Filesystem;
|
||||
use Way\Generators\Compilers\TemplateCompiler;
|
||||
|
||||
class GeneratorSpec extends ObjectBehavior {
|
||||
|
||||
function let(Filesystem $file)
|
||||
{
|
||||
// By default, we'll set the file to not exist
|
||||
// This may be overridden, though
|
||||
$file->exists('foo.txt')->willReturn(false);
|
||||
|
||||
$this->beConstructedWith($file);
|
||||
}
|
||||
|
||||
function it_is_initializable()
|
||||
{
|
||||
$this->shouldHaveType('Way\Generators\Generator');
|
||||
}
|
||||
|
||||
function it_compiles_a_template(Filesystem $file, TemplateCompiler $compiler)
|
||||
{
|
||||
$template = 'class $NAME$ {}';
|
||||
$data = ['NAME' => 'Bar'];
|
||||
$compiledTemplate = 'class Bar {}';
|
||||
|
||||
$file->get('template.txt')->shouldBeCalled()->willReturn($template);
|
||||
$compiler->compile($template, $data)->shouldBeCalled()->willReturn($compiledTemplate);
|
||||
|
||||
// When we call compile, we expect the method to
|
||||
// fetch the given template, compile it down,
|
||||
// and return the results
|
||||
$this->compile('template.txt', $data, $compiler)->shouldBe($compiledTemplate);
|
||||
}
|
||||
|
||||
}
|
||||
42
vendor/xethron/laravel-4-generators/spec/Way/Generators/Parsers/MigrationFieldsParserSpec.php
vendored
Normal file
42
vendor/xethron/laravel-4-generators/spec/Way/Generators/Parsers/MigrationFieldsParserSpec.php
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace spec\Way\Generators\Parsers;
|
||||
|
||||
use PhpSpec\ObjectBehavior;
|
||||
use Prophecy\Argument;
|
||||
|
||||
class MigrationFieldsParserSpec extends ObjectBehavior {
|
||||
|
||||
function it_is_initializable()
|
||||
{
|
||||
$this->shouldHaveType('Way\Generators\Parsers\MigrationFieldsParser');
|
||||
}
|
||||
|
||||
function it_parses_a_string_of_fields()
|
||||
{
|
||||
$this->parse('name:string')->shouldReturn([
|
||||
['field' => 'name', 'type' => 'string']
|
||||
]);
|
||||
|
||||
$this->parse('name:string, age:integer')->shouldReturn([
|
||||
['field' => 'name', 'type' => 'string'],
|
||||
['field' => 'age', 'type' => 'integer']
|
||||
]);
|
||||
|
||||
$this->parse('name:string:nullable, age:integer')->shouldReturn([
|
||||
['field' => 'name', 'type' => 'string', 'decorators' => ['nullable']],
|
||||
['field' => 'age', 'type' => 'integer']
|
||||
]);
|
||||
|
||||
$this->parse('name:string(15):nullable')->shouldReturn([
|
||||
['field' => 'name', 'type' => 'string', 'args' => '15', 'decorators' => ['nullable']]
|
||||
]);
|
||||
|
||||
$this->parse('name:double(15,8):nullable:default(10), age:integer')->shouldReturn([
|
||||
['field' => 'name', 'type' => 'double', 'args' => '15,8', 'decorators' => ['nullable', 'default(10)']],
|
||||
['field' => 'age', 'type' => 'integer']
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
36
vendor/xethron/laravel-4-generators/spec/Way/Generators/Parsers/MigrationNameParserSpec.php
vendored
Normal file
36
vendor/xethron/laravel-4-generators/spec/Way/Generators/Parsers/MigrationNameParserSpec.php
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace spec\Way\Generators\Parsers;
|
||||
|
||||
use PhpSpec\ObjectBehavior;
|
||||
use Prophecy\Argument;
|
||||
|
||||
class MigrationNameParserSpec extends ObjectBehavior
|
||||
{
|
||||
function it_is_initializable()
|
||||
{
|
||||
$this->shouldHaveType('Way\Generators\Parsers\MigrationNameParser');
|
||||
}
|
||||
|
||||
function it_parses_a_basic_migration_name()
|
||||
{
|
||||
$this->parse('create_orders_table')->shouldBe([
|
||||
'action' => 'create',
|
||||
'table' => 'orders'
|
||||
]);
|
||||
}
|
||||
|
||||
function it_parses_a_complex_migration_name()
|
||||
{
|
||||
$this->parse('add_first_name_and_last_name_to_recent_orders_table')->shouldBe([
|
||||
'action' => 'add',
|
||||
'table' => 'recent_orders'
|
||||
]);
|
||||
|
||||
$this->parse('remove_first_name_from_users_table')->shouldBe([
|
||||
'action' => 'remove',
|
||||
'table' => 'users'
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
22
vendor/xethron/laravel-4-generators/spec/Way/Generators/SchemaCreatorSpec.php
vendored
Normal file
22
vendor/xethron/laravel-4-generators/spec/Way/Generators/SchemaCreatorSpec.php
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace spec\Way\Generators;
|
||||
|
||||
use PhpSpec\ObjectBehavior;
|
||||
use Prophecy\Argument;
|
||||
use Way\Generators\Compilers\TemplateCompiler;
|
||||
use Way\Generators\Filesystem\Filesystem;
|
||||
|
||||
class SchemaCreatorSpec extends ObjectBehavior {
|
||||
|
||||
public function let(Filesystem $file, TemplateCompiler $compiler)
|
||||
{
|
||||
$this->beConstructedWith($file, $compiler);
|
||||
}
|
||||
|
||||
function it_is_initializable()
|
||||
{
|
||||
$this->shouldHaveType('Way\Generators\SchemaCreator');
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user