test: Replace deprecated attributeEqualTo()

This commit is contained in:
Koji Tanaka 2023-01-07 14:30:06 +09:00 committed by Kamil Wylegala
parent b1138db8f4
commit b46b6c758f
2 changed files with 66 additions and 22 deletions

View file

@ -1246,16 +1246,24 @@ class ControllerTest extends CakeTestCase {
->with( ->with(
$this->logicalAnd( $this->logicalAnd(
$this->isInstanceOf('CakeEvent'), $this->isInstanceOf('CakeEvent'),
$this->attributeEqualTo('_name', 'Controller.initialize'), $this->callback(function (CakeEvent $event) {
$this->attributeEqualTo('_subject', $Controller) return $event->name() === 'Controller.initialize';
}),
$this->callback(function (CakeEvent $event) use ($Controller) {
return $event->subject() === $Controller;
}),
) )
); );
$eventManager->expects($this->at(1))->method('dispatch') $eventManager->expects($this->at(1))->method('dispatch')
->with( ->with(
$this->logicalAnd( $this->logicalAnd(
$this->isInstanceOf('CakeEvent'), $this->isInstanceOf('CakeEvent'),
$this->attributeEqualTo('_name', 'Controller.startup'), $this->callback(function (CakeEvent $event) {
$this->attributeEqualTo('_subject', $Controller) return $event->name() === 'Controller.startup';
}),
$this->callback(function (CakeEvent $event) use ($Controller) {
return $event->subject() === $Controller;
}),
) )
); );
$Controller->expects($this->exactly(2))->method('getEventManager') $Controller->expects($this->exactly(2))->method('getEventManager')
@ -1293,8 +1301,12 @@ class ControllerTest extends CakeTestCase {
->with( ->with(
$this->logicalAnd( $this->logicalAnd(
$this->isInstanceOf('CakeEvent'), $this->isInstanceOf('CakeEvent'),
$this->attributeEqualTo('_name', 'Controller.shutdown'), $this->callback(function (CakeEvent $event) {
$this->attributeEqualTo('_subject', $Controller) return $event->name() === 'Controller.shutdown';
}),
$this->callback(function (CakeEvent $event) use ($Controller) {
return $event->subject() === $Controller;
}),
) )
); );
$Controller->expects($this->once())->method('getEventManager') $Controller->expects($this->once())->method('getEventManager')

View file

@ -990,16 +990,24 @@ class ViewTest extends CakeTestCase {
->with( ->with(
$this->logicalAnd( $this->logicalAnd(
$this->isInstanceOf('CakeEvent'), $this->isInstanceOf('CakeEvent'),
$this->attributeEqualTo('_name', 'View.beforeRender'), $this->callback(function (CakeEvent $event) {
$this->attributeEqualTo('_subject', $View) return $event->name() === 'View.beforeRender';
}),
$this->callback(function (CakeEvent $event) use ($View) {
return $event->subject() === $View;
}),
) )
); );
$View->Helpers->expects($this->at(1))->method('trigger') $View->Helpers->expects($this->at(1))->method('trigger')
->with( ->with(
$this->logicalAnd( $this->logicalAnd(
$this->isInstanceOf('CakeEvent'), $this->isInstanceOf('CakeEvent'),
$this->attributeEqualTo('_name', 'View.beforeRenderFile'), $this->callback(function (CakeEvent $event) {
$this->attributeEqualTo('_subject', $View) return $event->name() === 'View.beforeRenderFile';
}),
$this->callback(function (CakeEvent $event) use ($View) {
return $event->subject() === $View;
}),
) )
); );
@ -1007,16 +1015,24 @@ class ViewTest extends CakeTestCase {
->with( ->with(
$this->logicalAnd( $this->logicalAnd(
$this->isInstanceOf('CakeEvent'), $this->isInstanceOf('CakeEvent'),
$this->attributeEqualTo('_name', 'View.afterRenderFile'), $this->callback(function (CakeEvent $event) {
$this->attributeEqualTo('_subject', $View) return $event->name() === 'View.afterRenderFile';
}),
$this->callback(function (CakeEvent $event) use ($View) {
return $event->subject() === $View;
}),
) )
); );
$View->Helpers->expects($this->at(3))->method('trigger') $View->Helpers->expects($this->at(3))->method('trigger')
->with( ->with(
$this->logicalAnd( $this->logicalAnd(
$this->isInstanceOf('CakeEvent'), $this->isInstanceOf('CakeEvent'),
$this->attributeEqualTo('_name', 'View.afterRender'), $this->callback(function (CakeEvent $event) {
$this->attributeEqualTo('_subject', $View) return $event->name() === 'View.afterRender';
}),
$this->callback(function (CakeEvent $event) use ($View) {
return $event->subject() === $View;
}),
) )
); );
@ -1024,8 +1040,12 @@ class ViewTest extends CakeTestCase {
->with( ->with(
$this->logicalAnd( $this->logicalAnd(
$this->isInstanceOf('CakeEvent'), $this->isInstanceOf('CakeEvent'),
$this->attributeEqualTo('_name', 'View.beforeLayout'), $this->callback(function (CakeEvent $event) {
$this->attributeEqualTo('_subject', $View) return $event->name() === 'View.beforeLayout';
}),
$this->callback(function (CakeEvent $event) use ($View) {
return $event->subject() === $View;
}),
) )
); );
@ -1033,8 +1053,12 @@ class ViewTest extends CakeTestCase {
->with( ->with(
$this->logicalAnd( $this->logicalAnd(
$this->isInstanceOf('CakeEvent'), $this->isInstanceOf('CakeEvent'),
$this->attributeEqualTo('_name', 'View.beforeRenderFile'), $this->callback(function (CakeEvent $event) {
$this->attributeEqualTo('_subject', $View) return $event->name() === 'View.beforeRenderFile';
}),
$this->callback(function (CakeEvent $event) use ($View) {
return $event->subject() === $View;
}),
) )
); );
@ -1042,8 +1066,12 @@ class ViewTest extends CakeTestCase {
->with( ->with(
$this->logicalAnd( $this->logicalAnd(
$this->isInstanceOf('CakeEvent'), $this->isInstanceOf('CakeEvent'),
$this->attributeEqualTo('_name', 'View.afterRenderFile'), $this->callback(function (CakeEvent $event) {
$this->attributeEqualTo('_subject', $View) return $event->name() === 'View.afterRenderFile';
}),
$this->callback(function (CakeEvent $event) use ($View) {
return $event->subject() === $View;
}),
) )
); );
@ -1051,8 +1079,12 @@ class ViewTest extends CakeTestCase {
->with( ->with(
$this->logicalAnd( $this->logicalAnd(
$this->isInstanceOf('CakeEvent'), $this->isInstanceOf('CakeEvent'),
$this->attributeEqualTo('_name', 'View.afterLayout'), $this->callback(function (CakeEvent $event) {
$this->attributeEqualTo('_subject', $View) return $event->name() === 'View.afterLayout';
}),
$this->callback(function (CakeEvent $event) use ($View) {
return $event->subject() === $View;
}),
) )
); );