Skip to content

Commit

Permalink
tests: 'factory' replaced with 'create'
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Dec 11, 2023
1 parent aadf600 commit 5820a4c
Show file tree
Hide file tree
Showing 32 changed files with 105 additions and 105 deletions.
2 changes: 1 addition & 1 deletion tests/DI/Compiler.arguments.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ define('MyConstantTest', 'one');
$container = createContainer(new DI\Compiler, "
services:
lorem:
factory: Lorem(::MyConstantTest, Lorem::DolorSit, NOT_CONSTANT_TEST)
create: Lorem(::MyConstantTest, Lorem::DolorSit, NOT_CONSTANT_TEST)
setup:
- method( @lorem, @self, @container )
- method( @lorem::add(1, 2), [x: ::strtoupper('hello')] )
Expand Down
4 changes: 2 additions & 2 deletions tests/DI/Compiler.functions.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ parameters:
services:
ok:
factory: Service
create: Service
setup:
- not( not(%f%), not(%t%), not(%fn%), not(%dynamic%), %not% )
- string( string(%f%), string(%t%), string(%fn%), string(%dynamic%), %string% )
Expand All @@ -54,7 +54,7 @@ services:
bad1: Service(bool(123))
bad2:
factory: Service
create: Service
setup:
- method(bool(123))
', ['dynamic' => 123]);
Expand Down
2 changes: 1 addition & 1 deletion tests/DI/Compiler.generatedAccessor.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ services:
lorem: Lorem
lorem2:
factory: Lorem
create: Lorem
autowired: no
one: ILoremAccessor
Expand Down
2 changes: 1 addition & 1 deletion tests/DI/Compiler.generatedFactory.nullableParameters.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ $container = @createContainer($compiler, '
services:
article:
factory: Article(%title%, %foo%, %lorem%)
create: Article(%title%, %foo%, %lorem%)
implement: IArticleFactory
parameters: [?string title, ?Foo foo, ?int lorem: null]
Expand Down
4 changes: 2 additions & 2 deletions tests/DI/Compiler.generatedFactory.returnTypes.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ $compiler = new DI\Compiler;
$container = @createContainer($compiler, '
services:
article:
factory: Article(%title%)
create: Article(%title%)
implement: IArticleFactory
parameters: [title]
Expand All @@ -49,7 +49,7 @@ services:
article3:
implement: IArticleFactory
factory: FooArticle
create: FooArticle
');

Assert::type(IArticleFactory::class, $container->getService('article'));
Expand Down
2 changes: 1 addition & 1 deletion tests/DI/Compiler.generatedFactory.scalarParameters.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ $compiler = new DI\Compiler;
$container = @createContainer($compiler, '
services:
article:
factory: Article(%title%)
create: Article(%title%)
implement: IArticleFactory
parameters: [string title]
Expand Down
6 changes: 3 additions & 3 deletions tests/DI/Compiler.services.autowiring.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class Ipsum
$container = createContainer(new DI\Compiler, '
services:
model:
factory: Factory()::createModel
create: Factory()::createModel
setup:
# local methods
- test(_)
Expand All @@ -63,12 +63,12 @@ services:
- @lorem::test
lorem:
factory: Lorem
create: Lorem
alias: @lorem
ipsum:
factory: Ipsum
create: Ipsum
');


Expand Down
4 changes: 2 additions & 2 deletions tests/DI/Compiler.services.byClass.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ services:
three: @\Lorem
one:
factory: Lorem(@\Ipsum)
create: Lorem(@\Ipsum)
two:
factory: Ipsum(1)
create: Ipsum(1)
setup:
- @\Ipsum::foo()
Expand Down
2 changes: 1 addition & 1 deletion tests/DI/Compiler.unknownDefinitionKey.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Assert::throws(function () {
createContainer(new DI\Compiler, '
services:
-
factory: stdClass
create: stdClass
autowire: false
setups: []
foo: bar
Expand Down
2 changes: 1 addition & 1 deletion tests/DI/CompilerExtension.loadDefinitionsFromConfig.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class CompilerExtension extends DI\CompilerExtension


$config = (new DI\Config\Adapters\NeonAdapter)->load(__DIR__ . '/files/compiler.parseServices.namespace.neon');
$config['services']['articlesList']['factory']->arguments[0] = new Reference('extension.articles');
$config['services']['articlesList']['create']->arguments[0] = new Reference('extension.articles');

$builder = new DI\ContainerBuilder;
$compiler = new DI\Compiler($builder);
Expand Down
4 changes: 2 additions & 2 deletions tests/DI/CompilerExtension.loadFromFile.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ class MyExtension extends Nette\DI\CompilerExtension
$config = '
services:
one:
factory: Ipsum
create: Ipsum
';
$ext = new MyExtension;
$ext->setCompiler(new DI\Compiler, 'my');
$res = $ext->loadFromFile(Tester\FileMock::create($config, 'neon'));
Assert::equal([
'services' => [
'one' => [
'factory' => 'Ipsum',
'create' => 'Ipsum',
],
],
], $res);
2 changes: 1 addition & 1 deletion tests/DI/ContainerBuilder.autowiring.chaining.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,6 @@ $container = createContainer($compiler, '
services:
baz:
type: Baz
factory: Foo::createUnknown()::foo()
create: Foo::createUnknown()::foo()
');
Assert::true($container->hasService('baz'));
10 changes: 5 additions & 5 deletions tests/DI/ContainerBuilder.create.error.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ services:
a: stdClass
b: stdClass
bad:
factory: Good
create: Good
setup:
- $a = @\stdClass
');
Expand All @@ -309,7 +309,7 @@ services:
a: stdClass
b: stdClass
bad:
factory: Good
create: Good
setup:
- $a = MethodParam()::foo(@\stdClass)
');
Expand All @@ -323,7 +323,7 @@ services:
a: stdClass
b: stdClass
bad:
factory: MethodParam
create: MethodParam
setup:
- foo
');
Expand All @@ -337,7 +337,7 @@ services:
a: stdClass
b: stdClass
bad:
factory: Good
create: Good
setup:
- bar(@\stdClass)
');
Expand All @@ -351,7 +351,7 @@ services:
a: stdClass
b: stdClass
bad:
factory: Good
create: Good
setup:
- bar(MethodParam()::foo(@\stdClass))
');
Expand Down
2 changes: 1 addition & 1 deletion tests/DI/ContainerBuilder.metadata.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ $compiler = new DI\Compiler;
$container = createContainer($compiler, '
services:
lorem:
factory: stdClass
create: stdClass
tags:
- a
b: c
Expand Down
2 changes: 1 addition & 1 deletion tests/DI/ContainerBuilder.resolve.Container.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ services:
lorem: Lorem
next:
factory: @container::getByType(Lorem)::next()
create: @container::getByType(Lorem)::next()
type: stdClass
');

Expand Down
2 changes: 1 addition & 1 deletion tests/DI/ContainerBuilder.resolveTypes.next.php80.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ require __DIR__ . '/../bootstrap.php';
Assert::exception(function () {
$builder = new DI\ContainerBuilder;
$builder->addDefinition('a')
->setFactory([new Statement([Factory::class, 'createUnion']), 'next']);
->setCreator([new Statement([Factory::class, 'createUnion']), 'next']);
$container = createContainer($builder);
}, Nette\DI\ServiceCreationException::class, "Service 'a': Return type of Factory::createUnion() is expected to not be built-in/complex, 'stdClass|array' given.");
24 changes: 12 additions & 12 deletions tests/DI/ContainerBuilder.resolveTypes.next.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -112,84 +112,84 @@ require __DIR__ . '/../bootstrap.php';
Assert::noError(function () {
$builder = new DI\ContainerBuilder;
$builder->addDefinition('a')
->setFactory([new Statement([Factory::class, 'createClassPhpDoc']), 'next']);
->setCreator([new Statement([Factory::class, 'createClassPhpDoc']), 'next']);
$container = @createContainer($builder); // @return is deprecated
});

Assert::noError(function () {
$builder = new DI\ContainerBuilder;
$builder->addDefinition('a')
->setFactory([new Statement([Factory::class, 'createClass']), 'next']);
->setCreator([new Statement([Factory::class, 'createClass']), 'next']);
$container = createContainer($builder);
});

Assert::noError(function () {
$builder = new DI\ContainerBuilder;
$builder->addDefinition('a')
->setFactory([new Statement([Factory::class, 'createNullableClassPhpDoc']), 'next']);
->setCreator([new Statement([Factory::class, 'createNullableClassPhpDoc']), 'next']);
$container = @createContainer($builder); // @return is deprecated
});

Assert::noError(function () {
$builder = new DI\ContainerBuilder;
$builder->addDefinition('a')
->setFactory([new Statement([Factory::class, 'createNullableClass']), 'next']);
->setCreator([new Statement([Factory::class, 'createNullableClass']), 'next']);
$container = createContainer($builder);
});

Assert::exception(function () {
$builder = new DI\ContainerBuilder;
$builder->addDefinition('a')
->setFactory([new Statement([Factory::class, 'createScalarPhpDoc']), 'next']);
->setCreator([new Statement([Factory::class, 'createScalarPhpDoc']), 'next']);
$container = @createContainer($builder); // @return is deprecated
}, Nette\DI\ServiceCreationException::class, "Service 'a': Return type of Factory::createScalarPhpDoc() is expected to not be built-in/complex, 'array' given.");

Assert::exception(function () {
$builder = new DI\ContainerBuilder;
$builder->addDefinition('a')
->setFactory([new Statement([Factory::class, 'createScalar']), 'next']);
->setCreator([new Statement([Factory::class, 'createScalar']), 'next']);
$container = createContainer($builder);
}, Nette\DI\ServiceCreationException::class, "Service 'a': Return type of Factory::createScalar() is expected to not be built-in/complex, 'array' given.");

Assert::exception(function () {
$builder = new DI\ContainerBuilder;
$builder->addDefinition('a')
->setFactory([new Statement([Factory::class, 'createObjectPhpDoc']), 'next']);
->setCreator([new Statement([Factory::class, 'createObjectPhpDoc']), 'next']);
$container = createContainer($builder);
}, Nette\DI\ServiceCreationException::class, "Service 'a': Unknown service type, specify it or declare return type of factory method.");

Assert::exception(function () {
$builder = new DI\ContainerBuilder;
$builder->addDefinition('a')
->setFactory([new Statement([Factory::class, 'createObject']), 'next']);
->setCreator([new Statement([Factory::class, 'createObject']), 'next']);
$container = createContainer($builder);
}, Nette\DI\ServiceCreationException::class, "Service 'a': Unknown service type, specify it or declare return type of factory method.");

Assert::exception(function () {
$builder = new DI\ContainerBuilder;
$builder->addDefinition('a')
->setFactory([new Statement([Factory::class, 'createObjectNullable']), 'next']);
->setCreator([new Statement([Factory::class, 'createObjectNullable']), 'next']);
$container = createContainer($builder);
}, Nette\DI\ServiceCreationException::class, "Service 'a': Unknown service type, specify it or declare return type of factory method.");

Assert::exception(function () {
$builder = new DI\ContainerBuilder;
$builder->addDefinition('a')
->setFactory([new Statement([Factory::class, 'createMixedPhpDoc']), 'next']);
->setCreator([new Statement([Factory::class, 'createMixedPhpDoc']), 'next']);
$container = createContainer($builder);
}, Nette\DI\ServiceCreationException::class, "Service 'a': Unknown service type, specify it or declare return type of factory method.");

Assert::exception(function () {
$builder = new DI\ContainerBuilder;
$builder->addDefinition('a')
->setFactory([new Statement([Factory::class, 'createMixed']), 'next']);
->setCreator([new Statement([Factory::class, 'createMixed']), 'next']);
$container = createContainer($builder);
}, Nette\DI\ServiceCreationException::class, "Service 'a': Unknown service type, specify it or declare return type of factory method.");

Assert::exception(function () {
$builder = new DI\ContainerBuilder;
$builder->addDefinition('a')
->setFactory([new Statement([Factory::class, 'createGeneric']), 'next']);
->setCreator([new Statement([Factory::class, 'createGeneric']), 'next']);
$container = @createContainer($builder); // @return is deprecated
}, Nette\DI\ServiceCreationException::class, "Service 'a': Class 'T' not found.
Check the return type of Factory::createGeneric().");
12 changes: 6 additions & 6 deletions tests/DI/ContainerBuilder.tagged().phpt
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,22 @@ services:
f1: Foo(tagged(first))
f2: Foo(tagged(second, third))
s1:
factory: Service
create: Service
tags: [first]
s2:
factory: Service
create: Service
tags: [first]
s3:
factory: Service
create: Service
tags: [first: false]
s4:
factory: Service
create: Service
tags: [first: null]
s5:
factory: Service
create: Service
tags: [second]
s6:
factory: Service
create: Service
tags: [third]
');

Expand Down
2 changes: 1 addition & 1 deletion tests/DI/ContainerBuilder.typed().phpt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ services:
s3: ServiceChild
s4: stdClass
s5:
factory: Service
create: Service
autowired: no
');

Expand Down
8 changes: 4 additions & 4 deletions tests/DI/DIExtension.exportTags.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ test('Tag are exported when setting is true', function () {
services:
-
factory: stdClass
create: stdClass
tags:
first: a
second: b
Expand All @@ -46,7 +46,7 @@ test('Tags are not exported when setting is false', function () {
services:
-
factory: stdClass
create: stdClass
tags:
first: a
second: b
Expand All @@ -68,7 +68,7 @@ test('Default tag export behavior without explicit setting', function () {
services:
-
factory: stdClass
create: stdClass
tags:
first: a
second: b
Expand All @@ -91,7 +91,7 @@ test('Specific tag export when listed', function () {
services:
-
factory: stdClass
create: stdClass
tags:
first: a
second: b
Expand Down
Loading

0 comments on commit 5820a4c

Please sign in to comment.