Code Duplication    Length = 33-34 lines in 2 locations

test/unit/test/ProtoFactory/ProposalFactoryTest.php 1 location

@@ 44-77 (lines=34) @@
41
        parent::setUp();
42
    }
43
44
    public function testCreate()
45
    {
46
        $serializedIdentity = SerializedIdentityFactory::fromBytes('Alice', 'Bob');
47
        $nonce = 'u58920du89f';
48
        $txId = 'MyTransactionId';
49
50
        $channelHeader = ChannelHeaderFactory::create('MyChannelId');
51
        $channelHeader->setTxId($txId);
52
53
        $header = HeaderFactory::create(SignatureHeaderFactory::create(
54
            $serializedIdentity,
55
            $nonce
56
        ), $channelHeader);
57
58
        $chaincodeInvocationSpec = ChaincodeInvocationSpecFactory::fromArgs([
59
            'foo',
60
            'bar',
61
        ]);
62
63
        $chaincodeProposalPayload = ChaincodeProposalPayloadFactory::fromChaincodeInvocationSpec(
64
            $chaincodeInvocationSpec
65
        );
66
67
        $result = ProposalFactory::create($header, $chaincodeProposalPayload->serializeToString());
68
        self::assertInstanceOf(Proposal::class, $result);
69
        self::assertContains('Alice', $result->getHeader());
70
        self::assertContains('Bob', $result->getHeader());
71
        self::assertContains('MyChannelId', $result->getHeader());
72
        self::assertContains('MyTransactionId', $result->getHeader());
73
        self::assertContains('u58920du89f', $result->getHeader());
74
        self::assertContains('foo', $result->getPayload());
75
        self::assertContains('bar', $result->getPayload());
76
        self::assertSame('', $result->getExtension());
77
    }
78
79
    /**
80
     * @dataProvider getChainCodeProposalDataset

test/unit/test/ProtoFactory/SignedProposalFactoryTest.php 1 location

@@ 38-70 (lines=33) @@
35
 */
36
class SignedProposalFactoryTest extends TestCase
37
{
38
    public function testFromProposal()
39
    {
40
        $serializedIdentity = SerializedIdentityFactory::fromBytes('Alice', 'Bob');
41
        $nonce = 'u58920du89f';
42
        $txId = 'MyTransactionId';
43
44
        $channelHeader = ChannelHeaderFactory::create('MyChannelId');
45
        $channelHeader->setTxId($txId);
46
47
        $header = HeaderFactory::create(SignatureHeaderFactory::create(
48
            $serializedIdentity,
49
            $nonce
50
        ), $channelHeader);
51
52
        $chaincodeProposalPayload = ChaincodeProposalPayloadFactory::fromChaincodeInvocationSpecArgs([
53
            'foo',
54
            'bar',
55
        ]);
56
57
        $proposal = ProposalFactory::create($header, $chaincodeProposalPayload->serializeToString());
58
59
        $result = SignedProposalFactory::fromProposal($proposal, 'MySignature');
60
61
        self::assertInstanceOf(SignedProposal::class, $result);
62
        self::assertContains('Alice', $result->getProposalBytes());
63
        self::assertContains('Bob', $result->getProposalBytes());
64
        self::assertContains('MyChannelId', $result->getProposalBytes());
65
        self::assertContains('MyTransactionId', $result->getProposalBytes());
66
        self::assertContains('u58920du89f', $result->getProposalBytes());
67
        self::assertContains('foo', $result->getProposalBytes());
68
        self::assertContains('bar', $result->getProposalBytes());
69
        self::assertSame('MySignature', $result->getSignature());
70
    }
71
}
72