Skip to content
This repository was archived by the owner on Mar 29, 2024. It is now read-only.

Commit e1f0fa0

Browse files
committed
Add tests for extractor definitions
1 parent 294bd66 commit e1f0fa0

File tree

2 files changed

+87
-0
lines changed

2 files changed

+87
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php declare(strict_types=1);
2+
3+
/**
4+
* This file is part of the pinepain/js-sandbox PHP library.
5+
*
6+
* Copyright (c) 2016-2017 Bogdan Padalko <pinepain@gmail.com>
7+
*
8+
* Licensed under the MIT license: http://opensource.org/licenses/MIT
9+
*
10+
* For the full copyright and license information, please view the
11+
* LICENSE file that was distributed with this source or visit
12+
* http://opensource.org/licenses/MIT
13+
*/
14+
15+
16+
namespace Pinepain\JsSandbox\Tests\Extractors\Definition;
17+
18+
19+
use PHPUnit\Framework\TestCase;
20+
use Pinepain\JsSandbox\Extractors\Definition\ExtractorDefinitionInterface;
21+
use Pinepain\JsSandbox\Extractors\Definition\PlainExtractorDefinition;
22+
23+
24+
class PlainExtractorDefinitionTest extends TestCase
25+
{
26+
public function testWithNext()
27+
{
28+
$name = 'test';
29+
$next = $this->createMock(ExtractorDefinitionInterface::class);
30+
31+
$extractor = new PlainExtractorDefinition($name, $next);
32+
33+
$this->assertSame($name, $extractor->getName());
34+
$this->assertSame($next, $extractor->getNext());
35+
$this->assertSame([$extractor], $extractor->getVariations());
36+
}
37+
38+
public function testWithoutNext()
39+
{
40+
$name = 'test';
41+
42+
$extractor = new PlainExtractorDefinition($name);
43+
44+
$this->assertSame($name, $extractor->getName());
45+
$this->assertNull($extractor->getNext());
46+
$this->assertSame([$extractor], $extractor->getVariations());
47+
}
48+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php declare(strict_types=1);
2+
3+
/**
4+
* This file is part of the pinepain/js-sandbox PHP library.
5+
*
6+
* Copyright (c) 2016-2017 Bogdan Padalko <pinepain@gmail.com>
7+
*
8+
* Licensed under the MIT license: http://opensource.org/licenses/MIT
9+
*
10+
* For the full copyright and license information, please view the
11+
* LICENSE file that was distributed with this source or visit
12+
* http://opensource.org/licenses/MIT
13+
*/
14+
15+
16+
namespace Pinepain\JsSandbox\Tests\Extractors\Definition;
17+
18+
19+
use PHPUnit\Framework\TestCase;
20+
use Pinepain\JsSandbox\Extractors\Definition\ExtractorDefinitionInterface;
21+
use Pinepain\JsSandbox\Extractors\Definition\VariableExtractorDefinition;
22+
23+
24+
class VariableExtractorDefinitionTest extends TestCase
25+
{
26+
public function test()
27+
{
28+
$variations = [
29+
$this->createMock(ExtractorDefinitionInterface::class),
30+
$this->createMock(ExtractorDefinitionInterface::class),
31+
];
32+
33+
$extractor = new VariableExtractorDefinition(...$variations);
34+
35+
$this->assertNull($extractor->getName());
36+
$this->assertNull($extractor->getNext());
37+
$this->assertSame($variations, $extractor->getVariations());
38+
}
39+
}

0 commit comments

Comments
 (0)