Commit 97f72362 by Евгений

Улучшение #19462

Добавление в настройки городов переменных.
1 parent 5543e4fd
Showing with 59 additions and 2 deletions
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "3b1892b240e8c75618eef0b2ff047f9b", "content-hash": "00fe65321384040b3a686ba34d323406",
"packages": [ "packages": [
{ {
"name": "asm89/stack-cors", "name": "asm89/stack-cors",
......
...@@ -16,6 +16,7 @@ class CityTest extends TestCase ...@@ -16,6 +16,7 @@ class CityTest extends TestCase
use RefreshDatabase; use RefreshDatabase;
private $token; private $token;
private $token2;
private $token_main; private $token_main;
protected function setUp(): void protected function setUp(): void
...@@ -36,6 +37,10 @@ class CityTest extends TestCase ...@@ -36,6 +37,10 @@ class CityTest extends TestCase
'created_by' => $this->user->getKey() 'created_by' => $this->user->getKey()
]); ]);
$this->token2 = factory(Tokens::class)->create([
'created_by' => $this->user->getKey()
]);
$this->token_main = factory(Tokens::class)->create([ $this->token_main = factory(Tokens::class)->create([
'type' => Tokens::MAIN, 'type' => Tokens::MAIN,
]); ]);
...@@ -55,7 +60,7 @@ class CityTest extends TestCase ...@@ -55,7 +60,7 @@ class CityTest extends TestCase
]); ]);
} }
public function test_add_city(){ public function test_add_city_and_variables(){
$ids = Dictionary::all()->pluck('id'); $ids = Dictionary::all()->pluck('id');
$this->actingAs($this->user) $this->actingAs($this->user)
...@@ -96,6 +101,58 @@ class CityTest extends TestCase ...@@ -96,6 +101,58 @@ class CityTest extends TestCase
foreach ($this->token->cities as $city){ foreach ($this->token->cities as $city){
$this->assertEquals($city->campaigns->count(), 2); $this->assertEquals($city->campaigns->count(), 2);
} }
$camp = $this->token->cities[0]->campaigns[0];
$this->actingAs($this->user)
->post(route('token.campaign.variables', [
'token' => $this->token->id,
'campaign_id' => $camp->id
]),[
'variable' => 'add',
'name' => 'test',
'default_value' => 'default',
'value' => 'test_value'
])
->assertStatus(302);
foreach ($this->token->cities as $city){
foreach ($city->campaigns as $campaign){
$this->assertEquals($campaign->variables->count(), 1);
foreach ($campaign->variables as $var){
if ($campaign->id==$camp->id){
$this->assertEquals($var->value, 'test_value');
} else {
$this->assertEquals($var->value, 'default');
}
}
}
} }
$this->actingAs($this->user)
->post(route('token.city.store', [
'token' => $this->token2->id,
'city' => $ids[2]
]))
->assertStatus(302);
$this->token2->load('cities.campaigns');
$this->assertEquals($this->token2->cities->count(), 1);
foreach ($this->token2->cities as $city){
$this->assertEquals($city->campaigns->count(), 2);
}
foreach ($this->token2->cities as $city){
foreach ($city->campaigns as $campaign){
$this->assertEquals($campaign->variables->count(), 1);
foreach ($campaign->variables as $var){
$this->assertEquals($var->value, 'default');
}
}
}
//TODO: еще надо дописать добавление новой РК на управление. И автоматом эта РК должна во все города добавиться и автоматом
// должна переменная добавиться.
// и для чистоты эксперимента еще и вторую перменную добавить + еще бы имена перменных проверять на всякий случай
}
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!