Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # To get started with security, check out the documentation:
- # http://symfony.com/doc/current/book/security.html
- security:
- # http://symfony.com/doc/current/book/security.html#where-do-users-come-from-user-providers
- providers:
- in_memory:
- memory:
- users:
- admin:
- password: $2y$12$mWzkl91Q4moTzVYechsGPu52KpY/A8ZLWwK1aou4..q0LkOKMXFdq
- roles: 'ROLE_ADMIN'
- admin_2:
- password: $2y$12$uyCzM272bS.I335IvfUdeyxRu42ywKpC/51onQhMV2.yQBWSN6l3SEzqq
- roles: 'ROLE_ADMIN'
- firewalls:
- # disables authentication for assets and the profiler, adapt it according to your needs
- dev:
- pattern: ^/(_(profiler|wdt)|css|images|js)/
- security: false
- main:
- pattern: /.*
- anonymous: ~
- # activate different ways to authenticate
- # http_basic: ~
- # http://symfony.com/doc/current/book/security.html#a-configuring-how-your-users-will-authenticate
- # form_login: ~
- # http://symfony.com/doc/current/cookbook/security/form_login_setup.html
- provider: in_memory
- form_login:
- check_path: /admin_login_check
- login_path: /admin_login
- default_target_path: /admin/dashboard
- security: ~
- logout: ~
- encoders:
- SymfonyComponentSecurityCoreUserUser:
- algorithm: bcrypt
- cost: 12
- access_control:
- - { path: ^/admin/.*, roles: ROLE_ADMIN }
- - { path: ^/.*, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- <?php
- // src/Shop/AdminBundle/Tests/Controller/API/OrderStatusTest.php
- namespace ShopAdminBundleTestsControllerAPI;
- use SymfonyBundleFrameworkBundleTestWebTestCase;
- use SymfonyComponentBrowserKitCookie;
- use SymfonyComponentSecurityCoreAuthenticationTokenUsernamePasswordToken;
- class OrderStatusTest extends WebTestCase
- {
- private $client = null;
- public function setUp()
- {
- $this->client = static::createClient();
- }
- private function logIn()
- {
- $session = $this
- ->client
- ->getContainer()
- ->get('session');
- $firewall = "main";
- $token = new UsernamePasswordToken('admin', null, $firewall, array('ROLE_ADMIN'));
- $session->set('_secutiry_'. $firewall, serialize($token));
- $session->save();
- $cookie = new Cookie($session->getName(), $session->getId());
- $this->client->getCookieJar()->set($cookie);
- }
- public function testUpdate()
- {
- $kernel = static::createKernel();
- $kernel->boot();
- $this->logIn();
- $manager = $kernel
- ->getContainer()
- ->get('doctrine.orm.entity_manager');
- $dql = "SELECT o
- FROM ShopCartBundleEntityOrder as o";
- $query = $manager->createQuery($dql);
- $orders = $query->getResult();
- $order = $orders[0];
- $statuses = $manager->getRepository('ShopCartBundle:Status')
- ->findAll();
- foreach($statuses as $key => $status) {
- $statuses[$status->getName()] = $status;
- unset($statuses[$key]);
- }
- $status = $statuses['Новый'];
- $crawler = $this->client->request('GET', '/admin/api/order_status/update/'. $order->getId() .'/'. $status->getId());
- print_r($this->client->getResponse()->getContent());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement