How to use StringContainsToken class

Best Prophecy code snippet using StringContainsToken

MailboxRepositorySpec.php

Source:MailboxRepositorySpec.php Github

copy

Full Screen

...29 }30 public function it_can_create_a_mailbox(\PDOStatement $statement, Department $department) : void31 {32 $department->getId()->willReturn($departmentId = Uuid::uuid4());33 $this->db->prepare(new Argument\Token\StringContainsToken('INSERT'))->willReturn($statement);34 $statement->execute(new Argument\Token\TypeToken('array'));35 $mailbox = $this->createMailbox(36 $name = 'Mailbox',37 $department,38 $imapServer = 'mail.box',39 $imapPort = 587,40 $security = MailTransportSecurityValue::get(MailTransportSecurityValue::SECURITY_TLS),41 $imapUser = 'user',42 $imapPass = 'pass',43 $lastCheck = new \DateTimeImmutable()44 );45 $mailbox->getId()->shouldHaveType(UuidInterface::class);46 $mailbox->getName()->shouldBe($name);47 $mailbox->getDepartment()->shouldBe($department);48 $mailbox->getImapServer()->shouldBe($imapServer);49 $mailbox->getImapPort()->shouldBe($imapPort);50 $mailbox->getImapSecurity()->shouldBe($security);51 $mailbox->getImapUser()->shouldBe($imapUser);52 $mailbox->getImapPass()->shouldBe($imapPass);53 $mailbox->getLastCheck()->shouldBe($lastCheck);54 }55 public function it_can_get_a_mailbox(\PDOStatement $statement, Department $department) : void56 {57 $mailboxId = Uuid::uuid4();58 $departmentId = Uuid::uuid4();59 $this->departmentRepository->getDepartment(new Argument\Token\TypeToken(UuidInterface::class))60 ->willReturn($department);61 $name = 'Mailbox';62 $imapServer = 'mail.box';63 $imapPort = 587;64 $security = MailTransportSecurityValue::get(MailTransportSecurityValue::SECURITY_TLS);65 $imapUser = 'user';66 $imapPass = 'pass';67 $lastCheck = new \DateTimeImmutable();68 $this->db->prepare(new Argument\Token\StringContainsToken('SELECT'))->willReturn($statement);69 $statement->execute(['mailbox_id' => $mailboxId->getBytes()])->shouldBeCalled();70 $statement->rowCount()->willReturn(1);71 $statement->fetch(\PDO::FETCH_ASSOC)->willReturn(72 [73 'mailbox_id' => $mailboxId->getBytes(),74 'name' => $name,75 'department_id' => $departmentId->getBytes(),76 'imap_server' => $imapServer,77 'imap_port' => $imapPort,78 'imap_security' => $security->toString(),79 'imap_user' => $imapUser,80 'imap_pass' => $imapPass,81 'last_check' => $lastCheck->format('Y-m-d H:i:s'),82 ],83 null84 );85 $mailbox = $this->getMailbox($mailboxId);86 $mailbox->getId()->equals($mailboxId)->shouldBe(true);87 $mailbox->getName()->shouldBe($name);88 $mailbox->getDepartment()->shouldBe($department);89 $mailbox->getImapServer()->shouldBe($imapServer);90 $mailbox->getImapPort()->shouldBe($imapPort);91 $mailbox->getImapSecurity()->shouldBeLike($security);92 $mailbox->getImapUser()->shouldBe($imapUser);93 $mailbox->getImapPass()->shouldBe($imapPass);94 $mailbox->getLastCheck()->format('Y-m-d H:i:s')->shouldBe($lastCheck->format('Y-m-d H:i:s'));95 }96 public function it_will_error_when_getting_mailbox_failed(\PDOStatement $statement) : void97 {98 $mailboxId = Uuid::uuid4();99 $this->db->prepare(new Argument\Token\StringContainsToken('SELECT'))->willReturn($statement);100 $statement->execute(['mailbox_id' => $mailboxId->getBytes()])->shouldBeCalled();101 $statement->rowCount()->willReturn(0);102 $this->shouldThrow(\OutOfBoundsException::class)->duringGetMailbox($mailboxId);103 }104 public function it_can_get_all_mailboxes(\PDOStatement $statement, Department $department) : void105 {106 $mailboxId1 = Uuid::uuid4();107 $mailboxId2 = Uuid::uuid4();108 $departmentId = Uuid::uuid4();109 $this->departmentRepository->getDepartment(new Argument\Token\TypeToken(UuidInterface::class))110 ->willReturn($department);111 $this->db->query(new Argument\Token\StringContainsToken('SELECT'))->willReturn($statement);112 $statement->fetch(\PDO::FETCH_ASSOC)->willReturn(113 [114 'mailbox_id' => $mailboxId1->getBytes(),115 'name' => 'One',116 'department_id' => $departmentId->getBytes(),117 'imap_server' => 'one.dev',118 'imap_port' => 1,119 'imap_security' => MailTransportSecurityValue::SECURITY_SSL,120 'imap_user' => 'uone',121 'imap_pass' => 'pone',122 'last_check' => (new \DateTimeImmutable())->format('Y-m-d H:i:s'),123 ],124 [125 'mailbox_id' => $mailboxId2->getBytes(),126 'name' => 'Two',127 'department_id' => null,128 'imap_server' => 'two.dev',129 'imap_port' => 2,130 'imap_security' => MailTransportSecurityValue::SECURITY_NONE,131 'imap_user' => 'utwo',132 'imap_pass' => 'ptwo',133 'last_check' => (new \DateTimeImmutable())->format('Y-m-d H:i:s'),134 ],135 null136 );137 $mailboxes = $this->getMailboxes();138 $mailboxes->shouldHaveType(MailboxCollection::class);139 $mailboxes->count()->shouldBe(2);140 }141 public function it_can_get_all_mailboxes_for_department(\PDOStatement $statement, Department $department) : void142 {143 $mailboxId1 = Uuid::uuid4();144 $mailboxId2 = Uuid::uuid4();145 $departmentId = Uuid::uuid4();146 $department->getId()->willReturn($departmentId);147 $this->departmentRepository->getDepartment(new Argument\Token\TypeToken(UuidInterface::class))148 ->willReturn($department);149 $this->db->prepare(new Argument\Token\StringContainsToken('SELECT'))->willReturn($statement);150 $statement->execute(['department_id' => $departmentId->getBytes()])->shouldBeCalled();151 $statement->fetch(\PDO::FETCH_ASSOC)->willReturn(152 [153 'mailbox_id' => $mailboxId1->getBytes(),154 'name' => 'One',155 'department_id' => $departmentId->getBytes(),156 'imap_server' => 'one.dev',157 'imap_port' => 1,158 'imap_security' => MailTransportSecurityValue::SECURITY_SSL,159 'imap_user' => 'uone',160 'imap_pass' => 'pone',161 'last_check' => (new \DateTimeImmutable())->format('Y-m-d H:i:s'),162 ],163 [164 'mailbox_id' => $mailboxId2->getBytes(),165 'name' => 'Two',166 'department_id' => $departmentId->getBytes(),167 'imap_server' => 'two.dev',168 'imap_port' => 2,169 'imap_security' => MailTransportSecurityValue::SECURITY_NONE,170 'imap_user' => 'utwo',171 'imap_pass' => 'ptwo',172 'last_check' => (new \DateTimeImmutable())->format('Y-m-d H:i:s'),173 ],174 null175 );176 $mailboxes = $this->getMailboxesForDepartment($department);177 $mailboxes->shouldHaveType(MailboxCollection::class);178 $mailboxes->count()->shouldBe(2);179 }180 public function it_can_update_a_mailbox(\PDOStatement $statement, Mailbox $mailbox) : void181 {182 $mailbox->getId()->willReturn($mailboxId = Uuid::uuid4());183 $mailbox->getName()->willReturn($name = 'Mailbox');184 $mailbox->getDepartment()->willReturn($department = null);185 $mailbox->getImapServer()->willReturn($imapServer = 'mail.box');186 $mailbox->getImapPort()->willReturn($imapPort = 25);187 $mailbox->getImapSecurity()188 ->willReturn($security = MailTransportSecurityValue::get(MailTransportSecurityValue::SECURITY_TLS));189 $mailbox->getImapUser()->willReturn($imapUser = 'user');190 $mailbox->getImapPass()->willReturn($imapPass = 'pass');191 $this->db->prepare(new Argument\Token\StringContainsToken('UPDATE'))->willReturn($statement);192 $statement->execute([193 'mailbox_id' => $mailboxId->getBytes(),194 'name' => $name,195 'department_id' => $department,196 'imap_server' => $imapServer,197 'imap_port' => $imapPort,198 'imap_security' => $security->toString(),199 'imap_user' => $imapUser,200 'imap_pass' => $imapPass,201 ])->shouldBeCalled();202 $statement->rowCount()->willReturn(1);203 $this->updateMailbox($mailbox);204 }205 public function it_will_error_when_updating_mailbox_failed(206 \PDOStatement $statement,207 Mailbox $mailbox,208 Department $department209 ) : void210 {211 $mailbox->getId()->willReturn($mailboxId = Uuid::uuid4());212 $mailbox->getName()->willReturn($name = 'Mailbox');213 $mailbox->getDepartment()->willReturn($department);214 $mailbox->getImapServer()->willReturn($imapServer = 'mail.box');215 $mailbox->getImapPort()->willReturn($imapPort = 25);216 $mailbox->getImapSecurity()217 ->willReturn($security = MailTransportSecurityValue::get(MailTransportSecurityValue::SECURITY_TLS));218 $mailbox->getImapUser()->willReturn($imapUser = 'user');219 $mailbox->getImapPass()->willReturn($imapPass = 'pass');220 $department->getId()->willReturn($departmentId = Uuid::uuid4());221 $this->db->prepare(new Argument\Token\StringContainsToken('UPDATE'))->willReturn($statement);222 $statement->execute([223 'mailbox_id' => $mailboxId->getBytes(),224 'name' => $name,225 'department_id' => $departmentId->getBytes(),226 'imap_server' => $imapServer,227 'imap_port' => $imapPort,228 'imap_security' => $security->toString(),229 'imap_user' => $imapUser,230 'imap_pass' => $imapPass,231 ])->shouldBeCalled();232 $statement->rowCount()->willReturn(0);233 $this->shouldThrow(\RuntimeException::class)->duringUpdateMailbox($mailbox);234 }235 public function it_can_update_last_check_datetime_of_mailbox(\PDOStatement $statement, Mailbox $mailbox) : void236 {237 $mailbox->getId()->willReturn($mailboxId = Uuid::uuid4());238 $checkTime = new \DateTimeImmutable();239 $this->db->prepare(new Argument\Token\StringContainsToken('UPDATE'))->willReturn($statement);240 $statement->execute([241 'last_check' => $checkTime->format('Y-m-d H:i:s'),242 'mailbox_id' => $mailboxId->getBytes(),243 ])->shouldBeCalled();244 $statement->rowCount()->willReturn(1);245 $mailbox->setLastCheck($checkTime)->shouldBeCalled();246 $this->updateLastCheck($mailbox, $checkTime);247 }248 public function it_will_error_when_updating_last_check_datetime_of_mailbox_failed(249 \PDOStatement $statement,250 Mailbox $mailbox251 ) : void252 {253 $mailbox->getId()->willReturn($mailboxId = Uuid::uuid4());254 $this->db->prepare(new Argument\Token\StringContainsToken('UPDATE'))->willReturn($statement);255 $statement->execute(new Argument\Token\TypeToken('array'))->shouldBeCalled();256 $statement->rowCount()->willReturn(0);257 $this->shouldThrow(\RuntimeException::class)->duringUpdateLastCheck($mailbox);258 }259 public function it_can_delete_a_mailbox(\PDOStatement $statement, Mailbox $mailbox) : void260 {261 $mailbox->getId()->willReturn($mailboxId = Uuid::uuid4());262 $this->db->prepare(new Argument\Token\StringContainsToken('DELETE'))->willReturn($statement);263 $statement->execute(['mailbox_id' => $mailboxId->getBytes()])->shouldBeCalled();264 $statement->rowCount()->willReturn(1);265 $this->deleteMailbox($mailbox);266 }267 public function it_will_error_when_deleteing_mailbox_failed(\PDOStatement $statement, Mailbox $mailbox) : void268 {269 $mailbox->getId()->willReturn($mailboxId = Uuid::uuid4());270 $this->db->prepare(new Argument\Token\StringContainsToken('DELETE'))->willReturn($statement);271 $statement->execute(['mailbox_id' => $mailboxId->getBytes()])->shouldBeCalled();272 $statement->rowCount()->willReturn(0);273 $this->shouldThrow(\RuntimeException::class)->duringDeleteMailbox($mailbox);274 }275}...

