-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
353 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
suites: | ||
main_suite: | ||
namespace: Meritoo\CommonBundle | ||
verbose: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
/** | ||
* (c) Meritoo.pl, http://www.meritoo.pl | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace spec\Meritoo\CommonBundle\Application; | ||
|
||
use Meritoo\Common\ValueObject\Version; | ||
use Meritoo\CommonBundle\Application\Descriptor; | ||
use PhpSpec\ObjectBehavior; | ||
|
||
class DescriptorSpec extends ObjectBehavior | ||
{ | ||
public function it_is_initializable(): void | ||
{ | ||
$this->shouldHaveType(Descriptor::class); | ||
} | ||
|
||
public function it_has_name(): void | ||
{ | ||
$this->getName()->shouldReturn('test of name'); | ||
} | ||
|
||
public function it_has_description(): void | ||
{ | ||
$this->getDescription()->shouldReturn('test of description'); | ||
} | ||
|
||
public function it_has_version(): void | ||
{ | ||
$this->getVersion()->shouldBeLike(new Version(1, 0, 1)); | ||
} | ||
|
||
public function it_is_convertible_to_string(): void | ||
{ | ||
$this->__toString()->shouldReturn('test of name | test of description | 1.0.1'); | ||
} | ||
|
||
public function it_is_convertible_to_string_without_version(): void | ||
{ | ||
$this->beConstructedWith('test of name', 'test of description', null); | ||
$this->__toString()->shouldReturn('test of name | test of description | -'); | ||
} | ||
|
||
public function let(): void | ||
{ | ||
$this->beConstructedWith('test of name', 'test of description', new Version(1, 0, 1)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
<?php | ||
|
||
/** | ||
* (c) Meritoo.pl, http://www.meritoo.pl | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace spec\Meritoo\CommonBundle\Bundle; | ||
|
||
use Meritoo\Common\Collection\StringCollection; | ||
use Meritoo\CommonBundle\Bundle\Descriptor; | ||
use PhpSpec\ObjectBehavior; | ||
|
||
class DescriptorSpec extends ObjectBehavior | ||
{ | ||
public function it_is_initializable(): void | ||
{ | ||
$this->shouldHaveType(Descriptor::class); | ||
} | ||
|
||
public function it_has_name(): void | ||
{ | ||
$this->getName()->shouldReturn(''); | ||
$value = 'Test'; | ||
|
||
$this->setName($value); | ||
$this->getName()->shouldReturn($value); | ||
} | ||
|
||
public function it_has_short_name(): void | ||
{ | ||
$this->getShortName()->shouldReturn(''); | ||
} | ||
|
||
public function it_has_configuration_root_name(): void | ||
{ | ||
$this->getConfigurationRootName()->shouldReturn(''); | ||
$value = 'TestConfiguration'; | ||
|
||
$this->setConfigurationRootName($value); | ||
$this->getConfigurationRootName()->shouldReturn($value); | ||
} | ||
|
||
public function it_has_root_namespace(): void | ||
{ | ||
$this->getRootNamespace()->shouldReturn(''); | ||
$value = 'My\\TestBundle'; | ||
|
||
$this->setRootNamespace($value); | ||
$this->getRootNamespace()->shouldReturn($value); | ||
} | ||
|
||
public function it_has_path(): void | ||
{ | ||
$this->getPath()->shouldReturn(''); | ||
$value = '/my/test-bundle'; | ||
|
||
$this->setPath($value); | ||
$this->getPath()->shouldReturn($value); | ||
} | ||
|
||
public function it_has_parent_bundle_descriptor(): void | ||
{ | ||
$this->getParentBundleDescriptor()->shouldReturn(null); | ||
$value = new Descriptor('ParentBundle', 'ThisIsParent'); | ||
|
||
$this->setParentBundleDescriptor($value); | ||
$this->getParentBundleDescriptor()->shouldReturn($value); | ||
} | ||
|
||
public function it_has_child_bundle_descriptor(): void | ||
{ | ||
$this->getChildBundleDescriptor()->shouldReturn(null); | ||
$value = new Descriptor('ChildBundle', 'ThisIsChild'); | ||
|
||
$this->setChildBundleDescriptor($value); | ||
$this->getChildBundleDescriptor()->shouldReturn($value); | ||
} | ||
|
||
public function it_has_data_fixtures(): void | ||
{ | ||
$this->getDataFixtures()->shouldBeLike(new StringCollection()); | ||
|
||
$value = [ | ||
'Data/Fixture1', | ||
'Data/Fixture2', | ||
]; | ||
|
||
$this->addDataFixtures($value); | ||
$this->getDataFixtures()->shouldBeLike(new StringCollection($value)); | ||
} | ||
|
||
public function it_has_data_fixtures_directory_path(): void | ||
{ | ||
$this->getDataFixturesDirectoryPath()->shouldBeNull(); | ||
$value = '/my/test-bundle'; | ||
|
||
$this->setPath($value); | ||
$this->getDataFixturesDirectoryPath()->shouldReturn($value . '/' . Descriptor::PATH_DATA_FIXTURES); | ||
} | ||
|
||
public function it_has_file(): void | ||
{ | ||
$this->hasFile('')->shouldReturn(false); | ||
|
||
$path = '/my/test-bundle'; | ||
$this->setPath($path); | ||
$this->hasFile('test/test')->shouldReturn(false); | ||
|
||
$path = '/my/test-bundle'; | ||
$this->setPath($path); | ||
$this->hasFile('/my/test-bundle/configuration/routing/authorized.yaml')->shouldReturn(true); | ||
} | ||
|
||
public function it_is_convertible_to_array(): void | ||
{ | ||
$this->toArray()->shouldReturn([ | ||
'name' => '', | ||
'shortName' => '', | ||
'configurationRootName' => '', | ||
'rootNamespace' => '', | ||
'path' => '', | ||
'dataFixtures' => [], | ||
]) | ||
; | ||
|
||
$name = 'Test'; | ||
$configurationRootName = 'TestConfiguration'; | ||
$rootNamespace = 'My\\TestBundle'; | ||
$path = '/my/test-bundle'; | ||
$fixturesPaths = [ | ||
'Data/Fixture1', | ||
'Data/Fixture2', | ||
]; | ||
|
||
$this->setName($name); | ||
$this->setConfigurationRootName($configurationRootName); | ||
$this->setRootNamespace($rootNamespace); | ||
$this->setPath($path); | ||
$this->addDataFixtures($fixturesPaths); | ||
|
||
$this->toArray()->shouldReturn([ | ||
'name' => $name, | ||
'shortName' => 'test', | ||
'configurationRootName' => $configurationRootName, | ||
'rootNamespace' => $rootNamespace, | ||
'path' => $path, | ||
'dataFixtures' => $fixturesPaths, | ||
]) | ||
; | ||
} | ||
|
||
public function it_may_be_created_from_array(): void | ||
{ | ||
//todo | ||
} | ||
|
||
public function it_may_be_created_from_bundle(): void | ||
{ | ||
//todo | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
/** | ||
* (c) Meritoo.pl, http://www.meritoo.pl | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace spec\Meritoo\CommonBundle\Bundle; | ||
|
||
use Meritoo\Common\Collection\StringCollection; | ||
use Meritoo\CommonBundle\Bundle\Descriptor; | ||
use Meritoo\CommonBundle\Bundle\Descriptors; | ||
use PhpSpec\ObjectBehavior; | ||
|
||
class DescriptorsSpec extends ObjectBehavior | ||
{ | ||
public function it_is_initializable(): void | ||
{ | ||
$this->shouldHaveType(Descriptors::class); | ||
} | ||
|
||
public function is_a_collection(): void | ||
{ | ||
$this->shouldBeAnInstanceOf(StringCollection::class); | ||
} | ||
|
||
public function it_has_not_descriptor(): void | ||
{ | ||
$this->beConstructedWith([new Descriptor()]); | ||
$this->getDescriptor('Test\Namespace\ClassName')->shouldBeNull(); | ||
} | ||
|
||
public function it_has_descriptor(): void | ||
{ | ||
$descriptor = new Descriptor('Test', '', 'Test\Namespace'); | ||
|
||
$this->beConstructedWith([ | ||
$descriptor, | ||
]); | ||
|
||
$this | ||
->getDescriptor('Test\Namespace\ClassName') | ||
->shouldBeLike($descriptor) | ||
; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.