Skip to content
Next
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Minds Backend - Engine
Project
Project
Details
Activity
Releases
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
225
Issues
225
List
Boards
Labels
Service Desk
Milestones
Merge Requests
34
Merge Requests
34
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Security & Compliance
Security & Compliance
Dependency List
Packages
Packages
List
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Minds
Minds Backend - Engine
Compare Revisions
9c0c950e4ad048746c008de68c1080f74d67bdc2...84b15e3c5367880a77b8db3428c8b8a863920530
Source
84b15e3c5367880a77b8db3428c8b8a863920530
Select Git revision
...
Target
9c0c950e4ad048746c008de68c1080f74d67bdc2
Select Git revision
Compare
Commits (2)
(chore) Use more descriptive names for repository methods
· d8b5a302
Guy Thouret
authored
1 day ago
d8b5a302
(chore) Make Boost Campaigns Manager methods more descriptive of what they do/return
· 84b15e3c
Guy Thouret
authored
23 minutes ago
84b15e3c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
381 additions
and
147 deletions
+381
-147
Controllers/api/v2/analytics/views.php
Controllers/api/v2/analytics/views.php
+1
-1
Controllers/api/v2/boost/campaigns.php
Controllers/api/v2/boost/campaigns.php
+3
-3
Controllers/api/v2/boost/fetch/campaigns.php
Controllers/api/v2/boost/fetch/campaigns.php
+1
-1
Core/Blockchain/Events/TokenSaleEvent.php
Core/Blockchain/Events/TokenSaleEvent.php
+1
-1
Core/Blockchain/Events/WithdrawEvent.php
Core/Blockchain/Events/WithdrawEvent.php
+0
-1
Core/Boost/Campaigns/Dispatcher.php
Core/Boost/Campaigns/Dispatcher.php
+2
-2
Core/Boost/Campaigns/ElasticRepository.php
Core/Boost/Campaigns/ElasticRepository.php
+3
-23
Core/Boost/Campaigns/Iterator.php
Core/Boost/Campaigns/Iterator.php
+1
-1
Core/Boost/Campaigns/Manager.php
Core/Boost/Campaigns/Manager.php
+29
-32
Core/Boost/Campaigns/Repository.php
Core/Boost/Campaigns/Repository.php
+2
-22
Core/Entities/Delegates/BoostCampaignResolverDelegate.php
Core/Entities/Delegates/BoostCampaignResolverDelegate.php
+1
-1
Spec/Core/Boost/Campaigns/DispatcherSpec.php
Spec/Core/Boost/Campaigns/DispatcherSpec.php
+5
-5
Spec/Core/Boost/Campaigns/ElasticRepositorySpec.php
Spec/Core/Boost/Campaigns/ElasticRepositorySpec.php
+4
-37
Spec/Core/Boost/Campaigns/ManagerSpec.php
Spec/Core/Boost/Campaigns/ManagerSpec.php
+324
-0
Spec/Core/Boost/Campaigns/RepositorySpec.php
Spec/Core/Boost/Campaigns/RepositorySpec.php
+4
-17
No files found.
Controllers/api/v2/analytics/views.php
View file @
84b15e3c
...
...
@@ -40,7 +40,7 @@ class views implements Interfaces\Api
// Boost Campaigns
try
{
$campaign
=
$campaignsManager
->
get
((
string
)
$urn
);
$campaign
=
$campaignsManager
->
get
CampaignByUrn
((
string
)
$urn
);
$campaignsMetricsManager
->
setCampaign
(
$campaign
)
...
...
This diff is collapsed.
Click to expand it.
Controllers/api/v2/boost/campaigns.php
View file @
84b15e3c
...
...
@@ -50,7 +50,7 @@ class campaigns implements Interfaces\Api
$manager
=
Di
::
_
()
->
get
(
'Boost\Campaigns\Manager'
);
$manager
->
setActor
(
Session
::
getLoggedInUser
());
$response
=
$manager
->
get
List
([
$response
=
$manager
->
get
Campaigns
([
'owner_guid'
=>
Session
::
getLoggedinUserGuid
(),
'limit'
=>
$limit
,
'offset'
=>
$offset
,
...
...
@@ -106,9 +106,9 @@ class campaigns implements Interfaces\Api
try
{
if
(
!
$isEditing
)
{
$campaign
=
$manager
->
create
(
$campaign
,
$_POST
[
'payment'
]
??
null
);
$campaign
=
$manager
->
create
Campaign
(
$campaign
,
$_POST
[
'payment'
]
??
null
);
}
else
{
$campaign
=
$manager
->
update
(
$campaign
,
$_POST
[
'payment'
]
??
null
);
$campaign
=
$manager
->
update
Campaign
(
$campaign
,
$_POST
[
'payment'
]
??
null
);
}
Factory
::
response
([
...
...
This diff is collapsed.
Click to expand it.
Controllers/api/v2/boost/fetch/campaigns.php
View file @
84b15e3c
...
...
@@ -86,7 +86,7 @@ class campaigns implements Interfaces\Api
$data
=
[];
try
{
$result
=
$manager
->
fetch
([
$result
=
$manager
->
getCampaignsAndBoosts
([
'limit'
=>
$limit
,
'from'
=>
$offset
,
'rating'
=>
$rating
,
...
...
This diff is collapsed.
Click to expand it.
Core/Blockchain/Events/TokenSaleEvent.php
View file @
84b15e3c
...
...
@@ -78,7 +78,7 @@ class TokenSaleEvent implements BlockchainEventInterface
return
;
//purchase not found
}
var_dump
(
$log
);
error_log
(
print_r
(
$log
,
true
)
);
//is the requested amount below what has already been recorded
if
(
$transaction
->
getAmount
()
>
$purchase
->
getUnissuedAmount
())
{
return
;
//requested more than can issue
...
...
This diff is collapsed.
Click to expand it.
Core/Blockchain/Events/WithdrawEvent.php
View file @
84b15e3c
...
...
@@ -96,7 +96,6 @@ class WithdrawEvent implements BlockchainEventInterface
try
{
$this
->
manager
->
complete
(
$request
,
$transaction
);
}
catch
(
\Exception
$e
)
{
var_dump
(
$e
);
error_log
(
print_r
(
$e
,
true
));
}
}
...
...
This diff is collapsed.
Click to expand it.
Core/Boost/Campaigns/Dispatcher.php
View file @
84b15e3c
...
...
@@ -47,7 +47,7 @@ class Dispatcher
public
function
onLifecycle
(
string
$campaignUrn
)
{
$this
->
now
=
time
()
*
1000
;
$this
->
campaign
=
$this
->
manager
->
get
(
$campaignUrn
);
$this
->
campaign
=
$this
->
manager
->
get
CampaignByUrn
(
$campaignUrn
);
$this
->
metrics
->
setCampaign
(
$this
->
campaign
);
$this
->
syncIfImpressionsThresholdMet
();
...
...
@@ -81,7 +81,7 @@ class Dispatcher
{
if
(
$this
->
campaign
->
shouldBeCompleted
(
$this
->
now
))
{
error_log
(
"[BoostCampaignsDispatcher] Completing
{
$this
->
campaign
->
getUrn
()
}
..."
);
$this
->
manager
->
complete
(
$this
->
campaign
);
$this
->
manager
->
complete
Campaign
(
$this
->
campaign
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Core/Boost/Campaigns/ElasticRepository.php
View file @
84b15e3c
...
...
@@ -11,7 +11,6 @@ use Minds\Core\Data\ElasticSearch\Prepared\Update;
use
Minds\Core\Di\Di
;
use
Minds\Helpers\Number
;
use
Minds\Helpers\Text
;
use
NotImplementedException
;
class
ElasticRepository
{
...
...
@@ -39,7 +38,7 @@ class ElasticRepository
* @param array $opts
* @return Response
*/
public
function
get
List
(
array
$opts
=
[])
public
function
get
Campaigns
(
array
$opts
=
[])
{
$this
->
opts
=
array_merge
([
'limit'
=>
12
,
...
...
@@ -98,7 +97,7 @@ class ElasticRepository
return
$response
;
}
public
function
fetch
(
array
$opts
=
[])
public
function
getCampaignsAndBoosts
(
array
$opts
=
[])
{
$this
->
opts
=
array_merge
([
'limit'
=>
24
,
...
...
@@ -157,7 +156,7 @@ class ElasticRepository
* @return bool
* @throws Exception
*/
public
function
add
(
Campaign
$campaign
)
public
function
putCampaign
(
Campaign
$campaign
)
{
$body
=
[
'doc'
=>
[
...
...
@@ -217,23 +216,4 @@ class ElasticRepository
return
(
bool
)
$this
->
es
->
request
(
$prepared
);
}
/**
* @param Campaign $campaign
* @return bool
* @throws Exception
*/
public
function
update
(
Campaign
$campaign
)
{
return
$this
->
add
(
$campaign
);
}
/**
* @param Campaign $campaign
* @throws NotImplementedException
*/
public
function
delete
(
Campaign
$campaign
)
{
throw
new
NotImplementedException
();
}
}
This diff is collapsed.
Click to expand it.
Core/Boost/Campaigns/Iterator.php
View file @
84b15e3c
...
...
@@ -130,7 +130,7 @@ class Iterator implements \Iterator
public
function
getList
()
{
$response
=
$this
->
manager
->
get
List
([
$response
=
$this
->
manager
->
get
Campaigns
([
'limit'
=>
$this
->
limit
,
'from'
=>
$this
->
from
,
'offset'
=>
$this
->
offset
,
...
...
This diff is collapsed.
Click to expand it.
Core/Boost/Campaigns/Manager.php
View file @
84b15e3c
...
...
@@ -96,19 +96,20 @@ class Manager
}
/**
* Get a list of boost campaigns
* @param array $opts
* @return Response
* @throws Exception
*/
public
function
get
List
(
array
$opts
=
[])
public
function
get
Campaigns
(
array
$opts
=
[])
{
$opts
=
array_merge
([
'useElastic'
=>
true
],
$opts
);
$response
=
$opts
[
'useElastic'
]
?
$this
->
elasticRepository
->
get
List
(
$opts
)
:
$this
->
repository
->
get
List
(
$opts
);
$this
->
elasticRepository
->
get
Campaigns
(
$opts
)
:
$this
->
repository
->
get
CampaignByGuid
(
$opts
);
return
$response
->
map
(
function
(
Campaign
$campaign
)
{
try
{
...
...
@@ -128,15 +129,16 @@ class Manager
}
/**
* Get a list of boosts and boost campaigns
* @param array $opts
* @return Response|null
*/
public
function
fetch
(
array
$opts
=
[])
public
function
getCampaignsAndBoosts
(
array
$opts
=
[])
{
$response
=
null
;
try
{
$response
=
$this
->
elasticRepository
->
fetch
(
$opts
);
$response
=
$this
->
elasticRepository
->
getCampaignsAndBoosts
(
$opts
);
}
catch
(
Exception
$e
)
{
error_log
(
"[BoostCampaignsManager]
{
$e
}
"
);
}
...
...
@@ -145,12 +147,13 @@ class Manager
}
/**
* Get a single boost campaign by URN string
* @param string $urn
* @param array $opts
* @return Campaign|null
* @throws Exception
*/
public
function
get
(
string
$urn
,
array
$opts
=
[])
public
function
get
CampaignByUrn
(
string
$urn
,
array
$opts
=
[])
{
$opts
=
array_merge
([
'useElastic'
=>
false
...
...
@@ -162,7 +165,7 @@ class Manager
return
null
;
}
$campaigns
=
$this
->
get
List
([
$campaigns
=
$this
->
get
Campaigns
([
'guid'
=>
$guid
,
'useElastic'
=>
$opts
[
'useElastic'
],
])
->
toArray
();
...
...
@@ -180,7 +183,7 @@ class Manager
* @return Campaign
* @throws CampaignException
*/
public
function
create
(
Campaign
$campaign
,
$paymentPayload
=
null
)
public
function
create
Campaign
(
Campaign
$campaign
,
$paymentPayload
=
null
)
{
$campaign
=
$this
->
campaignUrnDelegate
->
onCreate
(
$campaign
);
$campaign
->
setOwner
(
$this
->
actor
);
...
...
@@ -209,8 +212,8 @@ class Manager
$campaign
=
$this
->
normalizeHashtagsDelegate
->
onCreate
(
$campaign
);
$campaign
=
$this
->
paymentsDelegate
->
onCreate
(
$campaign
,
$paymentPayload
);
$this
->
repository
->
add
(
$campaign
);
$this
->
elasticRepository
->
add
(
$campaign
);
$this
->
repository
->
putCampaign
(
$campaign
);
$this
->
elasticRepository
->
putCampaign
(
$campaign
);
return
$campaign
;
}
...
...
@@ -222,9 +225,9 @@ class Manager
* @throws CampaignException
* @throws Exception
*/
public
function
update
(
Campaign
$campaignRef
,
$paymentPayload
=
null
)
public
function
update
Campaign
(
Campaign
$campaignRef
,
$paymentPayload
=
null
)
{
$campaign
=
$this
->
get
(
$campaignRef
->
getUrn
());
$campaign
=
$this
->
get
CampaignByUrn
(
$campaignRef
->
getUrn
());
$isOwner
=
(
string
)
$this
->
actor
->
guid
===
(
string
)
$campaign
->
getOwnerGuid
();
if
(
$this
->
actor
&&
!
$this
->
actor
->
isAdmin
()
&&
!
$isOwner
)
{
...
...
@@ -256,8 +259,8 @@ class Manager
*/
public
function
sync
(
Campaign
$campaign
)
:
Campaign
{
$this
->
repository
->
update
(
$campaign
,
true
);
$this
->
elasticRepository
->
update
(
$campaign
);
$this
->
repository
->
putCampaign
(
$campaign
);
$this
->
elasticRepository
->
putCampaign
(
$campaign
);
return
$campaign
;
}
...
...
@@ -277,12 +280,12 @@ class Manager
*/
public
function
start
(
Campaign
$campaignRef
)
{
$campaign
=
$this
->
get
(
$campaignRef
->
getUrn
());
if
(
$this
->
actor
)
{
throw
new
CampaignException
(
'Campaigns should not be manually started'
);
}
$campaign
=
$this
->
getCampaignByUrn
(
$campaignRef
->
getUrn
());
if
(
$campaign
->
getDeliveryStatus
()
!==
Campaign
::
STATUS_CREATED
)
{
throw
new
CampaignException
(
'Campaign should be in [created] state in order to start it'
);
}
...
...
@@ -299,13 +302,9 @@ class Manager
* @throws CampaignException
* @throws Exception
*/
public
function
cancel
(
Campaign
$campaignRef
)
public
function
cancel
Campaign
(
Campaign
$campaignRef
)
{
$campaign
=
$this
->
get
(
$campaignRef
->
getUrn
());
if
(
!
$campaign
)
{
throw
new
CampaignException
(
'Campaign does not exist'
);
}
$campaign
=
$this
->
getCampaignByUrn
(
$campaignRef
->
getUrn
());
$isOwner
=
(
string
)
$this
->
actor
->
guid
===
(
string
)
$campaign
->
getOwnerGuid
();
...
...
@@ -332,9 +331,9 @@ class Manager
* @throws CampaignException
* @throws Exception
*/
public
function
reject
(
Campaign
$campaignRef
)
public
function
reject
Campaign
(
Campaign
$campaignRef
)
{
$campaign
=
$this
->
get
(
$campaignRef
->
getUrn
());
$campaign
=
$this
->
get
CampaignByUrn
(
$campaignRef
->
getUrn
());
if
(
$this
->
actor
&&
!
$this
->
actor
->
isAdmin
())
{
throw
new
CampaignException
(
'You\'re not allowed to reject this campaign'
);
...
...
@@ -358,9 +357,9 @@ class Manager
* @throws CampaignException
* @throws Exception
*/
public
function
complete
(
Campaign
$campaignRef
)
public
function
complete
Campaign
(
Campaign
$campaignRef
)
{
$campaign
=
$this
->
get
(
$campaignRef
->
getUrn
());
$campaign
=
$this
->
get
CampaignByUrn
(
$campaignRef
->
getUrn
());
if
(
$this
->
actor
)
{
throw
new
CampaignException
(
'Campaigns should not be manually completed'
);
...
...
@@ -384,11 +383,10 @@ class Manager
*/
public
function
onPaymentSuccess
(
Payment
$paymentRef
)
{
$campaign
=
$this
->
get
(
"urn:campaign:
{
$paymentRef
->
getCampaignGuid
()
}
"
);
$campaign
=
$this
->
get
CampaignByUrn
(
"urn:campaign:
{
$paymentRef
->
getCampaignGuid
()
}
"
);
$campaign
=
$this
->
paymentsDelegate
->
onConfirm
(
$campaign
,
$paymentRef
);
$this
->
repository
->
update
(
$campaign
);
$this
->
elasticRepository
->
update
(
$campaign
);
$this
->
sync
(
$campaign
);
$this
->
sendToQueue
(
$campaign
);
}
...
...
@@ -398,11 +396,10 @@ class Manager
*/
public
function
onPaymentFailed
(
Payment
$paymentRef
)
{
$campaign
=
$this
->
get
(
"urn:campaign:
{
$paymentRef
->
getCampaignGuid
()
}
"
);
$campaign
=
$this
->
get
CampaignByUrn
(
"urn:campaign:
{
$paymentRef
->
getCampaignGuid
()
}
"
);
$campaign
=
$this
->
paymentsDelegate
->
onFail
(
$campaign
,
$paymentRef
);
$this
->
repository
->
update
(
$campaign
);
$this
->
elasticRepository
->
update
(
$campaign
);
$this
->
sync
(
$campaign
);
}
protected
function
sendToQueue
(
Campaign
$campaign
)
:
void
...
...
This diff is collapsed.
Click to expand it.
Core/Boost/Campaigns/Repository.php
View file @
84b15e3c
...
...
@@ -11,7 +11,6 @@ use Minds\Core\Data\Cassandra\Prepared\Custom;
use
Minds\Core\Di\Di
;
use
Minds\Helpers\Number
;
use
Minds\Helpers\Text
;
use
NotImplementedException
;
class
Repository
{
...
...
@@ -32,7 +31,7 @@ class Repository
* @return Response
* @throws Exception
*/
public
function
get
List
(
array
$opts
=
[])
public
function
get
CampaignByGuid
(
array
$opts
=
[])
{
$opts
=
array_merge
([
'limit'
=>
12
,
...
...
@@ -117,7 +116,7 @@ class Repository
* @param bool $async
* @return bool
*/
public
function
add
(
Campaign
$campaign
,
$async
=
true
)
public
function
putCampaign
(
Campaign
$campaign
,
$async
=
true
)
{
$cql
=
"INSERT INTO boost_campaigns (type, guid, owner_guid, json_data, delivery_status) VALUES (?, ?, ?, ?, ?)"
;
...
...
@@ -134,23 +133,4 @@ class Repository
return
(
bool
)
$this
->
db
->
request
(
$prepared
,
$async
);
}
/**
* @param Campaign $campaign
* @param bool $async
* @return bool
*/
public
function
update
(
Campaign
$campaign
,
$async
=
true
)
{
return
$this
->
add
(
$campaign
,
$async
);
}
/**
* @param Campaign $campaign
* @throws NotImplementedException
*/
public
function
delete
(
Campaign
$campaign
)
{
throw
new
NotImplementedException
();
}
}
This diff is collapsed.
Click to expand it.
Core/Entities/Delegates/BoostCampaignResolverDelegate.php
View file @
84b15e3c
...
...
@@ -60,7 +60,7 @@ class BoostCampaignResolverDelegate implements ResolverDelegate
foreach
(
$urns
as
$urn
)
{
/** @var Campaign $campaign */
$campaign
=
$manager
->
get
(
$urn
);
$campaign
=
$manager
->
get
CampaignByUrn
(
$urn
);
$entities
[]
=
$campaign
;
}
...
...
This diff is collapsed.
Click to expand it.
Spec/Core/Boost/Campaigns/DispatcherSpec.php
View file @
84b15e3c
...
...
@@ -38,7 +38,7 @@ class DispatcherSpec extends ObjectBehavior
$campaign
->
getUrn
()
->
willReturn
(
'urn:campaign:1000'
);
$this
->
manager
->
get
(
'urn:campaign:1000'
)
$this
->
manager
->
get
CampaignByUrn
(
'urn:campaign:1000'
)
->
shouldBeCalled
()
->
willReturn
(
$initialCampaign
);
...
...
@@ -84,7 +84,7 @@ class DispatcherSpec extends ObjectBehavior
$campaign
->
getUrn
()
->
willReturn
(
'urn:campaign:1000'
);
$this
->
manager
->
get
(
'urn:campaign:1000'
)
$this
->
manager
->
get
CampaignByUrn
(
'urn:campaign:1000'
)
->
shouldBeCalled
()
->
willReturn
(
$initialCampaign
);
...
...
@@ -132,7 +132,7 @@ class DispatcherSpec extends ObjectBehavior
$campaign
->
getUrn
()
->
willReturn
(
'urn:campaign:1000'
);
$this
->
manager
->
get
(
'urn:campaign:1000'
)
$this
->
manager
->
get
CampaignByUrn
(
'urn:campaign:1000'
)
->
shouldBeCalled
()
->
willReturn
(
$campaign
);
...
...
@@ -149,7 +149,7 @@ class DispatcherSpec extends ObjectBehavior
->
shouldBeCalled
()
->
willReturn
(
true
);
$this
->
manager
->
complete
(
$campaign
)
$this
->
manager
->
complete
Campaign
(
$campaign
)
->
shouldBeCalled
()
->
willReturn
(
true
);
...
...
@@ -165,7 +165,7 @@ class DispatcherSpec extends ObjectBehavior
$campaign
->
getUrn
()
->
willReturn
(
'urn:campaign:1000'
);
$this
->
manager
->
get
(
'urn:campaign:1000'
)
$this
->
manager
->
get
CampaignByUrn
(
'urn:campaign:1000'
)
->
shouldBeCalled
()
->
willReturn
(
$campaign
);
...
...
This diff is collapsed.
Click to expand it.
Spec/Core/Boost/Campaigns/ElasticRepositorySpec.php
View file @
84b15e3c
...
...
@@ -65,7 +65,7 @@ class ElasticRepositorySpec extends ObjectBehavior
$this
->
queryBuilder
->
query
()
->
shouldBeCalled
();
$this
->
client
->
request
(
Argument
::
type
(
Prepared\Search
::
class
))
->
shouldBeCalled
()
->
willReturn
(
$esResult
);
$return
=
$this
->
get
List
([
'guid'
=>
1234
]);
$return
=
$this
->
get
Campaigns
([
'guid'
=>
1234
]);
$return
[
0
]
->
shouldBeAnInstanceOf
(
Campaign
::
class
);
}
...
...
@@ -100,12 +100,12 @@ class ElasticRepositorySpec extends ObjectBehavior
$this
->
queryBuilder
->
query
()
->
shouldBeCalled
();
$this
->
client
->
request
(
Argument
::
type
(
Prepared\Search
::
class
))
->
shouldBeCalled
()
->
willReturn
(
$esResult
);
$return
=
$this
->
fetch
([
'quality'
=>
5
]);
$return
=
$this
->
getCampaignsAndBoosts
([
'quality'
=>
5
]);
$return
[
0
]
->
shouldBeAnInstanceOf
(
Campaign
::
class
);
$return
[
1
]
->
shouldBeAnInstanceOf
(
Boost
::
class
);
}
public
function
it_should_
add_an_entry
_to_es
(
Campaign
$campaign
)
public
function
it_should_
put_a_campaign
_to_es
(
Campaign
$campaign
)
{
$campaign
->
getType
()
->
willReturn
(
'newsfeed'
);
$campaign
->
getOwnerGuid
()
->
willReturn
(
'1234'
);
...
...
@@ -130,39 +130,6 @@ class ElasticRepositorySpec extends ObjectBehavior
$campaign
->
getGuid
()
->
willReturn
(
'12345'
);
$this
->
client
->
request
(
Argument
::
type
(
Prepared\Update
::
class
))
->
shouldBeCalled
()
->
willReturn
(
true
);
$this
->
add
(
$campaign
);
}
public
function
it_should_update_an_entry_to_es
(
Campaign
$campaign
)
{
$campaign
->
getType
()
->
willReturn
(
'newsfeed'
);
$campaign
->
getOwnerGuid
()
->
willReturn
(
'1234'
);
$campaign
->
getName
()
->
willReturn
(
'test'
);
$campaign
->
getEntityUrns
()
->
willReturn
(
null
);
$campaign
->
getHashtags
()
->
willReturn
(
null
);
$campaign
->
getNsfw
()
->
willReturn
(
null
);
$campaign
->
getStart
()
->
willReturn
(
'12345'
);
$campaign
->
getEnd
()
->
willReturn
(
'23456'
);
$campaign
->
getBudget
()
->
willReturn
(
'1'
);
$campaign
->
getBudgetType
()
->
willReturn
(
'tokens'
);
$campaign
->
getChecksum
()
->
willReturn
(
'0xdeadbeef'
);
$campaign
->
getImpressions
()
->
willReturn
(
null
);
$campaign
->
getCreatedTimestamp
()
->
willReturn
(
'123456'
);
$campaign
->
getImpressionsMet
()
->
willReturn
(
'2'
);
$campaign
->
getRating
()
->
willReturn
(
'5'
);
$campaign
->
getQuality
()
->
willReturn
(
'5'
);
$campaign
->
getReviewedTimestamp
()
->
willReturn
(
null
);
$campaign
->
getRejectedTimestamp
()
->
willReturn
(
null
);
$campaign
->
getRevokedTimestamp
()
->
willReturn
(
null
);
$campaign
->
getCompletedTimestamp
()
->
willReturn
(
null
);
$campaign
->
getGuid
()
->
willReturn
(
'12345'
);
$this
->
client
->
request
(
Argument
::
type
(
Prepared\Update
::
class
))
->
shouldBeCalled
()
->
willReturn
(
true
);
$this
->
update
(
$campaign
);
}
public
function
it_should_delete_entry_in_es
()
{
$this
->
shouldThrow
(
'NotImplementedException'
)
->
duringDelete
(
new
Campaign
());
$this
->
putCampaign
(
$campaign
);
}
}
This diff is collapsed.
Click to expand it.
Spec/Core/Boost/Campaigns/ManagerSpec.php
View file @
84b15e3c
This diff is collapsed.
Click to expand it.
Spec/Core/Boost/Campaigns/RepositorySpec.php
View file @
84b15e3c
...
...
@@ -62,28 +62,20 @@ class RepositorySpec extends ObjectBehavior
'owner_guid'
=>
1234
,
'type'
=>
'newsfeed'
],
[
'guid'
=>
1235
,
'delivery_status'
=>
''
,
'json_data'
=>
json_encode
(
$this
->
boostCampaignJsonDataMock
),
'owner_guid'
=>
1235
,
'type'
=>
'newsfeed'
],
],
''
);
$this
->
client
->
request
(
Argument
::
type
(
Prepared\Custom
::
class
))
->
shouldBeCalled
()
->
willReturn
(
$rows
);
$return
=
$this
->
get
List
([
'guid'
=>
1234
]);
$return
=
$this
->
get
CampaignByGuid
([
'guid'
=>
1234
]);
$return
[
0
]
->
shouldBeAnInstanceOf
(
Campaign
::
class
);
$return
[
1
]
->
shouldBeAnInstanceOf
(
Campaign
::
class
);
}
public
function
it_should_not_return_a_list_if_no_args_passed
()
{
$this
->
shouldThrow
(
'Exception'
)
->
duringGet
List
();
$this
->
shouldThrow
(
'Exception'
)
->
duringGet
CampaignByGuid
();
}
public
function
it_should_store_a_boost_campaign
()
...
...
@@ -100,7 +92,7 @@ class RepositorySpec extends ObjectBehavior
->
shouldBeCalled
()
->
willReturn
(
true
);
$this
->
add
(
$campaign
)
->
shouldReturn
(
true
);
$this
->
putCampaign
(
$campaign
)
->
shouldReturn
(
true
);
}
public
function
it_should_update_a_boost_campaign
()
...
...
@@ -117,11 +109,6 @@ class RepositorySpec extends ObjectBehavior
->
shouldBeCalled
()
->
willReturn
(
true
);
$this
->
update
(
$campaign
)
->
shouldReturn
(
true
);
}
public
function
it_should_throw_not_implemented_exception_on_delete_a_boost_campaign
()
{
$this
->
shouldThrow
(
'NotImplementedException'
)
->
during
(
'delete'
,
[
new
Campaign
()]);
$this
->
putCampaign
(
$campaign
)
->
shouldReturn
(
true
);
}
}
This diff is collapsed.
Click to expand it.