public function test_create_write()
{
$orderCopywriterMock = $this->getMock('OrderCopywriter', ['save']);
$orderCopywriterMock
->expects($this->once())->method('save')
->will($this->returnCallback(function() use ($orderCopywriterMock) {$orderCopywriterMock->id = 'mock_order_copywriter_id'; return true; }));
$orderCopywriterPriceMock = $this->getMock('OrderPlannedPrice', ['mock_getOrderCopywriterPrice']);
$orderCopywriterPriceMock
->expects($this->once())->method('mock_getOrderCopywriterPrice')
->with($this->equalTo([
'contentLength' => 'mock_max_content_length',
'configTextLength' => 1000,
'configTextPrice' => 200,
]))
->will($this->returnValue(100));
$transactionMock = $this->getMock('Transaction', ['mock_createTransaction']);
$transactionMock
->expects($this->once())->method('mock_createTransaction')
->with(
$this->equalTo([
'type' => Transaction::TYPE_COPYWRITER_ORDER,
'status' => Transaction::STATUS_PLANNED,
'order_copywriter_id' => 'mock_order_copywriter_id',
'from_user_id' => 'mock_user_id',
'amount' => 100,
'system_transaction' => 0,
'comment' => 'Оплата за заказ на написание контента #mock_order_copywriter_id',
]))
->will($this->returnValue(true));
$options = [
'user_id' => 'mock_user_id',
'url' => 'mock_url',
'keywords' => 'mock_keywords',
'comment' => 'mock_comment',
'min_content_length' => 'mock_min_content_length',
'max_content_length' => 'mock_max_content_length',
'type' => OrderCopywriter::TYPE_WRITE,
];
BaseDI::$mockClasses = [
'OrderPlannedPrice::getOrderCopywriterPrice' => $orderCopywriterPriceMock,
'Transaction::createTransaction' => $transactionMock,
];
BaseDI::$mockNewClasses = [
'OrderCopywriter' => $orderCopywriterMock,
];
$this->assertNotNull(OrderCopywriter::createCopywriterOrder($options));
}