Full Screen

Full Screen

UserRepositorySpec.php

Source:UserRepositorySpec.php Github

copy

Full Screen

...37 $user->getPassword()->willReturn($password);38 $roleName = 'admin';39 $user->getRole()->willReturn($role);40 $role->getName()->willReturn($roleName);41 $this->db->prepare(new Argument\Token\StringContainsToken('INSERT'))->willReturn($statement);42 $statement->execute([43 'email' => $email,44 'display_name' => $displayName,45 'password' => $password,46 'role' => $roleName,47 ])->shouldBeCalled();48 $this->createUser($user);49 }50 public function it_can_get_all_users(\PDOStatement $statement, RoleInterface $role) : void51 {52 $this->db->query(new Argument\Token\StringContainsToken('SELECT'))->willReturn($statement);53 $statement->fetch(\PDO::FETCH_ASSOC)->willReturn(54 ['email' => 'one@d.com', 'display_name' => 'One', 'password' => '...', 'role' => 'user', 'active' => true],55 ['email' => 'two@d.com', 'display_name' => 'Two', 'password' => '...', 'role' => 'user', 'active' => false],56 null57 );58 $this->rbac->getRole('user')->willReturn($role);59 $users = $this->getUsers();60 $users->shouldBeAnInstanceOf(UserCollection::class);61 $users['one@d.com']->shouldBeAnInstanceOf(User::class);62 $users['one@d.com']->getDisplayName()->shouldBe('One');63 $users['one@d.com']->getPassword()->shouldBe('...');64 $users['one@d.com']->isActive()->shouldBe(true);65 $users['two@d.com']->shouldBeAnInstanceOf(User::class);66 $users['two@d.com']->getDisplayName()->shouldBe('Two');67 $users['two@d.com']->getPassword()->shouldBe('...');68 $users['two@d.com']->isActive()->shouldBe(false);69 }70 public function it_can_get_all_users_for_department(71 \PDOStatement $statement,72 RoleInterface $role,73 Department $department74 ) : void75 {76 $departmentId = Uuid::uuid4();77 $department->getId()->willReturn($departmentId);78 $this->db->prepare(new Argument\Token\StringContainsToken('SELECT'))->willReturn($statement);79 $statement->execute(['department_id' => $departmentId->getBytes()])->shouldBeCalled();80 $statement->fetch(\PDO::FETCH_ASSOC)->willReturn(81 ['email' => 'one@d.com', 'display_name' => 'One', 'password' => '...', 'role' => 'user', 'active' => true],82 ['email' => 'two@d.com', 'display_name' => 'Two', 'password' => '...', 'role' => 'user', 'active' => false],83 null84 );85 $this->rbac->getRole('user')->willReturn($role);86 $users = $this->getUsersForDepartment($department);87 $users->shouldBeAnInstanceOf(UserCollection::class);88 $users['one@d.com']->shouldBeAnInstanceOf(User::class);89 $users['one@d.com']->getDisplayName()->shouldBe('One');90 $users['one@d.com']->getPassword()->shouldBe('...');91 $users['one@d.com']->isActive()->shouldBe(true);92 $users['two@d.com']->shouldBeAnInstanceOf(User::class);93 $users['two@d.com']->getDisplayName()->shouldBe('Two');94 $users['two@d.com']->getPassword()->shouldBe('...');95 $users['two@d.com']->isActive()->shouldBe(false);96 }97 public function it_can_get_one_user(\PDOStatement $statement, RoleInterface $role) : void98 {99 $email = 'user@domain.mail';100 $this->db->prepare(new Argument\Token\StringContainsToken('SELECT'))->willReturn($statement);101 $statement->execute(['email' => $email])->shouldBeCalled();102 $statement->rowCount()->willReturn(1);103 $statement->fetch(\PDO::FETCH_ASSOC)->willReturn(104 ['email' => $email, 'display_name' => 'One', 'password' => '...', 'role' => 'user', 'active' => true],105 null106 );107 $this->rbac->getRole('user')->willReturn($role);108 $user = $this->getUserByEmail(EmailAddressValue::get($email));109 $user->shouldBeAnInstanceOf(User::class);110 $user->getEmail()->toString()->shouldBeLike($email);111 $user->getDisplayName()->shouldBe('One');112 $user->getPassword()->shouldBe('...');113 $user->isActive()->shouldBe(true);114 }115 public function it_errors_when_user_doesnt_exist(\PDOStatement $statement) : void116 {117 $email = 'user@domain.mail';118 $this->db->prepare(new Argument\Token\StringContainsToken('SELECT'))->willReturn($statement);119 $statement->execute(['email' => $email])->shouldBeCalled();120 $statement->rowCount()->willReturn(0);121 $this->shouldThrow(\OutOfBoundsException::class)->duringGetUserByEmail(EmailAddressValue::get($email));122 }123 public function it_can_update_a_user(\PDOStatement $statement, User $user, RoleInterface $role)124 {125 $user->getDisplayName()->willReturn($displayName = 'My Name');126 $user->getEmail()->willReturn($email = EmailAddressValue::get('my@name.email'));127 $user->getRole()->willReturn($role);128 $user->isActive()->willReturn($active = true);129 $role->getName()->willReturn($roleName = 'user');130 $this->db->prepare(new Argument\Token\StringContainsToken('UPDATE'))->willReturn($statement);131 $statement->execute([132 'display_name' => $displayName,133 'email' => $email->toString(),134 'role' => $roleName,135 'active' => intval($active),136 ])->shouldBeCalled();137 $statement->rowCount()->willReturn(1);138 $this->updateUser($user);139 }140 public function it_errors_when_updating_a_user_fails(\PDOStatement $statement, User $user, RoleInterface $role)141 {142 $user->getDisplayName()->willReturn($displayName = 'My Name');143 $user->getEmail()->willReturn($email = EmailAddressValue::get('my@name.email'));144 $user->getRole()->willReturn($role);145 $user->isActive()->willReturn($active = true);146 $role->getName()->willReturn($roleName = 'user');147 $this->db->prepare(new Argument\Token\StringContainsToken('UPDATE'))->willReturn($statement);148 $statement->execute([149 'display_name' => $displayName,150 'email' => $email->toString(),151 'role' => $roleName,152 'active' => intval($active),153 ])->shouldBeCalled();154 $statement->rowCount()->willReturn(0);155 $this->shouldThrow(\RuntimeException::class)->duringUpdateUser($user);156 }157 public function it_can_update_a_users_password(\PDOStatement $statement, User $user)158 {159 $user->getEmail()->willReturn($email = EmailAddressValue::get('my@name.email'));160 $password = password_hash('some-password', PASSWORD_DEFAULT);161 $this->db->prepare(new Argument\Token\StringContainsToken('UPDATE'))->willReturn($statement);162 $statement->execute([163 'email' => $email->toString(),164 'password' => $password,165 ])->shouldBeCalled();166 $statement->rowCount()->willReturn(1);167 $user->setPassword($password)->shouldBeCalled();168 $this->updatePassword($user, $password);169 }170 public function it_errors_when_updating_a_users_password_fails(\PDOStatement $statement, User $user)171 {172 $user->getEmail()->willReturn($email = EmailAddressValue::get('my@name.email'));173 $password = password_hash('some-password', PASSWORD_DEFAULT);174 $this->db->prepare(new Argument\Token\StringContainsToken('UPDATE'))->willReturn($statement);175 $statement->execute([176 'email' => $email->toString(),177 'password' => $password,178 ])->shouldBeCalled();179 $statement->rowCount()->willReturn(0);180 $user->setPassword($password)->shouldNotBeCalled();181 $this->shouldThrow(\RuntimeException::class)->duringUpdatePassword($user, $password);182 }183 public function it_can_assign_a_user_to_a_department(184 User $user,185 Department $department,186 \PDOStatement $statement187 ) : void188 {189 $departmentId = Uuid::uuid4();190 $department->getId()->willReturn($departmentId);191 $user->getEmail()->willReturn($email = EmailAddressValue::get('my@name.email'));192 $this->db->prepare(new Argument\Token\StringContainsToken('INSERT'))->willReturn($statement);193 $statement->execute([194 'email' => $email->toString(),195 'department_id' => $departmentId->getBytes(),196 ])->shouldBeCalled();197 $statement->rowCount()->willReturn(1);198 $this->assignUserToDepartment($user, $department);199 }200 public function it_will_error_when_assigning_user_to_department_failed(201 User $user,202 Department $department,203 \PDOStatement $statement204 ) : void205 {206 $departmentId = Uuid::uuid4();207 $department->getId()->willReturn($departmentId);208 $department->getName()->willReturn('myGroup');209 $user->getEmail()->willReturn($email = EmailAddressValue::get('my@name.email'));210 $this->db->prepare(new Argument\Token\StringContainsToken('INSERT'))->willReturn($statement);211 $statement->execute([212 'email' => $email->toString(),213 'department_id' => $departmentId->getBytes(),214 ])->shouldBeCalled();215 $statement->rowCount()->willReturn(0);216 $this->shouldThrow(\RuntimeException::class)->duringAssignUserToDepartment($user, $department);217 }218 public function it_can_remove_a_user_from_a_department(219 User $user,220 Department $department,221 \PDOStatement $statement222 ) : void223 {224 $departmentId = Uuid::uuid4();225 $department->getId()->willReturn($departmentId);226 $user->getEmail()->willReturn($email = EmailAddressValue::get('my@name.email'));227 $this->db->prepare(new Argument\Token\StringContainsToken('DELETE'))->willReturn($statement);228 $statement->execute([229 'email' => $email->toString(),230 'department_id' => $departmentId->getBytes(),231 ])->shouldBeCalled();232 $statement->rowCount()->willReturn(1);233 $this->removeUserFromDepartment($user, $department);234 }235 public function it_will_error_when_removing_user_from_department_failed(236 User $user,237 Department $department,238 \PDOStatement $statement239 ) : void240 {241 $departmentId = Uuid::uuid4();242 $department->getId()->willReturn($departmentId);243 $department->getName()->willReturn('myGroup');244 $user->getEmail()->willReturn($email = EmailAddressValue::get('my@name.email'));245 $this->db->prepare(new Argument\Token\StringContainsToken('DELETE'))->willReturn($statement);246 $statement->execute([247 'email' => $email->toString(),248 'department_id' => $departmentId->getBytes(),249 ])->shouldBeCalled();250 $statement->rowCount()->willReturn(0);251 $this->shouldThrow(\RuntimeException::class)->duringRemoveUserFromDepartment($user, $department);252 }253 public function it_can_delete_a_user(User $user, \PDOStatement $statement) : void254 {255 $user->getEmail()->willReturn($email = EmailAddressValue::get('my@name.email'));256 $this->db->prepare(new Argument\Token\StringContainsToken('DELETE'))->willReturn($statement);257 $statement->execute(['email' => $email->toString()])->shouldBeCalled();258 $statement->rowCount()->willReturn(1);259 $this->deleteUser($user);260 }261 public function it_will_error_when_deleting_user_failed(User $user, \PDOStatement $statement) : void262 {263 $user->getEmail()->willReturn($email = EmailAddressValue::get('my@name.email'));264 $this->db->prepare(new Argument\Token\StringContainsToken('DELETE'))->willReturn($statement);265 $statement->execute(['email' => $email->toString()])->shouldBeCalled();266 $statement->rowCount()->willReturn(0);267 $this->shouldThrow(\RuntimeException::class)->duringDeleteUser($user);268 }269}...

