-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSubSpecTest.php
More file actions
executable file
·74 lines (65 loc) · 1.79 KB
/
SubSpecTest.php
File metadata and controls
executable file
·74 lines (65 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
/*
* (c) Carsten Klee <mailme.klee@yahoo.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace CK\MARCspec\Test;
use CK\MARCspec\Field;
use CK\MARCspec\MARCspec;
use CK\MARCspec\Subfield;
use CK\MARCspec\SubSpec;
use PHPUnit\Framework\TestCase;
class SubSpecTest extends TestCase
{
protected function subspec($arg1, $arg2, $arg3)
{
return new SubSpec($arg1, $arg2, $arg3);
}
protected function marcspec($arg)
{
return new MARCspec($arg);
}
/****
* invalid data types
***/
/**
* @expectedException InvalidArgumentException
*/
public function testInvalidSubSpec1Decode()
{
$this->subspec('245', '=', '300');
}
/**
* @expectedException CK\MARCspec\Exception\InvalidMARCspecException
*/
public function testInvalidSubSpec2Decode()
{
$this->subspec(new Field('245'), '=', new Subfield('245'));
}
/**
* @expectedException CK\MARCspec\Exception\InvalidMARCspecException
*/
public function testInvalidSubSpec3Decode()
{
$this->marcspec('...{$a{$b}}');
}
/**
* assert true.
*/
public function testValidSubSpec1()
{
$marcspec1 = $this->marcspec('245$a');
$marcspec2 = $this->marcspec('245$b');
$subspec = $this->subspec($marcspec1, '=', $marcspec2);
$left = $subspec->getLeftSubTerm();
$right = $subspec->getRightSubTerm();
$operator = $subspec->getOperator();
$field = $left->getField();
$this->assertSame('245', $field->getTag());
$subfields = $right->getSubfields();
$this->assertInstanceOf('CK\MARCspec\Subfield', $subfields[0]);
$this->assertSame('=', $operator);
}
}