SpecTest.php in Little helpers 7.2
File
tests/Services/SpecTest.php
View source
<?php
namespace Drupal\little_helpers\Services;
use Upal\DrupalUnitTestCase;
class SpecTest extends DrupalUnitTestCase {
public function testKwargs() {
$spec = Spec::fromInfo([
'class' => \SplFixedArray::class,
'constructor' => 'fromArray',
'arguments' => [
'%initial',
],
'calls' => [
[
'offsetSet',
[
0,
'%other',
],
],
],
]);
$this
->assertEqual([
0,
2,
3,
], $spec
->instantiate([
'initial' => [
1,
2,
3,
],
'other' => 0,
])
->toArray());
}
public function testKwargsException() {
$spec = Spec::fromInfo([
'class' => \SplFixedArray::class,
'constructor' => 'fromArray',
'arguments' => [
'%initial',
],
]);
$this
->expectException(MissingArgumentException::class);
$spec
->instantiate();
}
public function testFromInfoHandlesStrings() {
$a = Spec::fromInfo(\SplFixedArray::class)
->instantiate();
$this
->assertInstanceOf(\SplFixedArray::class, $a);
}
}
Classes
Name |
Description |
SpecTest |
Test the instantiating spec class. |