Full Screen

Full Screen

DepartmentRepositorySpec.php

Source:DepartmentRepositorySpec.php Github

copy

Full Screen

...26 public function it_can_create_a_department(Department $parent, \PDOStatement $statement) : void27 {28 $parentId = Uuid::uuid4();29 $parent->getId()->willReturn($parentId);30 $this->db->prepare(new Argument\Token\StringContainsToken('INSERT'))->willReturn($statement);31 $statement->execute(new Argument\Token\TypeToken('array'));32 $department = $this->createDepartment(33 $name = 'Department',34 $parent,35 $email = EmailAddressValue::get('one@two.three')36 );37 $department->shouldHaveType(Department::class);38 $department->getId()->shouldHaveType(UuidInterface::class);39 $department->getName()->shouldBe($name);40 $department->getParent()->shouldBe($parent);41 $department->getEmail()->shouldBe($email);42 }43 public function it_can_get_all_departments(\PDOStatement $statement) : void44 {45 $uuid1 = Uuid::uuid4();46 $uuid2 = Uuid::uuid4();47 $uuid3 = Uuid::uuid4();48 $this->db->query(new Argument\Token\StringContainsToken('SELECT'))->willReturn($statement);49 $statement->fetch(\PDO::FETCH_ASSOC)->willReturn(50 ['department_id' => $uuid1->getBytes(), 'name' => 'One', 'parent_id' => null, 'email' => 'one@dom.dev'],51 ['department_id' => $uuid2->getBytes(), 'name' => 'Two', 'parent_id' => $uuid1->getBytes(), 'email' => 'two@dom.dev'],52 ['department_id' => $uuid3->getBytes(), 'name' => 'Three', 'parent_id' => null, 'email' => 'three@dom.dev'],53 null54 );55 $departments = $this->getDepartments();56 $departments->shouldHaveType(DepartmentCollection::class);57 $departments[$uuid1->toString()]->getName()->shouldBe('One');58 $departments[$uuid1->toString()]->getParent()->shouldBe(null);59 $departments[$uuid1->toString()]->getEmail()->toString()->shouldBe('one@dom.dev');60 $departments[$uuid2->toString()]->getName()->shouldBe('Two');61 $departments[$uuid2->toString()]->getParent()->getId()->equals($uuid1)->shouldBe(true);62 $departments[$uuid2->toString()]->getEmail()->toString()->shouldBe('two@dom.dev');63 $departments[$uuid3->toString()]->getName()->shouldBe('Three');64 $departments[$uuid3->toString()]->getParent()->shouldBe(null);65 $departments[$uuid3->toString()]->getEmail()->toString()->shouldBe('three@dom.dev');66 }67 public function it_can_get_one_department(\PDOStatement $statement) : void68 {69 $uuid1 = Uuid::uuid4();70 $uuid2 = Uuid::uuid4();71 $uuid3 = Uuid::uuid4();72 $this->db->query(new Argument\Token\StringContainsToken('SELECT'))->willReturn($statement);73 $statement->fetch(\PDO::FETCH_ASSOC)->willReturn(74 ['department_id' => $uuid1->getBytes(), 'name' => 'One', 'parent_id' => null, 'email' => 'one@dom.dev'],75 ['department_id' => $uuid2->getBytes(), 'name' => 'Two', 'parent_id' => $uuid1->getBytes(), 'email' => 'two@dom.dev'],76 ['department_id' => $uuid3->getBytes(), 'name' => 'Three', 'parent_id' => null, 'email' => 'three@dom.dev'],77 null78 );79 $department = $this->getDepartment($uuid1);80 $department->shouldHaveType(Department::class);81 $department->getId()->equals($uuid1)->shouldBe(true);82 }83 public function it_errors_when_getting_non_existent_department(\PDOStatement $statement) : void84 {85 $this->db->query(new Argument\Token\StringContainsToken('SELECT'))->willReturn($statement);86 $statement->fetch(\PDO::FETCH_ASSOC)->willReturn(null);87 $this->shouldThrow(\OutOfBoundsException::class)->duringGetDepartment(Uuid::uuid4());88 }89 public function it_can_get_a_users_departments(90 \PDOStatement $statement1,91 \PDOStatement $statement2,92 User $user93 ) : void94 {95 $uuid1 = Uuid::uuid4();96 $uuid2 = Uuid::uuid4();97 $uuid3 = Uuid::uuid4();98 $userMail = EmailAddressValue::get('user@mail.dev');99 $user->getEmail()->willReturn($userMail);100 $this->db->query(new Argument\Token\StringContainsToken('SELECT'))->willReturn($statement1);101 $statement1->fetch(\PDO::FETCH_ASSOC)->willReturn(102 ['department_id' => $uuid1->getBytes(), 'name' => 'One', 'parent_id' => null, 'email' => 'one@dom.dev'],103 ['department_id' => $uuid2->getBytes(), 'name' => 'Two', 'parent_id' => $uuid1->getBytes(), 'email' => 'two@dom.dev'],104 ['department_id' => $uuid3->getBytes(), 'name' => 'Three', 'parent_id' => null, 'email' => 'three@dom.dev'],105 null106 );107 $this->db->prepare(new Argument\Token\StringContainsToken('SELECT'))->willReturn($statement2);108 $statement2->execute(['email' => $userMail->toString()])->shouldBeCalled();109 $statement2->fetch(\PDO::FETCH_ASSOC)->willReturn(110 ['department_id' => $uuid2->getBytes(), 'name' => 'Two', 'parent_id' => $uuid1->getBytes(), 'email' => 'two@dom.dev'],111 ['department_id' => $uuid3->getBytes(), 'name' => 'Three', 'parent_id' => null, 'email' => 'three@dom.dev'],112 null113 );114 $departments = $this->getDepartmentsForUser($user);115 $departments->shouldHaveType(DepartmentCollection::class);116 $departments->shouldNotHaveKey($uuid1->toString());117 $departments[$uuid2->toString()]->getName()->shouldBe('Two');118 $departments[$uuid2->toString()]->getParent()->getId()->equals($uuid1)->shouldBe(true);119 $departments[$uuid2->toString()]->getEmail()->toString()->shouldBe('two@dom.dev');120 $departments[$uuid3->toString()]->getName()->shouldBe('Three');121 $departments[$uuid3->toString()]->getParent()->shouldBe(null);122 $departments[$uuid3->toString()]->getEmail()->toString()->shouldBe('three@dom.dev');123 }124 public function it_can_update_a_department(\PDOStatement $statement, Department $department) : void125 {126 $department->getId()->willReturn($departmentId = Uuid::uuid4());127 $department->getName()->willReturn($name = 'DepartmentName');128 $department->getParent()->willReturn(null);129 $department->getEmail()->willReturn($email = EmailAddressValue::get('dep@art.ment'));130 $this->db->prepare(new Argument\Token\StringContainsToken('UPDATE'))->willReturn($statement);131 $statement->execute([132 'name' => $name,133 'email' => $email->toString(),134 'parent_id' => null,135 'department_id' => $departmentId->getBytes(),136 ])->shouldBeCalled();137 $statement->rowCount()->willReturn(1);138 $this->updateDepartment($department);139 }140 public function it_will_error_when_updating_department_failed(141 \PDOStatement $statement,142 Department $department143 ) : void144 {145 $department->getId()->willReturn($departmentId = Uuid::uuid4());146 $department->getName()->willReturn($name = 'DepartmentName');147 $department->getParent()->willReturn(null);148 $department->getEmail()->willReturn($email = EmailAddressValue::get('dep@art.ment'));149 $this->db->prepare(new Argument\Token\StringContainsToken('UPDATE'))->willReturn($statement);150 $statement->execute([151 'name' => $name,152 'email' => $email->toString(),153 'parent_id' => null,154 'department_id' => $departmentId->getBytes(),155 ])->shouldBeCalled();156 $statement->rowCount()->willReturn(0);157 $this->shouldThrow(\RuntimeException::class)->duringUpdateDepartment($department);158 }159 public function it_can_delete_a_department(\PDOStatement $statement, Department $department) : void160 {161 $department->getId()->willReturn($uuid = Uuid::uuid4());162 $this->db->prepare(new Argument\Token\StringContainsToken('DELETE'))->willReturn($statement);163 $statement->execute(['department_id' => $uuid->getBytes()])->shouldBeCalled();164 $statement->rowCount()->willReturn(1);165 $this->deleteDepartment($department);166 }167 public function it_will_error_when_deleting_department_failed(168 \PDOStatement $statement,169 Department $department170 ) : void171 {172 $department->getId()->willReturn($uuid = Uuid::uuid4());173 $this->db->prepare(new Argument\Token\StringContainsToken('DELETE'))->willReturn($statement);174 $statement->execute(['department_id' => $uuid->getBytes()])->shouldBeCalled();175 $statement->rowCount()->willReturn(0);176 $this->shouldThrow(\RuntimeException::class)->duringDeleteDepartment($department);177 }178}...

Full Screen

Full Screen

StringContainsToken

Using AI Code Generation

copy

Full Screen

1use Prophecy\Argument;2$prophet = new Prophecy\Prophet;3$token = new Prophecy\Argument\Token\StringContainsToken('foo');4$double = $prophet->prophesize('stdClass');5$double->foo('bar')->willReturn('baz');6$double->foo('foo')->willReturn('baz');7$double->foo('foofoo')->willReturn('baz');8$double->foo('foofoofoo')->willReturn('baz');9$double->foo('foofoofoofoo')->willReturn('baz');10$double->foo('foofoofoofoofoo')->willReturn('baz');11$double->foo('foofoofoofoofoofoo')->willReturn('baz');12$double->foo('foofoofoofoofoofoofoo')->willReturn('baz');13$double->foo('foofoofoofoofoofoofoofoo')->willReturn('baz');14$double->foo('foofoofoofoofoofoofoofoofoo')->willReturn('baz');

Full Screen

Full Screen

StringContainsToken

Using AI Code Generation

copy

Full Screen

1require_once 'StringContainsToken.php';2use Prophecy\Argument;3{4 public function testStringContainsToken()5 {6 $class = new StringContainsToken();7 $this->assertTrue($class->isToken('string'));8 }9}10require_once 'StringContainsToken.php';11use Prophecy\Argument;12{13 public function testStringContainsToken()14 {15 $class = new StringContainsToken();16 $this->assertTrue($class->isToken('string'));17 }18}19require_once 'StringContainsToken.php';20use Prophecy\Argument;21{22 public function testStringContainsToken()23 {24 $class = new StringContainsToken();25 $this->assertTrue($class->isToken('string'));26 }27}28require_once 'StringContainsToken.php';29use Prophecy\Argument;30{31 public function testStringContainsToken()32 {33 $class = new StringContainsToken();34 $this->assertTrue($class->isToken('string'));35 }36}37require_once 'StringContainsToken.php';38use Prophecy\Argument;39{40 public function testStringContainsToken()41 {42 $class = new StringContainsToken();43 $this->assertTrue($class->isToken('string'));44 }45}46require_once 'StringContainsToken.php';47use Prophecy\Argument;48{49 public function testStringContainsToken()50 {51 $class = new StringContainsToken();52 $this->assertTrue($class->isToken('string'));53 }54}55require_once 'StringContainsToken.php';56use Prophecy\Argument;

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Prophecy automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used methods in StringContainsToken

Run Selenium Automation Tests on LambdaTest Cloud Grid

Trigger Selenium automation tests on a cloud-based Grid of 3000+ real browsers and operating systems.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful